Przeglądaj źródła

protobuf-cpp: Fix Windows build for versions <= 3.19.4 (#5955)

* protobuf-cpp: fix port_def.inc modification for versions <= 3.19.4

* protobuf-cpp: use recommended API to retrieve runtimes
Doekin 8 miesięcy temu
rodzic
commit
117ffb8a6c
1 zmienionych plików z 5 dodań i 4 usunięć
  1. 5 4
      packages/p/protobuf-cpp/xmake.lua

+ 5 - 4
packages/p/protobuf-cpp/xmake.lua

@@ -128,6 +128,10 @@ package("protobuf-cpp")
     end)
 
     on_install(function (package)
+        if package:is_plat("windows", "mingw") then
+            io.replace("src/google/protobuf/port_def.inc", "#define PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED", "", {plain = true})
+        end
+
         local version = package:version()
         if version:le("3.19.4") then
             os.cd("cmake")
@@ -138,9 +142,6 @@ package("protobuf-cpp")
         if version:ge("26.1") then
             io.replace("cmake/abseil-cpp.cmake", "BUILD_SHARED_LIBS AND MSVC", "FALSE", {plain = true})
         end
-        if package:is_plat("windows", "mingw") then
-            io.replace("src/google/protobuf/port_def.inc", "#define PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED", "", {plain = true})
-        end
 
         local configs = {
             "-Dprotobuf_BUILD_TESTS=OFF",
@@ -153,7 +154,7 @@ package("protobuf-cpp")
         table.insert(configs, "-Dprotobuf_DISABLE_RTTI=" .. (package:config("rtti") and "OFF" or "ON"))
         if package:is_plat("windows") then
             table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
-            table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+            table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:has_runtime("MT", "MTd") and "ON" or "OFF"))
         end
 
         table.insert(configs, "-Dprotobuf_WITH_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))