summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-08 13:49:44 +0800
committerGitHub <[email protected]>2024-07-08 13:49:44 +0800
commit34d02dc6438f438e2cb89e9f703a6323c18e6761 (patch)
tree6904be2845d486a2104a7766addcf9866d08a9f3
parenta80dac0cbe3d3259b14a78738ef9bd1e1134a028 (diff)
parentc14fe608eff79051422ff32250f87a1e4f6cd597 (diff)
Merge pull request #5316 from xmake-io/arm
add windows arm/arm64ec support
-rw-r--r--README.md2
-rw-r--r--README_zh.md2
-rw-r--r--xmake/modules/core/tools/cl.lua14
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua41
-rw-r--r--xmake/modules/package/tools/cmake.lua14
-rw-r--r--xmake/modules/package/tools/meson.lua2
-rw-r--r--xmake/modules/private/action/trybuild/cmake.lua18
-rw-r--r--xmake/platforms/windows/xmake.lua2
-rw-r--r--xmake/toolchains/msvc/load.lua7
9 files changed, 75 insertions, 27 deletions
diff --git a/README.md b/README.md
index 2a0b77f44..6620c6e0a 100644
--- a/README.md
+++ b/README.md
@@ -180,7 +180,7 @@ $ xmake f --menu
## Supported platforms
-* Windows (x86, x64, arm64)
+* Windows (x86, x64, arm, arm64, arm64ec)
* macOS (i386, x86_64, arm64)
* Linux (i386, x86_64, arm, arm64, riscv, mips, 390x, sh4 ...)
* *BSD (i386, x86_64)
diff --git a/README_zh.md b/README_zh.md
index efbb47e04..1b3f5437f 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -241,7 +241,7 @@ $ xmake f --menu
## 支持平台
-* Windows (x86, x64, arm64)
+* Windows (x86, x64, arm, arm64, arm64ec)
* macOS (i386, x86_64, arm64)
* Linux (i386, x86_64, arm, arm64, riscv, mips, 390x, sh4 ...)
* *BSD (i386, x86_64)
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index be521098b..c4eede192 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -77,15 +77,15 @@ function init(self)
-- language
, ["-ansi"] = ""
, ["-std=c99"] = "-TP" -- compile as c++ files because msvc doesn't support c99
- , ["-std=c11"] = "-std:c11"
- , ["-std=c17"] = "-std:c17"
- , ["-std=c2x"] = "-std:clatest"
- , ["-std=c23"] = "-std:clatest"
+ , ["-std=c11"] = "-std:c11"
+ , ["-std=c17"] = "-std:c17"
+ , ["-std=c2x"] = "-std:clatest"
+ , ["-std=c23"] = "-std:clatest"
, ["-std=gnu99"] = "-TP" -- compile as c++ files because msvc doesn't support c99
- , ["-std=gnu11"] = "-std:c11"
+ , ["-std=gnu11"] = "-std:c11"
, ["-std=gnu17"] = "-std:c17"
- , ["-std=gnu2x"] = "-std:clatest"
- , ["-std=gnu23"] = "-std:clatest"
+ , ["-std=gnu2x"] = "-std:clatest"
+ , ["-std=gnu23"] = "-std:clatest"
, ["-std=.*"] = ""
-- others
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index a6b7f471e..2ce2b44eb 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -266,13 +266,25 @@ function _find_vstudio(opt)
if vcvarsall and os.isfile(vcvarsall) and vsvers[VisualStudioVersion] then
-- load vcvarsall
- local vcvarsall_x86 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x86", opt)
- local vcvarsall_x64 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x64", opt)
- local vcvarsall_arm64 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "arm64", opt)
+ local vcvarsall_x86 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x86", opt)
+ local vcvarsall_x64 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x64", opt)
+ local vcvarsall_arm = _load_vcvarsall(vcvarsall, VisualStudioVersion, "arm", opt)
+ local vcvarsall_arm64 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "arm64", opt)
+ local vcvarsall_arm64ec = vcvarsall_arm64
-- save results
local results = {}
- results[vsvers[VisualStudioVersion]] = {version = VisualStudioVersion, vcvarsall_bat = vcvarsall, vcvarsall = {x86 = vcvarsall_x86, x64 = vcvarsall_x64, arm64 = vcvarsall_arm64}}
+ results[vsvers[VisualStudioVersion]] = {
+ version = VisualStudioVersion,
+ vcvarsall_bat = vcvarsall,
+ vcvarsall = {
+ x86 = vcvarsall_x86,
+ x64 = vcvarsall_x64,
+ arm = vcvarsall_arm,
+ arm64 = vcvarsall_arm64,
+ arm64ec = vcvarsall_arm64ec
+ }
+ }
return results
end
end
@@ -365,12 +377,24 @@ function _find_vstudio(opt)
if vcvarsall then
-- load vcvarsall
- local vcvarsall_x86 = _load_vcvarsall(vcvarsall, version, "x86", opt)
- local vcvarsall_x64 = _load_vcvarsall(vcvarsall, version, "x64", opt)
- local vcvarsall_arm64 = _load_vcvarsall(vcvarsall, version, "arm64", opt)
+ local vcvarsall_x86 = _load_vcvarsall(vcvarsall, version, "x86", opt)
+ local vcvarsall_x64 = _load_vcvarsall(vcvarsall, version, "x64", opt)
+ local vcvarsall_arm = _load_vcvarsall(vcvarsall, version, "arm", opt)
+ local vcvarsall_arm64 = _load_vcvarsall(vcvarsall, version, "arm64", opt)
+ local vcvarsall_arm64ec = vcvarsall_arm64
-- save results
- results[vsvers[version]] = {version = version, vcvarsall_bat = vcvarsall, vcvarsall = {x86 = vcvarsall_x86, x64 = vcvarsall_x64, arm64 = vcvarsall_arm64}}
+ results[vsvers[version]] = {
+ version = version,
+ vcvarsall_bat = vcvarsall,
+ vcvarsall = {
+ x86 = vcvarsall_x86,
+ x64 = vcvarsall_x64,
+ arm = vcvarsall_arm,
+ arm64 = vcvarsall_arm64,
+ arm64ec = vcvarsall_arm64ec
+ }
+ }
end
end
return results
@@ -469,3 +493,4 @@ function main(opt)
end
return vstudio
end
+
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 248368e77..d2fa362c6 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -100,10 +100,11 @@ end
-- get vs arch
function _get_vsarch(package)
local arch = package:arch()
- if arch == 'x86' or arch == 'i386' then return "Win32" end
- if arch == 'x86_64' then return "x64" end
- if arch:startswith('arm64') then return "ARM64" end
- if arch:startswith('arm') then return "ARM" end
+ if arch == "x86" or arch == "i386" then return "Win32" end
+ if arch == "x86_64" then return "x64" end
+ if arch == "arm64ec" then return "ARM64EC" end
+ if arch:startswith("arm64") then return "ARM64" end
+ if arch:startswith("arm") then return "ARM" end
return arch
end
@@ -297,7 +298,8 @@ function _get_cmake_system_processor(package)
x64 = "AMD64",
x86_64 = "AMD64",
arm = "ARM",
- arm64 = "ARM64"
+ arm64 = "ARM64",
+ arm64ec = "ARM64EC"
}
return archs[package:arch()] or package:arch()
end
@@ -356,6 +358,8 @@ function _get_configs_for_windows(package, configs, opt)
table.insert(configs, "Win32")
elseif package:is_arch("arm64") then
table.insert(configs, "ARM64")
+ elseif package:is_arch("arm64ec") then
+ table.insert(configs, "ARM64EC")
elseif package:is_arch("arm.*") then
table.insert(configs, "ARM")
else
diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua
index 2a2b248cf..fae75af6e 100644
--- a/xmake/modules/package/tools/meson.lua
+++ b/xmake/modules/package/tools/meson.lua
@@ -153,7 +153,7 @@ function _insert_cross_configs(package, file, opt)
elseif package:is_plat("windows") then
local cpu
local cpu_family
- if package:is_arch("arm64") then
+ if package:is_arch("arm64", "arm64ec") then
cpu = "aarch64"
cpu_family = "aarch64"
elseif package:is_arch("x86") then
diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua
index 94df5a450..747ab9c94 100644
--- a/xmake/modules/private/action/trybuild/cmake.lua
+++ b/xmake/modules/private/action/trybuild/cmake.lua
@@ -49,6 +49,17 @@ function _get_buildenv(key)
return value
end
+-- get vs arch
+function _get_vsarch()
+ local arch = get_config("arch") or os.arch()
+ if arch == "x86" or arch == "i386" then return "Win32" end
+ if arch == "x86_64" then return "x64" end
+ if arch == "arm64ec" then return "ARM64EC" end
+ if arch:startswith("arm64") then return "ARM64" end
+ if arch:startswith("arm") then return "ARM" end
+ return arch
+end
+
-- get msvc
function _get_msvc()
local msvc = toolchain.load("msvc")
@@ -110,7 +121,8 @@ function _get_cmake_system_processor()
x64 = "AMD64",
x86_64 = "AMD64",
arm = "ARM",
- arm64 = "ARM64"
+ arm64 = "ARM64",
+ arm64ec = "ARM64EC"
}
return archs[os.subarch()] or os.subarch()
end
@@ -455,7 +467,9 @@ function _build_for_msvc(opt)
local runenvs = _get_msvc_runenvs()
local msbuild = find_tool("msbuild", {envs = runenvs})
local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!")
- os.vexecv(msbuild.program, {slnfile, "-nologo", "-t:Build", "-m", "-p:Configuration=" .. (is_mode("debug") and "Debug" or "Release"), "-p:Platform=" .. (is_arch("x64") and "x64" or "Win32")}, {envs = runenvs})
+ os.vexecv(msbuild.program, {slnfile, "-nologo", "-t:Build", "-m",
+ "-p:Configuration=" .. (is_mode("debug") and "Debug" or "Release"),
+ "-p:Platform=" .. _get_vsarch()}, {envs = runenvs})
local projfile = os.isfile("INSTALL.vcxproj") and "INSTALL.vcxproj" or "INSTALL.vcproj"
if os.isfile(projfile) then
os.vexecv(msbuild.program, {projfile, "/property:configuration=" .. (is_mode("debug") and "Debug" or "Release")}, {envs = runenvs})
diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua
index 14ada8784..2b1bf4014 100644
--- a/xmake/platforms/windows/xmake.lua
+++ b/xmake/platforms/windows/xmake.lua
@@ -21,7 +21,7 @@
platform("windows")
set_os("windows")
set_hosts("windows")
- set_archs("x86", "x64", "arm64")
+ set_archs("x86", "x64", "arm", "arm64", "arm64ec")
set_formats("static", "$(name).lib")
set_formats("object", "$(name).obj")
diff --git a/xmake/toolchains/msvc/load.lua b/xmake/toolchains/msvc/load.lua
index 486c8e217..c5f2f6dac 100644
--- a/xmake/toolchains/msvc/load.lua
+++ b/xmake/toolchains/msvc/load.lua
@@ -57,7 +57,7 @@ function main(toolchain)
toolchain:set("toolset", "mrc", "rc.exe")
if toolchain:is_arch("x86") then
toolchain:set("toolset", "as", "ml.exe")
- elseif toolchain:is_arch("arm64") then
+ elseif toolchain:is_arch("arm64", "arm64ec") then
toolchain:set("toolset", "as", "[email protected]")
elseif toolchain:is_arch("arm.*") then
toolchain:set("toolset", "as", "[email protected]")
@@ -68,6 +68,11 @@ function main(toolchain)
toolchain:set("toolset", "sh", "link.exe")
toolchain:set("toolset", "ar", "link.exe")
+ -- init flags
+ if toolchain:is_arch("arm64ec") then
+ toolchain:add("cxflags", "/arm64EC")
+ end
+
-- add vs environments
local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"}
local curenvs = os.getenvs()