Browse Source

Auto-update astc-encoder to 5.2.0 (#6396)

* Update astc-encoder to 5.2.0

* Update xmake.lua

* remove -mcpu

* fix lto

* fix pthread

* fix linux arm64

* print bin dir

* limit arch

* fix configs

* revert

---------

Co-authored-by: star9029 <[email protected]>
ruki 3 months ago
parent
commit
b570f5befa
1 changed files with 50 additions and 8 deletions
  1. 50 8
      packages/a/astc-encoder/xmake.lua

+ 50 - 8
packages/a/astc-encoder/xmake.lua

@@ -4,8 +4,9 @@ package("astc-encoder")
     set_license("Apache-2.0")
     set_license("Apache-2.0")
 
 
     add_urls("https://github.com/ARM-software/astc-encoder/archive/refs/tags/$(version).tar.gz",
     add_urls("https://github.com/ARM-software/astc-encoder/archive/refs/tags/$(version).tar.gz",
-             "https://github.com/ARM-software/astc-encoder.git")
+             "https://github.com/ARM-software/astc-encoder.git", {submodules = false})
 
 
+    add_versions("5.2.0", "1680d440b765c3809490b6b49664a2ba0798624629615da4ff834401c0f1fe23")
     add_versions("4.8.0", "6c12f4656be21a69cbacd9f2c817283405decb514072dc1dcf51fd9a0b659852")
     add_versions("4.8.0", "6c12f4656be21a69cbacd9f2c817283405decb514072dc1dcf51fd9a0b659852")
     add_versions("4.7.0", "a57c81f79055aa7c9f8c82ac5464284e3df9bba682895dee09fa35bd1fdbab93")
     add_versions("4.7.0", "a57c81f79055aa7c9f8c82ac5464284e3df9bba682895dee09fa35bd1fdbab93")
     add_versions("4.6.1", "a73c7afadb2caba00339a8f715079d43f9b7e75cf57463477e5ac36ef7defd26")
     add_versions("4.6.1", "a73c7afadb2caba00339a8f715079d43f9b7e75cf57463477e5ac36ef7defd26")
@@ -18,17 +19,49 @@ package("astc-encoder")
     add_configs("native", {description = "Enable astcenc builds for native SIMD", default = false, type = "boolean"})
     add_configs("native", {description = "Enable astcenc builds for native SIMD", default = false, type = "boolean"})
     add_configs("decompressor", {description = "Enable astcenc builds for decompression only", default = false, type = "boolean"})
     add_configs("decompressor", {description = "Enable astcenc builds for decompression only", default = false, type = "boolean"})
     add_configs("diagnostics", {description = "Enable astcenc builds with diagnostic trace", default = false, type = "boolean"})
     add_configs("diagnostics", {description = "Enable astcenc builds with diagnostic trace", default = false, type = "boolean"})
-    add_configs("asan", {description = "Enable astcenc builds with address sanitizer", default = false, type = "boolean"})
 
 
     add_configs("invariance", {description = "Enable astcenc floating point invariance", default = true, type = "boolean"})
     add_configs("invariance", {description = "Enable astcenc floating point invariance", default = true, type = "boolean"})
     add_configs("cli", {description = "Enable build of astcenc command line tools", default = true, type = "boolean"})
     add_configs("cli", {description = "Enable build of astcenc command line tools", default = true, type = "boolean"})
 
 
+    if is_plat("linux", "bsd") then
+        add_syslinks("pthread")
+    end
+
     add_deps("cmake")
     add_deps("cmake")
 
 
-    on_install("windows|x64", "windows|x86", "mingw|x86_64", "linux", function (package)
+    on_load(function (package)
+        package:config_set("cli", not package:is_cross())
+        if package:is_plat("wasm", "cross") then
+            package:config_set("none", true)
+        end
+
+        if package:config("shared") then
+            package:add("defines", "ASTCENC_DYNAMIC_LIBRARY")
+        end
+    end)
+    -- arm_neon_sve_bridge.h: No such file or directory
+    on_install("!linux or linux|!arm64", function (package)
         io.replace("Source/cmake_core.cmake", "-Werror", "", {plain = true})
         io.replace("Source/cmake_core.cmake", "-Werror", "", {plain = true})
+        io.replace("Source/CMakeLists.txt", "-flto", "", {plain = true})
+        io.replace("Source/CMakeLists.txt", "-flto=auto", "", {plain = true})
+        if package:is_plat("mingw", "android", "bsd") or package:has_tool("cxx", "clang") then
+            io.replace("Source/cmake_core.cmake", "$<${is_clangcl}:-mcpu=native -march=native>", "", {plain = true})
+            io.replace("Source/cmake_core.cmake", "$<${is_gnu_fe}:-mcpu=native -march=native>", "", {plain = true})
+        end
+
+        local file = io.open("Source/cmake_core.cmake", "a")
+        local target_name = "${ASTCENC_TARGET}-" .. (package:config("shared") and "shared" or "static")
+        file:write(format([[
+            include(GNUInstallDirs)
+            install(TARGETS %s
+                RUNTIME DESTINATION bin
+                LIBRARY DESTINATION lib
+                ARCHIVE DESTINATION lib
+            )
+        ]], target_name))
+        file:close()
 
 
-        local configs = {}
+        local configs = {"-DASTCENC_WERROR=OFF"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DASTCENC_SHAREDLIB=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DASTCENC_SHAREDLIB=" .. (package:config("shared") and "ON" or "OFF"))
 
 
@@ -44,15 +77,24 @@ package("astc-encoder")
         table.insert(configs, "-DASTCENC_INVARIANCE=" .. (package:config("invariance") and "ON" or "OFF"))
         table.insert(configs, "-DASTCENC_INVARIANCE=" .. (package:config("invariance") and "ON" or "OFF"))
         table.insert(configs, "-DASTCENC_CLI=" .. (package:config("cli") and "ON" or "OFF"))
         table.insert(configs, "-DASTCENC_CLI=" .. (package:config("cli") and "ON" or "OFF"))
 
 
-        import("package.tools.cmake").install(package, configs)
+        local opt = {}
+        if package:is_plat("linux", "bsd") then
+            opt.ldflags = "-lpthread"
+            opt.shflags = "-lpthread"
+        end
+        import("package.tools.cmake").install(package, configs, opt)
 
 
-        os.cp("Source/astcenc.h", package:installdir("include"))
         if package:config("shared") then
         if package:config("shared") then
-            package:add("linkdirs", "bin")
+            io.replace("Source/astcenc.h",
+                [[#define ASTCENC_PUBLIC extern "C" __declspec(dllexport)]],
+                [[#define ASTCENC_PUBLIC extern "C" __declspec(dllimport)]], {plain = true})
         end
         end
+
+        os.cp("Source/astcenc.h", package:installdir("include"))
         if package:config("cli") then
         if package:config("cli") then
             local exe_prefix = package:is_plat("mingw", "windows") and ".exe" or ""
             local exe_prefix = package:is_plat("mingw", "windows") and ".exe" or ""
-            os.mv(path.join(package:installdir("bin"), "astcenc-native" .. exe_prefix), path.join(package:installdir("bin"), "astcenc" .. exe_prefix))
+            -- TODO: rename astcenc-neno?
+            os.trymv(path.join(package:installdir("bin"), "astcenc-native" .. exe_prefix), path.join(package:installdir("bin"), "astcenc" .. exe_prefix))
             package:addenv("PATH", "bin")
             package:addenv("PATH", "bin")
         end
         end
     end)
     end)