Commit 9b10f584 authored by kenton@google.com's avatar kenton@google.com

* Fix build on MSVC.

* Switch to statically-linked libraries instead of DLLs on MSVC.
parent 0b3023fa
2008-09-24 version 2.0.2:
2008-09-29 version 2.0.2:
General
* License changed from Apache 2.0 to New BSD.
* It is now possible to define custom "options", which are basically
......@@ -28,12 +28,12 @@
predictable among other things.
* TextFormat will no longer accept messages which contain multiple
instances of a singular field. Previously, the latter instance
would overwrite the former.
would overwrite the former.
* Now works on systems that don't have hash_map.
Java
* Print @Override annotation in generated code where appropriate.
Java
* Print @Override annotation in generated code where appropriate.
Python
* Strings now use the "unicode" type rather than the "str" type.
String fields may still be assigned ASCII "str" values; they will
......@@ -42,55 +42,59 @@
raises an exception. For example:
# No longer works (and never should have).
message.some_repeated_field.foo = 1
Windows
* We now build static libraries rather than DLLs by default on MSVC.
See vsprojects/readme.txt for more information.
2008-08-15 version 2.0.1:
protoc
* New flags --encode and --decode can be used to convert between protobuf text
format and binary format from the command-line.
* New flag --descriptor_set_out can be used to write FileDescriptorProtos for
all parsed files directly into a single output file. This is particularly
useful if you wish to parse .proto files from programs written in languages
other than C++: just run protoc as a background process and have it output
a FileDescriptorList, then parse that natively.
* Improved error message when an enum value's name conflicts with another
symbol defined in the enum type's scope, e.g. if two enum types declared
in the same scope have values with the same name. This is disallowed for
protoc
* New flags --encode and --decode can be used to convert between protobuf text
format and binary format from the command-line.
* New flag --descriptor_set_out can be used to write FileDescriptorProtos for
all parsed files directly into a single output file. This is particularly
useful if you wish to parse .proto files from programs written in languages
other than C++: just run protoc as a background process and have it output
a FileDescriptorList, then parse that natively.
* Improved error message when an enum value's name conflicts with another
symbol defined in the enum type's scope, e.g. if two enum types declared
in the same scope have values with the same name. This is disallowed for
compatibility with C++, but this wasn't clear from the error.
* Fixed absolute output paths on Windows.
* Fixed absolute output paths on Windows.
* Allow trailing slashes in --proto_path mappings.
C++
* Reflection objects are now per-class rather than per-instance. To make this
possible, the Reflection interface had to be changed such that all methods
take the Message instance as a parameter. This change improves performance
significantly in memory-bandwidth-limited use cases, since it makes the
message objects smaller. Note that source-incompatible interface changes
like this will not be made again after the library leaves beta.
C++
* Reflection objects are now per-class rather than per-instance. To make this
possible, the Reflection interface had to be changed such that all methods
take the Message instance as a parameter. This change improves performance
significantly in memory-bandwidth-limited use cases, since it makes the
message objects smaller. Note that source-incompatible interface changes
like this will not be made again after the library leaves beta.
* Heuristically detect sub-messages when printing unknown fields.
* Fix static initialization ordering bug that caused crashes at startup when
* Fix static initialization ordering bug that caused crashes at startup when
compiling on Mac with static linking.
* Fixed TokenizerTest when compiling with -DNDEBUG on Linux.
* Fixed incorrect definition of kint32min.
* Fixed TokenizerTest when compiling with -DNDEBUG on Linux.
* Fixed incorrect definition of kint32min.
* Fix bytes type setter to work with byte sequences with embedded NULLs.
* Other irrelevant tweaks.
Java
* Fixed UnknownFieldSet's parsing of varints larger than 32 bits.
* Fixed TextFormat's parsing of "inf" and "nan".
* Fixed TextFormat's parsing of comments.
* Added info to Java POM that will be required when we upload the
Java
* Fixed UnknownFieldSet's parsing of varints larger than 32 bits.
* Fixed TextFormat's parsing of "inf" and "nan".
* Fixed TextFormat's parsing of comments.
* Added info to Java POM that will be required when we upload the
package to a Maven repo.
Python
* MergeFrom(message) and CopyFrom(message) are now implemented.
* SerializeToString() raises an exception if the message is missing required
fields.
* Code organization improvements.
* Fixed doc comments for RpcController and RpcChannel, which had somehow been
Python
* MergeFrom(message) and CopyFrom(message) are now implemented.
* SerializeToString() raises an exception if the message is missing required
fields.
* Code organization improvements.
* Fixed doc comments for RpcController and RpcChannel, which had somehow been
swapped.
* Fixed text_format_test on Windows where floating-point exponents sometimes
contain extra zeros.
* Fixed text_format_test on Windows where floating-point exponents sometimes
contain extra zeros.
* Fix Python service CallMethod() implementation.
Other
......
......@@ -59,7 +59,8 @@ FileGenerator::FileGenerator(const FileDescriptor* file,
service_generators_(
new scoped_ptr<ServiceGenerator>[file->service_count()]),
extension_generators_(
new scoped_ptr<ExtensionGenerator>[file->extension_count()]) {
new scoped_ptr<ExtensionGenerator>[file->extension_count()]),
dllexport_decl_(dllexport_decl) {
for (int i = 0; i < file->message_type_count(); i++) {
message_generators_[i].reset(
......@@ -146,11 +147,13 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
// declare it to be a friend of each class.
printer->Print(
"\n"
"// Internal implementation detail -- do not call this.\n"
"// Internal implementation detail -- do not call these.\n"
"void $dllexport_decl$ $builddescriptorsname$();\n"
"void $builddescriptorsname$_AssignGlobalDescriptors(\n"
" ::google::protobuf::FileDescriptor* file);\n"
"\n",
"builddescriptorsname", GlobalBuildDescriptorsName(file_->name()));
"builddescriptorsname", GlobalBuildDescriptorsName(file_->name()),
"dllexport_decl", dllexport_decl_);
// Generate forward declarations of classes.
for (int i = 0; i < file_->message_type_count(); i++) {
......@@ -235,31 +238,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"#include <google/protobuf/wire_format_inl.h>\n",
"basename", StripProto(file_->name()));
// For each dependency, write a prototype for that dependency's
// BuildDescriptors() function. We don't expose these in the header because
// they are internal implementation details, and since this is generated code
// we don't have the usual risks involved with declaring external functions
// within a .cc file.
for (int i = 0; i < file_->dependency_count(); i++) {
const FileDescriptor* dependency = file_->dependency(i);
// Open the dependency's namespace.
vector<string> dependency_package_parts;
SplitStringUsing(dependency->package(), ".", &dependency_package_parts);
for (int i = 0; i < dependency_package_parts.size(); i++) {
printer->Print("namespace $name$ { ",
"name", dependency_package_parts[i]);
}
// Declare its BuildDescriptors() function.
printer->Print(
"void $function$();",
"function", GlobalBuildDescriptorsName(dependency->name()));
// Close the namespace.
for (int i = 0; i < dependency_package_parts.size(); i++) {
printer->Print(" }");
}
printer->Print("\n");
}
GenerateNamespaceOpeners(printer);
printer->Print(
......
......@@ -85,6 +85,8 @@ class FileGenerator {
// E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}.
vector<string> package_parts_;
string dllexport_decl_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
};
......
......@@ -25,7 +25,8 @@
namespace google {
namespace protobuf {
// Internal implementation detail -- do not call this.
// Internal implementation detail -- do not call these.
void LIBPROTOBUF_EXPORT protobuf_BuildDesc_google_2fprotobuf_2fdescriptor_2eproto();
void protobuf_BuildDesc_google_2fprotobuf_2fdescriptor_2eproto_AssignGlobalDescriptors(
::google::protobuf::FileDescriptor* file);
......
......@@ -56,7 +56,7 @@ using namespace std; // Don't do this at home, kids.
TypeName(const TypeName&); \
void operator=(const TypeName&)
#ifdef _MSC_VER
#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)
#ifdef LIBPROTOBUF_EXPORTS
#define LIBPROTOBUF_EXPORT __declspec(dllexport)
#else
......
......@@ -19,7 +19,7 @@
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
ConfigurationType="4"
>
<Tool
Name="VCPreBuildEventTool"
......@@ -60,18 +60,11 @@
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
......@@ -81,9 +74,6 @@
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
......@@ -92,7 +82,7 @@
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
ConfigurationType="4"
>
<Tool
Name="VCPreBuildEventTool"
......@@ -130,20 +120,11 @@
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
......@@ -153,9 +134,6 @@
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
......
......@@ -19,7 +19,7 @@
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
ConfigurationType="4"
>
<Tool
Name="VCPreBuildEventTool"
......@@ -60,18 +60,11 @@
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
......@@ -81,9 +74,6 @@
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
......@@ -92,7 +82,7 @@
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
ConfigurationType="4"
>
<Tool
Name="VCPreBuildEventTool"
......@@ -130,20 +120,11 @@
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
......@@ -153,9 +134,6 @@
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
......
......@@ -24,27 +24,37 @@ Compiling and Installing
build of libprotobuf.dll. Similarly, release builds must link against
release DLLs.
DLLs and Distribution
=====================
DLLs vs. static linking
=======================
Static linking is now the default for the Protocol Buffer libraries. Due to
issues with Win32's use of a separate heap for each DLL, as well as binary
compatibility issues between different versions of MSVC's STL library, it is
recommended that you use static linkage only. However, it is possible to
build libprotobuf and libprotoc as DLLs if you really want. To do this,
do the following:
1) Open protobuf.sln in MSVC.
2) For each of the projects libprotobuf and libprotoc, do the following:
2a) Right-click the project and choose "properties".
2b) From the side bar, choose "General", under "Configuration Properties".
2c) Change the "Configuration Type" to "Dynamic Library (.dll)".
2d) From the side bar, choose "Preprocessor", under "C/C++".
2e) Add PROTOBUF_USE_DLLS to the list of preprocessor defines.
3) When compiling your project, make sure to #define PROTOBUF_USE_DLLS.
When distributing your software to end users, we strongly recommend that you
do NOT install libprotobuf.dll or libprotoc.dll to any shared location.
Instead, keep these libraries next to your binaries, in your application's
own install directory. C++ makes it very difficult to maintain binary
compatibility between releases, so it is likely that future versions of these
libraries will *not* be usable as drop-in replacements. The only reason we
provide these libraries as DLLs rather than static libs is so that a program
which is itself split into multiple DLLs can safely pass protocol buffer
objects between them.
libraries will *not* be usable as drop-in replacements.
If your project is itself a DLL intended for use by third-party software, we
recommend that you do NOT expose protocol buffer objects in your library's
public interface, and that you statically link protocol buffers into your
library.
TODO(kenton): This sounds kind of scary. Maybe we should only provide static
libraries?
Notes on Compiler Warnings
==========================
......@@ -63,7 +73,8 @@ C4355 - 'this' : used in base member initializer list
C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
C4996 - 'function': was declared deprecated
C4251 is of particular note. The protocol buffer library uses templates in
C4251 is of particular note, if you are compiling the Protocol Buffer library
as a DLL (see previous section). The protocol buffer library uses templates in
its public interfaces. MSVC does not provide any reasonable way to export
template classes from a DLL. However, in practice, it appears that exporting
templates is not necessary anyway. Since the complete definition of any
......
......@@ -262,6 +262,10 @@
RelativePath=".\google\protobuf\unittest_embed_optimize_for.pb.h"
>
</File>
<File
RelativePath=".\google\protobuf\unittest_custom_options.pb.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
......@@ -406,6 +410,10 @@
RelativePath=".\google\protobuf\unittest_embed_optimize_for.pb.cc"
>
</File>
<File
RelativePath=".\google\protobuf\unittest_custom_options.pb.cc"
>
</File>
<File
RelativePath="..\src\google\protobuf\unknown_field_set_unittest.cc"
>
......@@ -563,6 +571,30 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\google\protobuf\unittest_custom_options.proto"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating unittest_custom_options.pb.{h,cc}..."
CommandLine="Debug\protoc -I../src --cpp_out=. ../src/google/protobuf/unittest_custom_options.proto&#x0D;&#x0A;"
Outputs="google\protobuf\unittest_custom_options.pb.h;google\protobuf\unittest_custom_options.pb.cc"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating unittest_custom_options.pb.{h,cc}..."
CommandLine="Release\protoc -I../src --cpp_out=. ../src/google/protobuf/unittest_custom_options.proto&#x0D;&#x0A;"
Outputs="google\protobuf\unittest_custom_options.pb.h;google\protobuf\unittest_custom_options.pb.cc"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment