Build DLLs on Cygwin and MinGW.

This commit is contained in:
kenton@google.com 2009-12-22 02:05:33 +00:00
parent 94fd2ad771
commit c0ee4d2ed9
3 changed files with 42 additions and 8 deletions

View File

@ -30,6 +30,8 @@
UTF-8 bytes.
* Compiled-in message types can now contain dynamic extensions, through use
of CodedInputStream::SetExtensionRegistry().
* Now compiles shared libraries (DLLs) by default on Cygwin and MinGW, to
match other platforms. Use --disable-shared to avoid this.
Java
* parseDelimitedFrom() and mergeDelimitedFrom() now detect EOF and return

View File

@ -76,7 +76,7 @@ nobase_include_HEADERS = \
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
libprotobuf_lite_la_LDFLAGS = -version-info 6:0:0
libprotobuf_lite_la_LDFLAGS = -version-info 6:0:0 -export-dynamic -no-undefined
libprotobuf_lite_la_SOURCES = \
google/protobuf/stubs/common.cc \
google/protobuf/stubs/once.cc \
@ -95,7 +95,7 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/io/zero_copy_stream_impl_lite.cc
libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
libprotobuf_la_LDFLAGS = -version-info 6:0:0
libprotobuf_la_LDFLAGS = -version-info 6:0:0 -export-dynamic -no-undefined
libprotobuf_la_SOURCES = \
$(libprotobuf_lite_la_SOURCES) \
google/protobuf/stubs/strutil.cc \
@ -123,7 +123,7 @@ libprotobuf_la_SOURCES = \
google/protobuf/compiler/parser.cc
libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
libprotoc_la_LDFLAGS = -version-info 6:0:0
libprotoc_la_LDFLAGS = -version-info 6:0:0 -export-dynamic -no-undefined
libprotoc_la_SOURCES = \
google/protobuf/compiler/code_generator.cc \
google/protobuf/compiler/command_line_interface.cc \

View File

@ -68,6 +68,9 @@ namespace compiler {
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef F_OK
#define F_OK 00 // not defined by MSVC for whatever reason
#endif
#endif
namespace {
@ -248,11 +251,40 @@ void CommandLineInterfaceTest::Run(const string& command) {
if (!disallow_plugins_) {
cli_.AllowPlugins("prefix-");
#ifdef _WIN32
args.push_back("--plugin=prefix-gen-plug=test_plugin.exe");
#else
args.push_back("--plugin=prefix-gen-plug=test_plugin");
#endif
const char* possible_paths[] = {
// When building with shared libraries, libtool hides the real executable
// in .libs and puts a fake wrapper in the current directory.
// Unfortunately, due to an apparent bug on Cygwin/MinGW, if one program
// wrapped in this way (e.g. protobuf-tests.exe) tries to execute another
// program wrapped in this way (e.g. test_plugin.exe), the latter fails
// with error code 127 and no explanation message. Presumably the problem
// is that the wrapper for protobuf-tests.exe set some environment
// variables that confuse the wrapper for test_plugin.exe. Luckily, it
// turns out that if we simply invoke the wrapped test_plugin.exe
// directly, it works -- I guess the environment variables set by the
// protobuf-tests.exe wrapper happen to be correct for it too. So we do
// that.
".libs/test_plugin.exe", // Win32 w/autotool (Cygwin / MinGW)
"test_plugin.exe", // Other Win32 (MSVC)
"test_plugin", // Unix
};
string plugin_path;
for (int i = 0; i < GOOGLE_ARRAYSIZE(possible_paths); i++) {
if (access(possible_paths[i], F_OK) == 0) {
plugin_path = possible_paths[i];
break;
}
}
if (plugin_path.empty()) {
GOOGLE_LOG(ERROR)
<< "Plugin executable not found. Plugin tests are likely to fail.";
} else {
args.push_back("--plugin=prefix-gen-plug=" + plugin_path);
}
}
scoped_array<const char*> argv(new const char*[args.size()]);