From b973d2af44dba9785fdd50792dd867722b0adab8 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jul 2024 22:50:48 +0800 Subject: add windows arm support --- xmake/modules/detect/sdks/find_vstudio.lua | 25 +++++++++++++++++++++++-- xmake/platforms/windows/xmake.lua | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index a6b7f471e..183f7162f 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -268,11 +268,21 @@ function _find_vstudio(opt) -- load vcvarsall 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) -- 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 + } + } return results end end @@ -367,10 +377,20 @@ function _find_vstudio(opt) -- load vcvarsall 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) -- 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 + } + } end end return results @@ -469,3 +489,4 @@ function main(opt) end return vstudio end + diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 14ada8784..f5f6ca424 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") set_formats("static", "$(name).lib") set_formats("object", "$(name).obj") -- cgit v1.3.1 From 8621473fcae841844b670173df23646f7e1a40d0 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jul 2024 22:51:44 +0800 Subject: update readme --- README.md | 2 +- README_zh.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a0b77f44..3c80c5326 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) * 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..b08bf8d04 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) * macOS (i386, x86_64, arm64) * Linux (i386, x86_64, arm, arm64, riscv, mips, 390x, sh4 ...) * *BSD (i386, x86_64) -- cgit v1.3.1 From 6161154cd0ee1552f4a369d5da80c82c2fde9407 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jul 2024 22:59:07 +0800 Subject: support arm64ec --- README.md | 2 +- README_zh.md | 2 +- xmake/modules/core/tools/cl.lua | 14 +++++++------- xmake/modules/detect/sdks/find_vstudio.lua | 24 ++++++++++++++---------- xmake/toolchains/msvc/load.lua | 7 ++++++- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3c80c5326..6620c6e0a 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ $ xmake f --menu ## Supported platforms -* Windows (x86, x64, arm, 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 b08bf8d04..1b3f5437f 100644 --- a/README_zh.md +++ b/README_zh.md @@ -241,7 +241,7 @@ $ xmake f --menu ## 支持平台 -* Windows (x86, x64, arm, 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 183f7162f..2ce2b44eb 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -266,10 +266,11 @@ 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_arm = _load_vcvarsall(vcvarsall, VisualStudioVersion, "arm", 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 = {} @@ -280,7 +281,8 @@ function _find_vstudio(opt) x86 = vcvarsall_x86, x64 = vcvarsall_x64, arm = vcvarsall_arm, - arm64 = vcvarsall_arm64 + arm64 = vcvarsall_arm64, + arm64ec = vcvarsall_arm64ec } } return results @@ -375,10 +377,11 @@ 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_arm = _load_vcvarsall(vcvarsall, version, "arm", 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]] = { @@ -388,7 +391,8 @@ function _find_vstudio(opt) x86 = vcvarsall_x86, x64 = vcvarsall_x64, arm = vcvarsall_arm, - arm64 = vcvarsall_arm64 + arm64 = vcvarsall_arm64, + arm64ec = vcvarsall_arm64ec } } end 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", "armasm64_msvc@armasm64.exe") elseif toolchain:is_arch("arm.*") then toolchain:set("toolset", "as", "armasm_msvc@armasm.exe") @@ -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() -- cgit v1.3.1 From b42d338164895297339e94792faf2da4418f1e88 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jul 2024 23:00:31 +0800 Subject: enable arm64ec for tools.cmake --- xmake/modules/package/tools/cmake.lua | 14 +++++++++----- xmake/platforms/windows/xmake.lua | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 248368e77..735d2fe48 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:startswith("arm64") then return "ARM64" end + if arch:startswith("arm64ec") then return "ARM64EC" 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/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index f5f6ca424..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", "arm", "arm64") + set_archs("x86", "x64", "arm", "arm64", "arm64ec") set_formats("static", "$(name).lib") set_formats("object", "$(name).obj") -- cgit v1.3.1 From 8a9a8a2bee6db0730d6e376e0114a3430ceba063 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jul 2024 23:00:53 +0800 Subject: enable arm64ec for tools.cmake again --- xmake/modules/package/tools/meson.lua | 2 +- xmake/modules/private/action/trybuild/cmake.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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..c976e4bd5 100644 --- a/xmake/modules/private/action/trybuild/cmake.lua +++ b/xmake/modules/private/action/trybuild/cmake.lua @@ -110,7 +110,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 -- cgit v1.3.1 From c14fe608eff79051422ff32250f87a1e4f6cd597 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jul 2024 23:01:53 +0800 Subject: fix vs arch --- xmake/modules/package/tools/cmake.lua | 2 +- xmake/modules/private/action/trybuild/cmake.lua | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 735d2fe48..d2fa362c6 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -102,8 +102,8 @@ 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 == "arm64ec" then return "ARM64EC" end if arch:startswith("arm64") then return "ARM64" end - if arch:startswith("arm64ec") then return "ARM64EC" end if arch:startswith("arm") then return "ARM" end return arch end diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua index c976e4bd5..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") @@ -456,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}) -- cgit v1.3.1