summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/sdks
diff options
context:
space:
mode:
authorruki <[email protected]>2025-05-17 22:08:31 +0800
committerGitHub <[email protected]>2025-05-17 22:08:31 +0800
commit2f8decdc353f4e18de953c074ae8fed1c0969cda (patch)
tree48c8fc85958094ba81f635e6dcaf59f351e88374 /xmake/modules/detect/sdks
parentbfef847fcd6f6745b52a9f3c2ab2870dcaf23d16 (diff)
parent2b88ba37fa0a9957b8ab24cf1bf6da59e2c39f21 (diff)
Merge branch 'dev' into unitybuildunitybuild
Diffstat (limited to 'xmake/modules/detect/sdks')
-rw-r--r--xmake/modules/detect/sdks/find_qt.lua25
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua50
2 files changed, 52 insertions, 23 deletions
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua
index d720ac8b8..29eb65e73 100644
--- a/xmake/modules/detect/sdks/find_qt.lua
+++ b/xmake/modules/detect/sdks/find_qt.lua
@@ -141,7 +141,13 @@ function _find_sdkdir(sdkdir, sdkver)
-- @see https://github.com/xmake-io/xmake/issues/4881
if sdkver then
local major = sdkver:sub(1, 1)
- qmake = find_file("qmake" .. major, paths, {suffixes = subdirs})
+ local suffixes = {major, "-" .. major, "-qt" .. major, ""}
+ for _, suffix in ipairs(suffixes) do
+ qmake = find_file("qmake" .. suffix, paths, {suffixes = subdirs})
+ if qmake then
+ break
+ end
+ end
end
if not qmake then
qmake = find_file("qmake", paths, {suffixes = subdirs})
@@ -167,18 +173,25 @@ function _find_qmake(sdkdir, sdkver)
if sdkver then
sdkver = semver.try_parse(sdkver)
if sdkver then
- local cachekey = "qmake-" .. sdkver:major()
- qmake = find_tool("qmake", {program = "qmake" .. sdkver:major(), cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")})
+ local major = sdkver:major()
+ local suffixes = {major, "-" .. major, "-qt" .. major}
+ for _, suffix in ipairs(suffixes) do
+ local cachekey = "qmake" .. suffix
+ qmake = find_tool("qmake", {program = cachekey, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")})
+ if qmake then
+ break
+ end
+ end
end
end
-- we need to find the default qmake in current system
-- maybe we only installed qmake6
if not qmake then
- local suffixes = {"", "6", "-qt5"}
+ local suffixes = {"", "6", "-6", "-qt6", "5", "-5", "-qt5"}
for _, suffix in ipairs(suffixes) do
- local cachekey = "qmake-" .. suffix
- qmake = find_tool("qmake", {program = "qmake" .. suffix, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")})
+ local cachekey = "qmake" .. suffix
+ qmake = find_tool("qmake", {program = cachekey, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")})
if qmake then
break
end
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index c3aca3ad4..3e687228a 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -109,11 +109,9 @@ function find_build_tools(opt)
end
local variables = {}
- local VCToolsVersion
- local vs_toolset = opt.vs_toolset
- if vs_toolset and os.isdir(path.join(sdkdir, "VC/Tools/MSVC", vs_toolset)) then
- VCToolsVersion = vs_toolset
- else
+ local VCInstallDir = path.join(sdkdir, "VC")
+ local VCToolsVersion = opt.vs_toolset
+ if not VCToolsVersion or not os.isdir(path.join(VCInstallDir, "Tools/MSVC", VCToolsVersion)) then
-- https://github.com/xmake-io/xmake/issues/6159
local latest_toolset
for _, dir in ipairs(os.dirs(path.join(sdkdir, "VC/Tools/MSVC/*"))) do
@@ -128,8 +126,9 @@ function find_build_tools(opt)
return
end
end
+ variables.VCInstallDir = VCInstallDir
variables.VCToolsVersion = VCToolsVersion
- variables.VCToolsInstallDir = path.join(sdkdir, "VC/Tools/MSVC", VCToolsVersion)
+ variables.VCToolsInstallDir = path.join(VCInstallDir, "Tools/MSVC", VCToolsVersion)
local WindowsSDKVersion
local vs_sdkver = opt.vs_sdkver
@@ -145,10 +144,15 @@ function find_build_tools(opt)
end
variables.WindowsSDKVersion = WindowsSDKVersion
variables.WindowsSdkDir = path.join(sdkdir, "Windows Kits/10")
+ variables.WindowsSdkBinPath = path.join(variables.WindowsSdkDir, "bin")
+ variables.WindowsSdkVerBinPath = path.join(variables.WindowsSdkBinPath, WindowsSDKVersion)
+ variables.ExtensionSdkDir = path.join(variables.WindowsSdkDir, "ExtensionSdkDir")
+ variables.UCRTVersion = WindowsSDKVersion
+ variables.UniversalCRTSdkDir = variables.WindowsSdkDir
local includedirs = {
path.join(variables.VCToolsInstallDir, "include"),
- path.join(variables.VCToolsInstallDir, "atlmfc/include"),
+ path.join(variables.VCToolsInstallDir, "atlmfc", "include"),
path.join(variables.WindowsSdkDir, "Include", WindowsSDKVersion, "ucrt"),
path.join(variables.WindowsSdkDir, "Include", WindowsSDKVersion, "shared"),
path.join(variables.WindowsSdkDir, "Include", WindowsSDKVersion, "um"),
@@ -158,8 +162,10 @@ function find_build_tools(opt)
local linkdirs = {
path.join(variables.VCToolsInstallDir, "lib"),
+ path.join(variables.VCToolsInstallDir, "atlmfc", "lib"),
path.join(variables.WindowsSdkDir, "Lib", WindowsSDKVersion, "ucrt"),
path.join(variables.WindowsSdkDir, "Lib", WindowsSDKVersion, "um"),
+ path.join(variables.WindowsSdkDir, "Lib", WindowsSDKVersion, "km"),
}
local archs = {
@@ -182,32 +188,42 @@ function find_build_tools(opt)
if #lib ~= 0 then
local vcvars = {
BUILD_TOOLS_ROOT = sdkdir,
+ VSInstallDir = sdkdir,
-- vs runs in a windows ctx, so the envsep is always ";"
INCLUDE = path.joinenv(includedirs, ';'),
LIB = path.joinenv(lib, ';'),
- WindowsSdkDir = variables.WindowsSdkDir,
- WindowsSDKVersion = WindowsSDKVersion,
- VCToolsInstallDir = variables.VCToolsInstallDir,
VSCMD_ARG_HOST_ARCH = "x64",
+
+ VCInstallDir = variables.VCInstallDir,
+ VCToolsVersion = variables.VCToolsVersion,
+ VCToolsInstallDir = variables.VCToolsInstallDir,
+
+ WindowsSDKVersion = variables.WindowsSDKVersion,
+ WindowsSdkDir = variables.WindowsSdkDir,
+ WindowsSdkBinPath = variables.WindowsSdkBinPath,
+ WindowsSdkVerBinPath = variables.WindowsSdkVerBinPath,
+ ExtensionSdkDir = variables.ExtensionSdkDir,
+ UCRTVersion = variables.UCRTVersion,
+ UniversalCRTSdkDir = variables.UniversalCRTSdkDir,
}
- local buidl_tools_bin = {}
+ local build_tools_bin = {}
local host_dir = "Host" .. vcvars.VSCMD_ARG_HOST_ARCH
if is_host("windows") then
- table.insert(buidl_tools_bin, path.join(vcvars.VCToolsInstallDir, "bin", host_dir, target_arch))
- table.insert(buidl_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion))
- table.insert(buidl_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion, "ucrt"))
+ table.insert(build_tools_bin, path.join(vcvars.VCToolsInstallDir, "bin", host_dir, target_arch))
+ table.insert(build_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion))
+ table.insert(build_tools_bin, path.join(vcvars.WindowsSdkDir, "bin", WindowsSDKVersion, "ucrt"))
elseif is_host("linux") then
-- for msvc-wine
- table.insert(buidl_tools_bin, path.join(sdkdir, "bin", target_arch))
+ table.insert(build_tools_bin, path.join(sdkdir, "bin", target_arch))
end
vcvars.VSCMD_ARG_TGT_ARCH = target_arch
- vcvars.BUILD_TOOLS_BIN = path.joinenv(buidl_tools_bin)
+ vcvars.BUILD_TOOLS_BIN = path.joinenv(build_tools_bin)
- local PATH = buidl_tools_bin
+ local PATH = build_tools_bin
table.join2(PATH, path.splitenv(os.getenv("PATH")))
vcvars.PATH = path.joinenv(PATH)