Browse Source

angelscript: support windows arm64 (#3688)

* support windows arm64

* port windows arm64
star9029 1 year ago
parent
commit
81b799f1f1

+ 27 - 0
packages/a/angelscript/patches/msvc-arm64.patch

@@ -0,0 +1,27 @@
+diff --git a/angelscript/source/as_callfunc_arm64_msvc.asm b/angelscript/source/as_callfunc_arm64_msvc.asm
+index ce43c75..1059246 100644
+--- a/angelscript/source/as_callfunc_arm64_msvc.asm
++++ b/angelscript/source/as_callfunc_arm64_msvc.asm
+@@ -68,7 +68,7 @@ GetHFAReturnDouble PROC
+     ALIGN   4
+ GetHFAReturnFloat PROC
+     adr     x9, |populateFloats|
+-    sub     x9, x9, x2 // x9 -= returnSize; (already 4 bytes per return)
++    sub     x9, x9, x2 ; x9 -= returnSize; (already 4 bytes per return)
+     br      x9
+ 
+     str     s3, [x1, #0x4]
+@@ -185,6 +185,7 @@ CallARM64Ret128 PROC
+     ldp     fp, lr, [sp],#0x20
+ 
+     ret ; CallARM64Ret128
++    ENDP
+ 
+     ALIGN   4
+ CallARM64RetInMemory PROC
+@@ -202,4 +203,4 @@ CallARM64RetInMemory PROC
+ 
+     ret ; CallARM64RetInMemory
+ 
+-    END
++    ENDP

+ 36 - 0
packages/a/angelscript/port/xmake.lua

@@ -0,0 +1,36 @@
+add_rules("mode.debug", "mode.release")
+add_rules("utils.install.cmake_importfiles")
+set_languages("c++11")
+
+option("exceptions", {showmenu = true,  default = false})
+
+target("angelscript")
+    set_kind("shared")
+    add_files("angelscript/source/*.cpp")
+    add_headerfiles("angelscript/include/*.h")
+    add_includedirs("angelscript/include")
+
+    add_defines("ANGELSCRIPT_EXPORT")
+    if not has_config("exceptions") then
+        add_defines("AS_NO_EXCEPTIONS")
+    end
+
+    if is_plat("windows") then
+        if is_arch("x64") then
+            add_files("angelscript/source/as_callfunc_x64_msvc_asm.asm")
+        elseif is_arch("arm64") then
+            add_files("angelscript/source/as_callfunc_arm64_msvc.asm")
+        -- elseif is_arch("arm32") then
+        --     add_files("angelscript/source/as_callfunc_arm_msvc.asm")
+        end
+    else
+        if is_arch("arm32") then
+            add_files("angelscript/source/as_callfunc_arm_gcc.S")
+        elseif is_arch("arm64") then
+            add_files("angelscript/source/as_callfunc_arm64_gcc.S")
+        end
+
+        if is_plat("linux") then
+            add_syslinks("pthread")
+        end
+    end

+ 16 - 3
packages/a/angelscript/xmake.lua

@@ -1,5 +1,4 @@
 package("angelscript")
-
     set_homepage("http://angelcode.com/angelscript/")
     set_description("Extremely flexible cross-platform scripting library designed to allow applications to extend their functionality through external scripts")
     set_license("zlib")
@@ -10,23 +9,37 @@ package("angelscript")
     add_versions("2.35.0", "010dd45e23e734d46f5891d70e268607a12cb9ab12503dda42f842d9db7e8857")
     add_versions("2.34.0", "6faa043717522ae0fb2677d907ca5b0e35a79d28e5f83294565e6c6229bfbdf7")
 
+    add_patches(">=2.34.0", "patches/msvc-arm64.patch", "1433f474870102e6fd8d0c9978b6d122a098cdecded29be70176b9dab534564f")
+
+    add_configs("exceptions", {description = "Enable exception handling in script context", default = false, type = "boolean"})
+
     if is_plat("linux") then
         add_syslinks("pthread")
     end
 
-    add_deps("cmake")
+    on_load("windows|x86", "windows|x64", "linux", "android", "msys", "mingw", function (package)
+        package:add("deps", "cmake")
+    end)
 
     on_install("windows|x86", "windows|x64", "linux", "android", "msys", "mingw", function (package)
         os.cd("angelscript/projects/cmake")
         local configs = {}
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
-        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, "-DAS_NO_EXCEPTIONS=" .. (package:config("exceptions") and "OFF" or "ON"))
         if package:is_plat("android") then
             io.gsub("CMakeLists.txt", "set_property", "#set_property")
         end
         import("package.tools.cmake").install(package, configs)
     end)
 
+    on_install("windows|arm64", function (package)
+        local configs = {}
+        configs.exceptions = package:config("exceptions")
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package, configs)
+    end)
+
     on_test(function (package)
         assert(package:check_cxxsnippets({test = [[
             #include <iostream>