Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add windows arm/arm64ec support #5316

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions xmake/modules/core/tools/cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 33 additions & 8 deletions xmake/modules/detect/sdks/find_vstudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -469,3 +493,4 @@ function main(opt)
end
return vstudio
end

14 changes: 9 additions & 5 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/modules/package/tools/meson.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions xmake/modules/private/action/trybuild/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion xmake/platforms/windows/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion xmake/toolchains/msvc/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand All @@ -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()
Expand Down
Loading