Browse Source

update embree (#1676)

* update embree

* update tbb

* fix embree

* fix mingw CMAKE_SYSTEM_PROCESSOR

* fix opencv

* constrain opencv

* fix tbb
Hoildkv 2 years ago
parent
commit
3db218b43e
3 changed files with 41 additions and 10 deletions
  1. 10 1
      packages/e/embree/xmake.lua
  2. 16 9
      packages/o/opencv/xmake.lua
  3. 15 0
      packages/t/tbb/xmake.lua

+ 10 - 1
packages/e/embree/xmake.lua

@@ -10,19 +10,28 @@ package("embree")
     add_versions("v3.13.0", "4d86a69508a7e2eb8710d571096ad024b5174834b84454a8020d3a910af46f4f")
     add_versions("v3.13.3", "74ec785afb8f14d28ea5e0773544572c8df2e899caccdfc88509f1bfff58716f")
     add_versions("v3.13.4", "e6a8d1d4742f60ae4d936702dd377bc4577a3b034e2909adb2197d0648b1cb35")
+    add_versions("v3.13.5", "b8c22d275d9128741265537c559d0ea73074adbf2f2b66b0a766ca52c52d665b")
 
     -- Not recommanded to build embree as a static library.
     add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"})
 
     add_deps("cmake", "tbb")
+    if is_plat("windows") then
+        add_syslinks("advapi32")
+    end
+    add_links("embree3", "embree_sse42", "embree_avx", "embree_avx2", "embree_avx512", "tasking", "simd", "lexers", "math", "sys")
 
-    on_install("macosx", "linux", "windows", function (package)
+    on_install("macosx", "linux", "windows|x64", "windows|x86", function (package)
+        io.replace("common/tasking/CMakeLists.txt", "include(installTBB)", "", {plain = true})
         local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_DOC=OFF", "-DEMBREE_TUTORIALS=OFF", "-DEMBREE_ISPC_SUPPORT=OFF"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DEMBREE_STATIC_LIB=" .. (package:config("shared") and "OFF" or "ON"))
         if package:is_plat("windows") then
             table.insert(configs, "-DUSE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
         end
+        if package:is_plat("macosx") and package:is_arch("x86_64") and not package:config("shared") then
+            table.insert(configs, "-DEMBREE_MAX_ISA=DEFAULT")
+        end
         import("package.tools.cmake").install(package, configs)
     end)
 

+ 16 - 9
packages/o/opencv/xmake.lua

@@ -75,7 +75,10 @@ package("opencv")
 
     on_load("linux", "macosx", "windows", "mingw@windows,msys", function (package)
         if package:is_plat("windows") then
-            local arch = (package:is_arch("x64") and "x64" or "x86")
+            local arch = "x64"
+            if     package:is_arch("x86")   then arch = "x86"
+            elseif package:is_arch("arm64") then arch = "ARM64"
+            end
             local linkdir = (package:config("shared") and "lib" or "staticlib")
             local vs = import("core.tool.toolchain").load("msvc"):config("vs")
             local vc_ver = "vc13"
@@ -136,8 +139,14 @@ package("opencv")
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         if package:is_plat("windows") then
             table.insert(configs, "-DBUILD_WITH_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+            if package:is_arch("arm64") then
+                local vs = import("core.tool.toolchain").load("msvc"):config("vs")
+                assert(tonumber(vs) >= 2022, "opencv requires Visual Studio 2022 and later for arm targets")
+                table.insert(configs, "-DCMAKE_SYSTEM_NAME=Windows")
+                table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=ARM64")
+            end
         elseif package:is_plat("mingw") then
-            table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_arch("x86_64") and "x86_64" or "x86"))
+            table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_arch("x86_64") and "AMD64" or "i686"))
         end
         local resourcedir = package:resourcedir("opencv_contrib")
         if resourcedir then
@@ -158,7 +167,10 @@ package("opencv")
             package:add("links", reallink)
         end
         if package:is_plat("windows") then
-            local arch = package:is_arch("x64") and "x64" or "x86"
+            local arch = "x64"
+            if     package:is_arch("x86")   then arch = "x86"
+            elseif package:is_arch("arm64") then arch = "ARM64"
+            end
             local linkdir = (package:config("shared") and "lib" or "staticlib")
             local vs = import("core.tool.toolchain").load("msvc"):config("vs")
             local vc_ver = "vc13"
@@ -197,12 +209,7 @@ package("opencv")
     end)
 
     on_test(function (package)
-        -- bin path envs will be missing for precompiled artifacts in old xmake version
-        local runtest = true
-        if package.is_built and not package:is_built() and xmake.version():le("2.5.6") then
-            runtest = false
-        end
-        if runtest then
+        if not package:is_cross() then
             os.vrun((package:debug() and "opencv_versiond" or "opencv_version"))
         end
         assert(package:check_cxxsnippets({test = [[

+ 15 - 0
packages/t/tbb/xmake.lua

@@ -16,6 +16,7 @@ package("tbb")
         add_versions("2021.3.0", "8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e")
         add_versions("2021.4.0", "021796c7845e155e616f5ecda16daa606ebb4c6f90b996e5c08aebab7a8d3de3")
         add_versions("2021.5.0", "e5b57537c741400cf6134b428fc1689a649d7d38d9bb9c1b6d64f092ea28178a")
+        add_versions("2021.7.0", "2cae2a80cda7d45dc7c072e4295c675fff5ad8316691f26f40539f7e7e54c0cc")
     else
         add_urls("https://github.com/oneapi-src/oneTBB/archive/v$(version).tar.gz")
         add_versions("2020.3", "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3")
@@ -23,6 +24,7 @@ package("tbb")
         add_versions("2021.3.0", "8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e")
         add_versions("2021.4.0", "021796c7845e155e616f5ecda16daa606ebb4c6f90b996e5c08aebab7a8d3de3")
         add_versions("2021.5.0", "e5b57537c741400cf6134b428fc1689a649d7d38d9bb9c1b6d64f092ea28178a")
+        add_versions("2021.7.0", "2cae2a80cda7d45dc7c072e4295c675fff5ad8316691f26f40539f7e7e54c0cc")
 
         add_patches("2021.2.0", path.join(os.scriptdir(), "patches", "2021.2.0", "gcc11.patch"), "181511cf4878460cb48ac0531d3ce8d1c57626d698e9001a0951c728fab176fb")
         add_patches("2021.5.0", path.join(os.scriptdir(), "patches", "2021.5.0", "i386.patch"), "1a1c11724839cf98b1b8f4d415c0283ec7719c330b11503c578739eb02889ec0")
@@ -53,7 +55,20 @@ package("tbb")
             end
             local configs = {"-DTBB_TEST=OFF", "-DTBB_STRICT=OFF"}
             table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+            if package:is_plat("mingw") then
+                table.insert(configs, "-DCMAKE_SYSTEM_PROCESSOR=" .. (package:is_arch("x86_64") and "AMD64" or "i686"))
+            end
             import("package.tools.cmake").install(package, configs)
+            if package:is_plat("mingw") then
+                local ext = package:config("shared") and ".dll.a" or ".a"
+                local libfiles = os.files(path.join(package:installdir("lib"), "libtbb*" .. ext))
+                for _, libfile in ipairs(libfiles) do
+                    if libfile:match(".+libtbb%d+" .. ext) then
+                        os.cp(libfile, path.join(package:installdir("lib"), "libtbb" .. ext))
+                        break
+                    end
+                end
+            end
         else
             local configs = {"-j4", "tbb_build_prefix=build_dir"}
             local cfg = package:debug() and "debug" or "release"