aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2008-09-30 00:09:40 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2008-09-30 00:09:40 +0000
commit9b10f5845aabc791e2fef0e5a11656ca01cd7813 (patch)
tree63fdebf8dd5893de95d6470d000cd60e3a1a3c9c /src/google/protobuf
parent0b3023fa6561f3b5abe43ac9e20d0ede43a56737 (diff)
* Fix build on MSVC.
* Switch to statically-linked libraries instead of DLLs on MSVC.
Diffstat (limited to 'src/google/protobuf')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.cc34
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.h2
-rw-r--r--src/google/protobuf/descriptor.pb.h3
-rw-r--r--src/google/protobuf/stubs/common.h2
4 files changed, 11 insertions, 30 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index 70b434dd..6487979f 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -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(
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h
index fc3d98cf..b4e01285 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -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);
};
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h
index 420f178d..4bc315e2 100644
--- a/src/google/protobuf/descriptor.pb.h
+++ b/src/google/protobuf/descriptor.pb.h
@@ -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);
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index 3744a585..9309b6be 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -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