misc. stuff:

- Improved readmes.
- Fixed incorrect definition of kint32min.
- Fixed absolute output paths on Windows.
- Added info to Java POM that will be required when we upload the
  package to a Maven repo.
This commit is contained in:
temporal 2008-07-21 20:28:30 +00:00
parent e8564291e2
commit cc930432c2
9 changed files with 195 additions and 21 deletions

View File

@ -10,8 +10,8 @@ incompatible way in the future. It's unlikely that any big changes
will be made, but we can make no promises. Expect a non-beta release
sometime in August 2008.
C++ Installation
================
C++ Installation - Unix
=======================
To build and install the C++ Protocol Buffer runtime and the Protocol
Buffer compiler (protoc) execute the following:
@ -27,7 +27,19 @@ Proceed at your own risk.
"make install" may require superuser privileges.
For advanced usage information on configure and make, see INSTALL.
For advanced usage information on configure and make, see INSTALL.txt.
** Hint on insall location **
By default, the package will be installed to /usr/local. However,
on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
You can add it, but it may be easier to just install to /usr
instead. To do this, invoke configure as follows:
./configure --prefix=/usr
If you already built the package with a different prefix, make sure
to run "make clean" before building again.
** Note for Solaris users **
@ -39,6 +51,14 @@ For advanced usage information on configure and make, see INSTALL.
See src/solaris/libstdc++.la for more info on this bug.
C++ Installation - Windows
==========================
If you are using Micosoft Visual C++, see vsprojects/readme.txt.
If you are using Cygwin or MinGW, follow the Unix installation
instructions, above.
Java and Python Installation
============================

View File

@ -3,8 +3,11 @@ Copyright 2008 Google Inc.
This directory contains the Java Protocol Buffers runtime library.
Installation
============
Installation - With Maven
=========================
The Protocol Buffers build is managed using Maven. If you would
rather build without Maven, see the next section.
1) Install Apache Maven if you don't have it:
@ -37,6 +40,31 @@ Installation
The .jar will be placed in the "target" directory.
Installation - Without Maven
============================
If you would rather not install Maven to build the library, you may
follow these instructions instead. Note that these instructions skip
running unit tests.
1) Build the C++ code, or obtain a binary distribution of protoc. If
you install a binary distribution, make sure that it is the same
version as this package. If in doubt, run:
$ protoc --version
If you built the C++ code without installing, the compiler binary
should be located in ../src.
2) Invoke protoc to build DescriptorProtos.java:
$ protoc --java_out=src/main/java -I../src \
../src/google/protobuf/descriptor.proto
3) Compile the code in src/main/java using whatever means you prefer.
4) Install the classes wherever you prefer.
Usage
=====

View File

@ -14,10 +14,27 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.0.1-SNAPSHOT</version>
<name>Protocol Buffer Java API</name>
<packaging>jar</packaging>
<name>Protocol Buffer Java API</name>
<description>
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format.
</description>
<inceptionYear>2008</inceptionYear>
<url>http://code.google.com/p/protobuf</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>http://code.google.com/p/protobuf/source/browse</url>
<connection>
scm:svn:http://protobuf.googlecode.com/svn/trunk/
</connection>
</scm>
<dependencies>
<dependency>
<groupId>junit</groupId>
@ -89,7 +106,8 @@
<arg value="../src/google/protobuf/unittest.proto" />
<arg value="../src/google/protobuf/unittest_import.proto" />
<arg value="../src/google/protobuf/unittest_mset.proto" />
<arg value="src/test/java/com/google/protobuf/multiple_files_test.proto" />
<arg
value="src/test/java/com/google/protobuf/multiple_files_test.proto" />
<arg
value="../src/google/protobuf/unittest_optimize_for.proto" />
</exec>

View File

@ -3,6 +3,18 @@ Copyright 2008 Google Inc.
This directory contains the Python Protocol Buffers runtime library.
Normally, this directory comes as part of the protobuf package, available
from:
http://code.google.com/p/protobuf
The complete package includes the C++ source code, which includes the
Protocol Compiler (protoc). If you downloaded this package from PyPI
or some other Python-specific source, you may have received only the
Python part of the code. In this case, you will need to obtain the
Protocol Compiler from some other source before you can use this
package.
Installation
============

View File

@ -29,6 +29,7 @@
#endif
#include <errno.h>
#include <iostream>
#include <ctype.h>
#include <google/protobuf/compiler/command_line_interface.h>
#include <google/protobuf/compiler/importer.h>
@ -67,6 +68,20 @@ static const char* kPathSeparator = ";";
#else
static const char* kPathSeparator = ":";
#endif
// Returns true if the text looks like a Windows-style absolute path, starting
// with a drive letter. Example: "C:\foo".
static bool IsWindowsAbsolutePath(const string& text) {
#if defined(_WIN32) || defined(__CYGWIN__)
return text.size() >= 3 && text[1] == ':' &&
isalpha(text[0]) &&
(text[2] == '/' || text[2] == '\\') &&
text.find_last_of(':') == 1;
#else
return false;
#endif
}
} // namespace
// A MultiFileErrorCollector that prints errors to stderr.
@ -502,18 +517,14 @@ bool CommandLineInterface::InterpretArgument(const string& name,
directive.generator = iter->second.generator;
// Split value at ':' to separate the generator parameter from the
// filename.
vector<string> parts;
SplitStringUsing(value, ":", &parts);
if (parts.size() == 1) {
directive.output_location = parts[0];
} else if (parts.size() == 2) {
directive.parameter = parts[0];
directive.output_location = parts[1];
// filename. However, avoid doing this if the colon is part of a valid
// Windows-style absolute path.
string::size_type colon_pos = value.find_first_of(':');
if (colon_pos == string::npos || IsWindowsAbsolutePath(value)) {
directive.output_location = value;
} else {
cerr << "Invalid value for flag " << name << "." << endl;
return false;
directive.parameter = value.substr(0, colon_pos);
directive.output_location = value.substr(colon_pos + 1);
}
output_directives_.push_back(directive);

View File

@ -51,6 +51,7 @@ class CommandLineInterfaceTest : public testing::Test {
// Methods to set up the test (called before Run()).
class MockCodeGenerator;
class NullCodeGenerator;
// Registers a MockCodeGenerator with the given name.
MockCodeGenerator* RegisterGenerator(const string& generator_name,
@ -63,6 +64,10 @@ class CommandLineInterfaceTest : public testing::Test {
const string& filename,
const string& help_text);
// Registers a CodeGenerator which will not actually generate anything,
// but records the parameter passed to the generator.
NullCodeGenerator* RegisterNullGenerator(const string& flag_name);
// Create a temp file within temp_directory_ with the given name.
// The containing directory is also created if necessary.
void CreateTempFile(const string& name, const string& contents);
@ -122,7 +127,7 @@ class CommandLineInterfaceTest : public testing::Test {
string error_text_;
// Pointers which need to be deleted later.
vector<MockCodeGenerator*> mock_generators_to_delete_;
vector<CodeGenerator*> mock_generators_to_delete_;
};
// A mock CodeGenerator which outputs information about the context in which
@ -159,6 +164,25 @@ class CommandLineInterfaceTest::MockCodeGenerator : public CodeGenerator {
bool expect_write_error_;
};
class CommandLineInterfaceTest::NullCodeGenerator : public CodeGenerator {
public:
NullCodeGenerator() : called_(false) {}
~NullCodeGenerator() {}
mutable bool called_;
mutable string parameter_;
// implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file,
const string& parameter,
OutputDirectory* output_directory,
string* error) const {
called_ = true;
parameter_ = parameter;
return true;
}
};
// ===================================================================
void CommandLineInterfaceTest::SetUp() {
@ -239,6 +263,15 @@ CommandLineInterfaceTest::RegisterErrorGenerator(
return generator;
}
CommandLineInterfaceTest::NullCodeGenerator*
CommandLineInterfaceTest::RegisterNullGenerator(
const string& flag_name) {
NullCodeGenerator* generator = new NullCodeGenerator;
mock_generators_to_delete_.push_back(generator);
cli_.RegisterGenerator(flag_name, generator, "");
return generator;
}
void CommandLineInterfaceTest::CreateTempFile(
const string& name,
const string& contents) {
@ -424,6 +457,42 @@ TEST_F(CommandLineInterfaceTest, GeneratorParameters) {
"foo.proto", "Foo", "output.test");
}
#if defined(_WIN32) || defined(__CYGWIN__)
TEST_F(CommandLineInterfaceTest, WindowsOutputPath) {
// Test that the output path can be a Windows-style path.
NullCodeGenerator* generator = RegisterNullGenerator("--test_out");
CreateTempFile("foo.proto",
"syntax = \"proto2\";\n");
Run("protocol_compiler --test_out=C:\\ "
"--proto_path=$tmpdir foo.proto");
ExpectNoErrors();
EXPECT_TRUE(generator->called_);
EXPECT_EQ("", generator->parameter_);
}
TEST_F(CommandLineInterfaceTest, WindowsOutputPathAndParameter) {
// Test that we can have a windows-style output path and a parameter.
NullCodeGenerator* generator = RegisterNullGenerator("--test_out");
CreateTempFile("foo.proto",
"syntax = \"proto2\";\n");
Run("protocol_compiler --test_out=bar:C:\\ "
"--proto_path=$tmpdir foo.proto");
ExpectNoErrors();
EXPECT_TRUE(generator->called_);
EXPECT_EQ("bar", generator->parameter_);
}
#endif // defined(_WIN32) || defined(__CYGWIN__)
TEST_F(CommandLineInterfaceTest, PathLookup) {
// Test that specifying multiple directories in the proto search path works.

View File

@ -147,7 +147,7 @@ typedef uint64_t uint64;
#endif
static const int32 kint32max = 0x7FFFFFFF;
static const int32 kint32min = -kint32min - 1;
static const int32 kint32min = -kint32max - 1;
static const int64 kint64max = GOOGLE_LONGLONG(0x7FFFFFFFFFFFFFFF);
static const int64 kint64min = -kint64max - 1;
static const uint32 kuint32max = 0xFFFFFFFFu;

View File

@ -50,6 +50,17 @@ TEST(VersionTest, VersionMatchesConfig) {
#endif // PACKAGE_VERSION
TEST(CommonTest, IntMinMaxConstants) {
// kint32min was declared incorrectly in the first release of protobufs.
// Ugh.
EXPECT_LT(kint32min, kint32max);
EXPECT_EQ(static_cast<uint32>(kint32min), static_cast<uint32>(kint32max) + 1);
EXPECT_LT(kint64min, kint64max);
EXPECT_EQ(static_cast<uint64>(kint64min), static_cast<uint64>(kint64max) + 1);
EXPECT_EQ(0, kuint32max + 1);
EXPECT_EQ(0, kuint64max + 1);
}
vector<string> captured_messages_;
void CaptureLog(LogLevel level, const char* filename, int line,

View File

@ -7,7 +7,7 @@ Compiling and Installing
========================
1) Open protobuf.sln in Microsoft Visual Studio.
2) Choose "Debug" or "Release" configuration as desired.
2) Choose "Debug" or "Release" configuration as desired.*
3) From the Build menu, choose "Build Solution". Wait for compiling to finish.
4) From a command shell, run tests.exe and check that all tests pass.
5) Run extract_includes.bat to copy all the public headers into a separate
@ -19,6 +19,11 @@ Compiling and Installing
8) Copy libprotobuf.{lib,dll} and libprotoc.{lib,dll} wherever you put
libraries.
* To avoid conflicts between the MSVC debug and release runtime libraries, when
compiling a debug build of your application, you must link against a debug
build of libprotobuf.dll. Similarly, release builds must link against
release DLLs.
DLLs and Distribution
=====================