Skip to content

Commit ab54b6f

Browse files
thrift: fix download (#4038)
* thrift: fix download * add qt5 config * add patch
1 parent 150c3a3 commit ab54b6f

File tree

2 files changed

+119
-22
lines changed

2 files changed

+119
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
diff --git a/build/cmake/DefineInstallationPaths.cmake b/build/cmake/DefineInstallationPaths.cmake
2+
index 23962b442..0c824cc7a 100644
3+
--- a/build/cmake/DefineInstallationPaths.cmake
4+
+++ b/build/cmake/DefineInstallationPaths.cmake
5+
@@ -20,11 +20,7 @@
6+
7+
# Define the default install paths
8+
set(BIN_INSTALL_DIR "bin" CACHE PATH "The binary install dir (default: bin)")
9+
-if(MSVC)
10+
- set(LIB_INSTALL_DIR "bin${LIB_SUFFIX}" CACHE PATH "The library install dir (default: bin${LIB_SUFFIX})")
11+
-else()
12+
- set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
13+
-endif()
14+
+set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
15+
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "The library install dir (default: include)")
16+
set(CMAKE_INSTALL_DIR "lib/cmake" CACHE PATH "The subdirectory to install cmake config files (default: cmake)")
17+
set(PKGCONFIG_INSTALL_DIR "lib/pkgconfig" CACHE PATH "The subdirectory to install pkgconfig config files (default: lib/pkgconfig)")
18+
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
19+
index b59292cd3..23caa09fe 100644
20+
--- a/build/cmake/DefineOptions.cmake
21+
+++ b/build/cmake/DefineOptions.cmake
22+
@@ -39,10 +39,7 @@ option(BUILD_LIBRARIES "Build Thrift libraries" ON)
23+
# and enables the library if all are found. This means the default is to build as
24+
# much as possible but leaving out libraries if their dependencies are not met.
25+
26+
-if (NOT Boost_USE_STATIC_LIBS)
27+
- add_definitions(-DBOOST_ALL_DYN_LINK)
28+
- add_definitions(-DBOOST_TEST_DYN_LINK)
29+
-endif()
30+
+
31+
32+
# as3
33+
option(WITH_AS3 "Build ActionScript 3 Thrift Library" ON)
34+
diff --git a/lib/c_glib/CMakeLists.txt b/lib/c_glib/CMakeLists.txt
35+
index 35571233d..ac6fc1d52 100644
36+
--- a/lib/c_glib/CMakeLists.txt
37+
+++ b/lib/c_glib/CMakeLists.txt
38+
@@ -71,7 +71,8 @@ set(thrift_c_glib_zlib_SOURCES
39+
)
40+
41+
# If OpenSSL is not found just ignore the OpenSSL stuff
42+
-if(OPENSSL_FOUND AND WITH_OPENSSL)
43+
+if(WITH_OPENSSL)
44+
+ find_package(OpenSSL REQUIRED)
45+
list(APPEND thrift_c_glib_SOURCES
46+
src/thrift/c_glib/transport/thrift_ssl_socket.c
47+
)
48+
@@ -83,8 +84,7 @@ if(OPENSSL_FOUND AND WITH_OPENSSL)
49+
list(APPEND SYSLIBS OpenSSL::Crypto)
50+
endif()
51+
else()
52+
- include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
53+
- list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
54+
+ list(APPEND SYSLIBS OpenSSL::SSL OpenSSL::Crypto)
55+
endif()
56+
endif()
57+
58+
diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
59+
index c2f15dd57..3f36a23c1 100644
60+
--- a/lib/cpp/CMakeLists.txt
61+
+++ b/lib/cpp/CMakeLists.txt
62+
@@ -97,7 +97,8 @@ else()
63+
endif()
64+
65+
# If OpenSSL is not found or disabled just ignore the OpenSSL stuff
66+
-if(OPENSSL_FOUND AND WITH_OPENSSL)
67+
+if(WITH_OPENSSL)
68+
+ find_package(OpenSSL REQUIRED)
69+
list(APPEND thriftcpp_SOURCES
70+
src/thrift/transport/TSSLSocket.cpp
71+
src/thrift/transport/TSSLServerSocket.cpp
72+
@@ -112,8 +113,7 @@ if(OPENSSL_FOUND AND WITH_OPENSSL)
73+
list(APPEND SYSLIBS OpenSSL::Crypto)
74+
endif()
75+
else()
76+
- include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
77+
- list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
78+
+ list(APPEND SYSLIBS OpenSSL::SSL OpenSSL::Crypto)
79+
endif()
80+
endif()
81+
82+
@@ -174,7 +174,7 @@ if(WITH_LIBEVENT)
83+
target_link_libraries(thriftnb PUBLIC thrift)
84+
if(TARGET libevent::core AND TARGET libevent::extra)
85+
# libevent was found via its cmake config, use modern style targets
86+
- target_link_libraries(thriftnb PUBLIC libevent::core libevent::extra)
87+
+ target_link_libraries(thriftnb PUBLIC libevent::core libevent::extra)
88+
else()
89+
target_link_libraries(thriftnb PUBLIC ${LIBEVENT_LIBRARIES})
90+
endif()

packages/t/thrift/xmake.lua

+29-22
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package("thrift")
2-
32
set_homepage("https://thrift.apache.org/")
43
set_description("Thrift is a lightweight, language-independent software stack for point-to-point RPC implementation.")
54
set_license("Apache-2.0")
65

7-
add_urls("https://dlcdn.apache.org/thrift/0.16.0/thrift-0.16.0.tar.gz", {version = function (version)
8-
return version:gsub("v", "")
9-
end})
10-
add_urls("https://github.com/apache/thrift.git")
11-
add_versions("v0.16.0", "f460b5c1ca30d8918ff95ea3eb6291b3951cf518553566088f3f2be8981f6209")
6+
add_urls("https://github.com/apache/thrift/archive/refs/tags/$(version).tar.gz",
7+
"https://github.com/apache/thrift.git")
8+
9+
add_versions("v0.16.0", "df2931de646a366c2e5962af679018bca2395d586e00ba82d09c0379f14f8e7b")
10+
11+
add_patches(">=0.16.0", "patches/0.16.0/cmake.patch", "8dd82f54d52a37487e64aa3529f4dbcedcda671ab46fcb7a8c0f2c521ee0be9b")
12+
13+
add_configs("compiler", {description = "Build compiler", default = false, type = "boolean"})
1214

1315
add_deps("cmake", "boost")
1416
if is_plat("windows") then
@@ -17,48 +19,53 @@ package("thrift")
1719
add_deps("flex", "bison")
1820
end
1921

20-
local configdeps = {glib = "glib", libevent = "libevent", ssl = "openssl", zlib = "zlib"}
21-
for config, dep in pairs(configdeps) do
22-
add_configs(config, {description = "Enable " .. config .. " support.", default = false, type = "boolean"})
22+
local configdeps = {"glib", "libevent", "openssl", "zlib", "qt5"}
23+
for _, dep in pairs(configdeps) do
24+
add_configs(dep, {description = "Enable " .. dep .. " support.", default = false, type = "boolean"})
2325
end
2426

2527
on_load(function (package)
26-
for name, dep in pairs(configdeps) do
27-
if package:config(name) then
28-
if name == "libevent" and package:config("ssl") then
28+
for _, dep in pairs(configdeps) do
29+
if package:config(dep) then
30+
if dep == "libevent" and package:config("openssl") then
2931
package:add("deps", "libevent", {configs = {openssl = true}})
32+
elseif dep == "openssl" then
33+
package:add("deps", "openssl3")
34+
elseif dep == "qt5" then
35+
package:add("deps", "qt5core", "qt5network")
3036
else
3137
package:add("deps", dep)
3238
end
3339
end
3440
end
3541
end)
3642

37-
on_install("linux", "macosx", "cross", function (package)
43+
on_install("windows", "linux", "macosx", "cross", function (package)
3844
local configs = {
3945
"-DBUILD_TESTING=OFF",
40-
"-DWITH_STDTHREADS=ON",
41-
"-DBUILD_COMPILER=ON",
4246
"-DBUILD_TUTORIALS=OFF",
43-
-- language support.
47+
4448
"-DBUILD_CPP=ON",
4549
"-DBUILD_JAVA=OFF",
4650
"-DBUILD_JAVASCRIPT=OFF",
4751
"-DBUILD_NODEJS=OFF",
4852
"-DBUILD_PYTHON=OFF",
4953
}
5054

51-
for config, dep in pairs(configdeps) do
52-
-- Use WITH_OPENSSL instead of WITH_SSL, thus use dep:upper().
55+
for _, dep in pairs(configdeps) do
5356
local feat = dep:upper()
54-
if config == "glib" then
57+
if dep == "glib" then
5558
feat = "C_GLIB"
5659
end
57-
table.insert(configs, "-DWITH_" .. feat .. "=" .. (package:config(config) and "ON" or "OFF"))
60+
table.insert(configs, "-DWITH_" .. feat .. "=" .. (package:config(dep) and "ON" or "OFF"))
5861
end
5962

60-
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
63+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
6164
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
65+
table.insert(configs, "-DBUILD_COMPILER=" .. (package:config("compiler") and "ON" or "OFF"))
66+
if package:is_plat("windows") then
67+
table.insert(configs, "-DWITH_MT=" .. (package:has_runtime("MT") and "ON" or "OFF"))
68+
end
6269
import("package.tools.cmake").install(package, configs)
6370
end)
6471

@@ -67,5 +74,5 @@ package("thrift")
6774
apache::thrift::transport::TTransport* test() {
6875
return new apache::thrift::transport::TSocket("localhost", 9090);
6976
}
70-
]]}, {configs = {languages = "c++11"}, includes="thrift/transport/TSocket.h"}))
77+
]]}, {configs = {languages = "c++11"}, includes = "thrift/transport/TSocket.h"}))
7178
end)

0 commit comments

Comments
 (0)