From c02cb5c1abb4006cd5dd32ada89fab0ae5c06bdb Mon Sep 17 00:00:00 2001 From: Maarten Pronk Date: Mon, 5 Sep 2022 11:34:29 +0200 Subject: [PATCH] [Thrift] Build thrift library with cmake. (#5427) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Build thrift library with cmake. * Add Thrift as new package. * Revert ThriftJuliaCompiler. * Name package Thrift. * Build dir outside of src dir. * Apply patch for Windows. * Disable tutorials and add another patch. * Also lowercase . * Patch FreeBSD and fix patches. * Build under src dir. * More case-sensitive fixes. * Another patch update... * More case-sensitive fixes. * Fix double patch. Exclude Delphi compiler, it uses unsupported codecvt on win-cxx03. * Update T/Thrift/build_tarballs.jl Co-authored-by: Mosè Giordano Co-authored-by: Mosè Giordano --- T/Thrift/build_tarballs.jl | 60 ++++++ T/Thrift/bundled/patches/freebsd.patch | 15 ++ .../patches/include_case_sensitive.patch | 184 ++++++++++++++++++ 3 files changed, 259 insertions(+) create mode 100644 T/Thrift/build_tarballs.jl create mode 100644 T/Thrift/bundled/patches/freebsd.patch create mode 100644 T/Thrift/bundled/patches/include_case_sensitive.patch diff --git a/T/Thrift/build_tarballs.jl b/T/Thrift/build_tarballs.jl new file mode 100644 index 00000000000..31659b765c5 --- /dev/null +++ b/T/Thrift/build_tarballs.jl @@ -0,0 +1,60 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder, Pkg + +name = "Thrift" +version = v"0.16.0" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/apache/thrift.git", "2a93df80f27739ccabb5b885cb12a8dc7595ecdf") + DirectorySource("./bundled") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/thrift + +# Needed as https://github.com/apache/thrift/pull/2518 isn't released yet +for f in ${WORKSPACE}/srcdir/patches/*.patch; do + atomic_patch -p1 ${f} +done + +mkdir build_dir && cd build_dir + +CMAKE_FLAGS=(-DCMAKE_INSTALL_PREFIX=$prefix +-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} +-DCMAKE_BUILD_TYPE=Release +-DBUILD_COMPILER=ON +-DBUILD_CPP=ON +-DBUILD_PYTHON=OFF +-DBUILD_TESTING=OFF +-DBUILD_JAVASCRIPT=OFF +-DBUILD_NODEJS=OFF +-DWITH_SHARED_LIB=ON +-DBUILD_TUTORIALS=OFF +-DTHRIFT_COMPILER_DELPHI=OFF) + +cmake .. "${CMAKE_FLAGS[@]}" + +make -j${nproc} +make install +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = expand_cxxstring_abis(supported_platforms()) + +# The products that we will ensure are always built +products = [ + ExecutableProduct("thrift", :thrift) + LibraryProduct("libthrift", :libthrift) +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + Dependency("boost_jll", compat="=1.76.0") +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/T/Thrift/bundled/patches/freebsd.patch b/T/Thrift/bundled/patches/freebsd.patch new file mode 100644 index 00000000000..1d6a9f94625 --- /dev/null +++ b/T/Thrift/bundled/patches/freebsd.patch @@ -0,0 +1,15 @@ +diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp +index 9991fd6bd..e46daeba8 100644 +--- a/lib/cpp/src/thrift/transport/TSocket.cpp ++++ b/lib/cpp/src/thrift/transport/TSocket.cpp +@@ -432,6 +432,10 @@ void TSocket::local_open() { + TWinsockSingleton::create(); + #endif // _WIN32 + ++#if __FreeBSD__ ++ #define EAI_NODATA EAI_NONAME ++#endif // __FreeBSD__ ++ + if (isOpen()) { + return; + } diff --git a/T/Thrift/bundled/patches/include_case_sensitive.patch b/T/Thrift/bundled/patches/include_case_sensitive.patch new file mode 100644 index 00000000000..37b98246500 --- /dev/null +++ b/T/Thrift/bundled/patches/include_case_sensitive.patch @@ -0,0 +1,184 @@ +diff --git a/compiler/cpp/tests/catch/catch.hpp b/compiler/cpp/tests/catch/catch.hpp +index 33d037e55..1744c742d 100644 +--- a/compiler/cpp/tests/catch/catch.hpp ++++ b/compiler/cpp/tests/catch/catch.hpp +@@ -6338,7 +6338,7 @@ namespace Catch { + #endif + + #ifdef __AFXDLL +-#include ++#include + #else + #include + #endif +diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h +index 867ceb079..b691c4169 100644 +--- a/lib/cpp/src/thrift/protocol/TProtocol.h ++++ b/lib/cpp/src/thrift/protocol/TProtocol.h +@@ -22,7 +22,7 @@ + + #ifdef _WIN32 + // Need to come before any Windows.h includes +-#include ++#include + #endif + + #include +diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp +index 91a1c39af..6fc281674 100644 +--- a/lib/cpp/src/thrift/transport/THttpServer.cpp ++++ b/lib/cpp/src/thrift/transport/THttpServer.cpp +@@ -25,7 +25,7 @@ + #include + #include + #if defined(_MSC_VER) || defined(__MINGW32__) +- #include ++ #include + #endif + + using std::string; +diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp +index e4234b180..fd1aeee95 100644 +--- a/lib/cpp/src/thrift/transport/TPipeServer.cpp ++++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp +@@ -27,8 +27,8 @@ + #ifdef _WIN32 + #include + #include +-#include +-#include ++#include ++#include + #include + #endif //_WIN32 + +diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp +index 25ec789e0..8dda1072b 100644 +--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp ++++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp +@@ -70,7 +70,7 @@ + // adds problematic macros like min() and max(). Try to work around: + #define NOMINMAX + #define WIN32_LEAN_AND_MEAN +-#include ++#include + #undef NOMINMAX + #undef WIN32_LEAN_AND_MEAN + #endif +diff --git a/lib/cpp/src/thrift/transport/TWebSocketServer.h b/lib/cpp/src/thrift/transport/TWebSocketServer.h +index 7f39f36b9..2a3e076cf 100644 +--- a/lib/cpp/src/thrift/transport/TWebSocketServer.h ++++ b/lib/cpp/src/thrift/transport/TWebSocketServer.h +@@ -31,7 +31,7 @@ + #include + #include + #if defined(_MSC_VER) || defined(__MINGW32__) +-#include ++#include + #define THRIFT_strncasecmp(str1, str2, len) _strnicmp(str1, str2, len) + #define THRIFT_strcasestr(haystack, needle) StrStrIA(haystack, needle) + #else +diff --git a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp +index ac24124b3..d3696053b 100644 +--- a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp ++++ b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp +@@ -38,7 +38,7 @@ int thrift_gettimeofday(struct timeval* tv, struct timezone* tz) { + } + #else + #define WIN32_LEAN_AND_MEAN +-#include ++#include + #include + #include + #include +diff --git a/lib/cpp/src/thrift/windows/SocketPair.cpp b/lib/cpp/src/thrift/windows/SocketPair.cpp +index 2650b37d4..9271b0294 100644 +--- a/lib/cpp/src/thrift/windows/SocketPair.cpp ++++ b/lib/cpp/src/thrift/windows/SocketPair.cpp +@@ -34,7 +34,7 @@ + #include + + // Win32 +-#include ++#include + + int thrift_socketpair(int d, int type, int protocol, THRIFT_SOCKET sv[2]) { + THRIFT_UNUSED_VARIABLE(protocol); +diff --git a/lib/cpp/src/thrift/windows/SocketPair.h b/lib/cpp/src/thrift/windows/SocketPair.h +index 86bf43150..74b65dfaa 100644 +--- a/lib/cpp/src/thrift/windows/SocketPair.h ++++ b/lib/cpp/src/thrift/windows/SocketPair.h +@@ -29,7 +29,7 @@ + #endif + + // Win32 +-#include ++#include + #include + + int thrift_socketpair(int d, int type, int protocol, THRIFT_SOCKET sv[2]); +diff --git a/lib/cpp/src/thrift/windows/Sync.h b/lib/cpp/src/thrift/windows/Sync.h +index f5b8a052d..df93e7436 100644 +--- a/lib/cpp/src/thrift/windows/Sync.h ++++ b/lib/cpp/src/thrift/windows/Sync.h +@@ -31,7 +31,7 @@ + // adds problematic macros like min() and max(). Try to work around: + #define NOMINMAX + #define WIN32_LEAN_AND_MEAN +-#include ++#include + #undef NOMINMAX + #undef WIN32_LEAN_AND_MEAN + +diff --git a/lib/cpp/src/thrift/windows/WinFcntl.h b/lib/cpp/src/thrift/windows/WinFcntl.h +index 4816fc5ec..39e5efd13 100644 +--- a/lib/cpp/src/thrift/windows/WinFcntl.h ++++ b/lib/cpp/src/thrift/windows/WinFcntl.h +@@ -33,7 +33,7 @@ + #endif + + // Win32 +-#include ++#include + #include + + extern "C" { +diff --git a/lib/cpp/src/thrift/windows/config.h b/lib/cpp/src/thrift/windows/config.h +index ce10c5524..19296d63f 100644 +--- a/lib/cpp/src/thrift/windows/config.h ++++ b/lib/cpp/src/thrift/windows/config.h +@@ -57,7 +57,7 @@ + #include + + // windows +-#include ++#include + #include + + #ifndef __MINGW32__ +diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp +index 935a20514..bf6c15369 100644 +--- a/lib/cpp/test/OpenSSLManualInitTest.cpp ++++ b/lib/cpp/test/OpenSSLManualInitTest.cpp +@@ -21,7 +21,7 @@ + // which will cause the test to fail + #define MANUAL_OPENSSL_INIT 1 + #ifdef _WIN32 +-#include ++#include + #endif + + #include +diff --git a/lib/py/src/ext/endian.h b/lib/py/src/ext/endian.h +index 1660cbd98..a2cf594ed 100644 +--- a/lib/py/src/ext/endian.h ++++ b/lib/py/src/ext/endian.h +@@ -25,7 +25,7 @@ + #ifndef _WIN32 + #include + #else +-#include ++#include + #pragma comment(lib, "ws2_32.lib") + #define BIG_ENDIAN (4321) + #define LITTLE_ENDIAN (1234)