diff options
author | cyy <cyyever@outlook.com> | 2019-02-05 02:57:21 +0800 |
---|---|---|
committer | James E. King III <jking@apache.org> | 2019-02-04 13:57:21 -0500 |
commit | 8fdb7587e688ae66a0e30e9f22bf8dc09599b2e9 (patch) | |
tree | 5bdd27f74952a29c402c47d3c4946d8fcf38f67d | |
parent | 71afec0ea3fc700d5f0d1c46512723963bf1e2f7 (diff) | |
download | thrift-8fdb7587e688ae66a0e30e9f22bf8dc09599b2e9.tar.gz |
THRIFT-4759:add thrift export to fix windows shared lib building (#1714)
* add THRIFT_EXPORT to fix windows shared lib building
* use shared libraries on vs2017 appveyor build, leave msvc2017 static link
-rwxr-xr-x | appveyor.yml | 2 | ||||
-rwxr-xr-x | lib/cpp/CMakeLists.txt | 4 | ||||
-rwxr-xr-x | lib/cpp/Makefile.am | 1 | ||||
-rw-r--r-- | lib/cpp/src/thrift/TOutput.cpp | 2 | ||||
-rw-r--r-- | lib/cpp/src/thrift/TOutput.h | 4 | ||||
-rw-r--r-- | lib/cpp/src/thrift/thrift_export.h | 20 | ||||
-rw-r--r-- | lib/cpp/src/thrift/transport/TSSLServerSocket.cpp | 1 | ||||
-rw-r--r-- | lib/cpp/src/thrift/transport/TSSLSocket.h | 2 |
8 files changed, 32 insertions, 4 deletions
diff --git a/appveyor.yml b/appveyor.yml index 39aba4f95..74c92f1fa 100755 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,7 +39,7 @@ environment: - PROFILE: MSVC2017 PLATFORM: x64 CONFIGURATION: Release - BUILD_SHARED_LIBS: OFF + BUILD_SHARED_LIBS: ON BOOST_VERSION: 1.67.0 LIBEVENT_VERSION: 2.1.8 PYTHON_VERSION: 3.6 diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index dd90c808b..e92da606b 100755 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -23,6 +23,10 @@ REQUIRE_BOOST_HEADERS() include_directories(src) +if(NOT BUILD_SHARED_LIBS) + add_definitions("-DTHRIFT_STATIC_DEFINE") +endif() + # SYSLIBS contains libraries that need to be linked to all lib targets set(SYSLIBS "") diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am index 616effddd..114ff1767 100755 --- a/lib/cpp/Makefile.am +++ b/lib/cpp/Makefile.am @@ -132,6 +132,7 @@ include_thriftdir = $(includedir)/thrift include_thrift_HEADERS = \ $(top_builddir)/config.h \ src/thrift/thrift-config.h \ + src/thrift/thrift_export.h \ src/thrift/TDispatchProcessor.h \ src/thrift/Thrift.h \ src/thrift/TOutput.h \ diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp index f25b56653..8d163a941 100644 --- a/lib/cpp/src/thrift/TOutput.cpp +++ b/lib/cpp/src/thrift/TOutput.cpp @@ -27,7 +27,7 @@ namespace apache { namespace thrift { -TOutput GlobalOutput; +THRIFT_EXPORT TOutput GlobalOutput; TOutput::TOutput() : f_(&errorTimeWrapper) {} diff --git a/lib/cpp/src/thrift/TOutput.h b/lib/cpp/src/thrift/TOutput.h index 6135cfa15..26c9a563a 100644 --- a/lib/cpp/src/thrift/TOutput.h +++ b/lib/cpp/src/thrift/TOutput.h @@ -20,6 +20,8 @@ #ifndef _THRIFT_OUTPUT_H_ #define _THRIFT_OUTPUT_H_ 1 +#include <thrift/thrift_export.h> + namespace apache { namespace thrift { @@ -51,7 +53,7 @@ private: void (*f_)(const char*); }; -extern TOutput GlobalOutput; +THRIFT_EXPORT extern TOutput GlobalOutput; } } // namespace apache::thrift diff --git a/lib/cpp/src/thrift/thrift_export.h b/lib/cpp/src/thrift/thrift_export.h new file mode 100644 index 000000000..f5c059fb7 --- /dev/null +++ b/lib/cpp/src/thrift/thrift_export.h @@ -0,0 +1,20 @@ +#ifndef THRIFT_EXPORT_H +#define THRIFT_EXPORT_H + +#ifdef THRIFT_STATIC_DEFINE +# define THRIFT_EXPORT +#elif defined(_MSC_VER ) +# ifndef THRIFT_EXPORT +# ifdef thrift_EXPORTS + /* We are building this library */ +# define THRIFT_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define THRIFT_EXPORT __declspec(dllimport) +# endif +# endif +#else +# define THRIFT_EXPORT +#endif + +#endif /* THRIFT_EXPORT_H */ diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp index 34605c09f..b20c17408 100644 --- a/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.cpp @@ -17,6 +17,7 @@ * under the License. */ +#include <thrift/thrift_export.h> #include <thrift/transport/TSSLServerSocket.h> #include <thrift/transport/TSSLSocket.h> diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.h b/lib/cpp/src/thrift/transport/TSSLSocket.h index 8f095dc8c..4d46998c4 100644 --- a/lib/cpp/src/thrift/transport/TSSLSocket.h +++ b/lib/cpp/src/thrift/transport/TSSLSocket.h @@ -321,7 +321,7 @@ private: std::shared_ptr<AccessManager> access_; static concurrency::Mutex mutex_; static uint64_t count_; - static bool manualOpenSSLInitialization_; + THRIFT_EXPORT static bool manualOpenSSLInitialization_; void setup(std::shared_ptr<TSSLSocket> ssl); static int passwordCallback(char* password, int size, int, void* data); }; |