Ver Fonte

thrift: fix download (#4038)

* thrift: fix download

* add qt5 config

* add patch
star9029 há 1 ano atrás
pai
commit
ab54b6fda1
2 ficheiros alterados com 119 adições e 22 exclusões
  1. 90 0
      packages/t/thrift/patches/0.16.0/cmake.patch
  2. 29 22
      packages/t/thrift/xmake.lua

+ 90 - 0
packages/t/thrift/patches/0.16.0/cmake.patch

@@ -0,0 +1,90 @@
+diff --git a/build/cmake/DefineInstallationPaths.cmake b/build/cmake/DefineInstallationPaths.cmake
+index 23962b442..0c824cc7a 100644
+--- a/build/cmake/DefineInstallationPaths.cmake
++++ b/build/cmake/DefineInstallationPaths.cmake
+@@ -20,11 +20,7 @@
+ 
+ # Define the default install paths
+ set(BIN_INSTALL_DIR "bin" CACHE PATH "The binary install dir (default: bin)")
+-if(MSVC)
+-    set(LIB_INSTALL_DIR "bin${LIB_SUFFIX}" CACHE PATH "The library install dir (default: bin${LIB_SUFFIX})")
+-else()
+-    set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
+-endif()
++set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
+ set(INCLUDE_INSTALL_DIR "include" CACHE PATH "The library install dir (default: include)")
+ set(CMAKE_INSTALL_DIR "lib/cmake" CACHE PATH "The subdirectory to install cmake config files (default: cmake)")
+ set(PKGCONFIG_INSTALL_DIR "lib/pkgconfig" CACHE PATH "The subdirectory to install pkgconfig config files (default: lib/pkgconfig)")
+diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
+index b59292cd3..23caa09fe 100644
+--- a/build/cmake/DefineOptions.cmake
++++ b/build/cmake/DefineOptions.cmake
+@@ -39,10 +39,7 @@ option(BUILD_LIBRARIES "Build Thrift libraries" ON)
+ # and enables the library if all are found. This means the default is to build as
+ # much as possible but leaving out libraries if their dependencies are not met.
+ 
+-if (NOT Boost_USE_STATIC_LIBS)
+-    add_definitions(-DBOOST_ALL_DYN_LINK)
+-    add_definitions(-DBOOST_TEST_DYN_LINK)
+-endif()
++
+ 
+ # as3
+ option(WITH_AS3 "Build ActionScript 3 Thrift Library" ON)
+diff --git a/lib/c_glib/CMakeLists.txt b/lib/c_glib/CMakeLists.txt
+index 35571233d..ac6fc1d52 100644
+--- a/lib/c_glib/CMakeLists.txt
++++ b/lib/c_glib/CMakeLists.txt
+@@ -71,7 +71,8 @@ set(thrift_c_glib_zlib_SOURCES
+ )
+ 
+ # If OpenSSL is not found just ignore the OpenSSL stuff
+-if(OPENSSL_FOUND AND WITH_OPENSSL)
++if(WITH_OPENSSL)
++    find_package(OpenSSL REQUIRED)
+     list(APPEND thrift_c_glib_SOURCES
+ 	    src/thrift/c_glib/transport/thrift_ssl_socket.c
+     )
+@@ -83,8 +84,7 @@ if(OPENSSL_FOUND AND WITH_OPENSSL)
+             list(APPEND SYSLIBS OpenSSL::Crypto)
+         endif()
+     else()
+-        include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
+-        list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
++        list(APPEND SYSLIBS OpenSSL::SSL OpenSSL::Crypto)
+     endif()
+ endif()
+ 
+diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
+index c2f15dd57..3f36a23c1 100644
+--- a/lib/cpp/CMakeLists.txt
++++ b/lib/cpp/CMakeLists.txt
+@@ -97,7 +97,8 @@ else()
+ endif()
+ 
+ # If OpenSSL is not found or disabled just ignore the OpenSSL stuff
+-if(OPENSSL_FOUND AND WITH_OPENSSL)
++if(WITH_OPENSSL)
++    find_package(OpenSSL REQUIRED)
+     list(APPEND thriftcpp_SOURCES
+        src/thrift/transport/TSSLSocket.cpp
+        src/thrift/transport/TSSLServerSocket.cpp
+@@ -112,8 +113,7 @@ if(OPENSSL_FOUND AND WITH_OPENSSL)
+             list(APPEND SYSLIBS OpenSSL::Crypto)
+         endif()
+     else()
+-        include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
+-        list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
++        list(APPEND SYSLIBS OpenSSL::SSL OpenSSL::Crypto)
+     endif()
+ endif()
+ 
+@@ -174,7 +174,7 @@ if(WITH_LIBEVENT)
+     target_link_libraries(thriftnb PUBLIC thrift)
+     if(TARGET libevent::core AND TARGET libevent::extra)
+         # libevent was found via its cmake config, use modern style targets
+-        target_link_libraries(thriftnb PUBLIC libevent::core libevent::extra)
++    target_link_libraries(thriftnb PUBLIC libevent::core libevent::extra)
+     else()
+         target_link_libraries(thriftnb PUBLIC ${LIBEVENT_LIBRARIES})
+     endif()

+ 29 - 22
packages/t/thrift/xmake.lua

@@ -1,14 +1,16 @@
 package("thrift")
-
     set_homepage("https://thrift.apache.org/")
     set_description("Thrift is a lightweight, language-independent software stack for point-to-point RPC implementation.")
     set_license("Apache-2.0")
 
-    add_urls("https://dlcdn.apache.org/thrift/0.16.0/thrift-0.16.0.tar.gz",  {version = function (version)
-        return version:gsub("v", "")
-    end})
-    add_urls("https://github.com/apache/thrift.git")
-    add_versions("v0.16.0", "f460b5c1ca30d8918ff95ea3eb6291b3951cf518553566088f3f2be8981f6209")
+    add_urls("https://github.com/apache/thrift/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/apache/thrift.git")
+
+    add_versions("v0.16.0", "df2931de646a366c2e5962af679018bca2395d586e00ba82d09c0379f14f8e7b")
+
+    add_patches(">=0.16.0", "patches/0.16.0/cmake.patch", "8dd82f54d52a37487e64aa3529f4dbcedcda671ab46fcb7a8c0f2c521ee0be9b")
+
+    add_configs("compiler", {description = "Build compiler", default = false, type = "boolean"})
 
     add_deps("cmake", "boost")
     if is_plat("windows") then
@@ -17,16 +19,20 @@ package("thrift")
         add_deps("flex", "bison")
     end
 
-    local configdeps = {glib = "glib", libevent = "libevent", ssl = "openssl", zlib = "zlib"}
-    for config, dep in pairs(configdeps) do
-        add_configs(config, {description = "Enable " .. config .. " support.", default = false, type = "boolean"})
+    local configdeps = {"glib", "libevent", "openssl", "zlib", "qt5"}
+    for _, dep in pairs(configdeps) do
+        add_configs(dep, {description = "Enable " .. dep .. " support.", default = false, type = "boolean"})
     end
 
     on_load(function (package)
-        for name, dep in pairs(configdeps) do
-            if package:config(name) then
-                if name == "libevent" and package:config("ssl") then
+        for _, dep in pairs(configdeps) do
+            if package:config(dep) then
+                if dep == "libevent" and package:config("openssl") then
                     package:add("deps", "libevent", {configs = {openssl = true}})
+                elseif dep == "openssl" then
+                    package:add("deps", "openssl3")
+                elseif dep == "qt5" then
+                    package:add("deps", "qt5core", "qt5network")
                 else
                     package:add("deps", dep)
                 end
@@ -34,13 +40,11 @@ package("thrift")
         end
     end)
 
-    on_install("linux", "macosx", "cross", function (package)
+    on_install("windows", "linux", "macosx", "cross", function (package)
         local configs = {
             "-DBUILD_TESTING=OFF",
-            "-DWITH_STDTHREADS=ON",
-            "-DBUILD_COMPILER=ON",
             "-DBUILD_TUTORIALS=OFF",
-            -- language support.
+
             "-DBUILD_CPP=ON",
             "-DBUILD_JAVA=OFF",
             "-DBUILD_JAVASCRIPT=OFF",
@@ -48,17 +52,20 @@ package("thrift")
             "-DBUILD_PYTHON=OFF",
         }
 
-        for config, dep in pairs(configdeps) do
-            -- Use WITH_OPENSSL instead of WITH_SSL, thus use dep:upper().
+        for _, dep in pairs(configdeps) do
             local feat = dep:upper()
-            if config == "glib" then
+            if dep == "glib" then
                 feat = "C_GLIB"
             end
-            table.insert(configs, "-DWITH_" .. feat .. "=" .. (package:config(config) and "ON" or "OFF"))
+            table.insert(configs, "-DWITH_" .. feat .. "=" .. (package:config(dep) and "ON" or "OFF"))
         end
 
-        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        table.insert(configs, "-DBUILD_COMPILER=" .. (package:config("compiler") and "ON" or "OFF"))
+        if package:is_plat("windows") then
+            table.insert(configs, "-DWITH_MT=" .. (package:has_runtime("MT") and "ON" or "OFF"))
+        end
         import("package.tools.cmake").install(package, configs)
     end)
 
@@ -67,5 +74,5 @@ package("thrift")
             apache::thrift::transport::TTransport* test() {
                 return new apache::thrift::transport::TSocket("localhost", 9090);
             }
-        ]]}, {configs = {languages = "c++11"}, includes="thrift/transport/TSocket.h"}))
+        ]]}, {configs = {languages = "c++11"}, includes = "thrift/transport/TSocket.h"}))
     end)