Browse Source

Auto-update onnx to v1.16.0 (#3649)

* Update onnx to v1.16.0

* use c++17

* Update xmake.lua

* patch cmake abseil

* Update xmake.lua

---------

Co-authored-by: star9029 <[email protected]>
ruki 1 year ago
parent
commit
a4044ffedc

+ 29 - 0
packages/o/onnx/patches/1.16.0/cmake-abseil.patch

@@ -0,0 +1,29 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6d7ca846..ccf65e10 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -509,13 +509,13 @@ if(ONNX_USE_LITE_PROTO)
+   if(TARGET protobuf::libprotobuf-lite)
+     target_link_libraries(onnx_proto PUBLIC protobuf::libprotobuf-lite PRIVATE ${protobuf_ABSL_USED_TARGETS})
+   else()
+-    target_link_libraries(onnx_proto PUBLIC ${PROTOBUF_LITE_LIBRARIES})
++    target_link_libraries(onnx_proto PUBLIC ${PROTOBUF_LITE_LIBRARIES} ${protobuf_ABSL_USED_TARGETS})
+   endif()
+ else()
+   if(TARGET protobuf::libprotobuf)
+     target_link_libraries(onnx_proto PUBLIC protobuf::libprotobuf PRIVATE ${protobuf_ABSL_USED_TARGETS})
+   else()
+-    target_link_libraries(onnx_proto PUBLIC ${PROTOBUF_LIBRARIES})
++    target_link_libraries(onnx_proto PUBLIC ${PROTOBUF_LIBRARIES} ${protobuf_ABSL_USED_TARGETS})
+   endif()
+ endif()
+ add_onnx_global_defines(onnx_proto)
+@@ -532,7 +532,7 @@ target_include_directories(onnx PUBLIC
+   $<BUILD_INTERFACE:${ONNX_ROOT}>
+   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+   $<INSTALL_INTERFACE:include>)
+-target_link_libraries(onnx PUBLIC onnx_proto)
++target_link_libraries(onnx PUBLIC onnx_proto ${protobuf_ABSL_USED_TARGETS})
+ add_onnx_global_defines(onnx)
+ 
+ if(BUILD_ONNX_PYTHON)

+ 14 - 2
packages/o/onnx/xmake.lua

@@ -5,10 +5,17 @@ package("onnx")
 
     add_urls("https://github.com/onnx/onnx/archive/refs/tags/$(version).tar.gz",
              "https://github.com/onnx/onnx.git")
+
+    add_versions("v1.16.0", "0ce153e26ce2c00afca01c331a447d86fbf21b166b640551fe04258b4acfc6a4")
     add_versions("v1.15.0", "c757132e018dd0dd171499ef74fca88b74c5430a20781ec53da19eb7f937ef68")
     add_versions("v1.11.0", "a20f2d9df805b16ac75ab4da0a230d3d1c304127d719e5c66a4e6df514e7f6c0")
     add_versions("v1.12.0", "052ad3d5dad358a33606e0fc89483f8150bb0655c99b12a43aa58b5b7f0cc507")
 
+    add_patches("1.16.0", "patches/1.16.0/cmake-abseil.patch", "d8cad2b231ce01aa3263692f88293be3eaa2b380e021eb5288f4c7ea930c19cb")
+
+    add_configs("exceptions", {description = "Enable exception handling", default = true, type = "boolean"})
+    add_configs("registration", {description = "Enable static registration for onnx operator schemas.", default = true, type = "boolean"})
+
     add_deps("cmake")
     add_deps("protobuf-cpp")
     add_deps("python", {kind = "binary"})
@@ -26,7 +33,12 @@ package("onnx")
         local configs = {}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
-        table.insert(configs, "-DCMAKE_CXX_STANDARD=" .. (package:is_plat("windows") and "17" or "11"))
+        if package:version():lt("1.16.0") then
+            table.insert(configs, "-DCMAKE_CXX_STANDARD=" .. (package:is_plat("windows") and "17" or "11"))
+        end
+        table.insert(configs, "-DONNX_USE_PROTOBUF_SHARED_LIBS=" .. (package:dep("protobuf-cpp"):config("shared") and "ON" or "OFF"))
+        table.insert(configs, "-DONNX_DISABLE_EXCEPTIONS=" .. (package:config("exceptions") and "OFF" or "ON"))
+        table.insert(configs, "-DONNX_DISABLE_STATIC_REGISTRATION=" .. (package:config("registration") and "OFF" or "ON"))
         if package:is_plat("windows") then
             local vs_runtime = package:config("vs_runtime")
             if vs_runtime then
@@ -41,7 +53,7 @@ package("onnx")
 
     on_test(function (package)
         local languages = "c++11"
-        if package:is_plat("windows") then
+        if package:is_plat("windows") or package:version():ge("1.16.0") then
             languages = "c++17"
         end
         assert(package:has_cxxtypes("onnx::ModelProto", {includes = "onnx/proto_utils.h", configs = {languages = languages}}))

+ 2 - 0
packages/p/protobuf-cpp/xmake.lua

@@ -57,6 +57,7 @@ package("protobuf-cpp")
         io.replace("CMakeLists.txt", "set(protobuf_DEBUG_POSTFIX \"d\"", "set(protobuf_DEBUG_POSTFIX \"\"", {plain = true})
      
         local configs = {"-Dprotobuf_BUILD_TESTS=OFF", "-Dprotobuf_BUILD_PROTOC_BINARIES=ON"}
+        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"))
       
         local packagedeps = {}
@@ -66,6 +67,7 @@ package("protobuf-cpp")
         end
 
         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"))
             if package:config("shared") then
                 package:add("defines", "PROTOBUF_USE_DLLS")