summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-16 00:53:17 +0800
committerruki <[email protected]>2024-01-16 00:53:17 +0800
commit4c40d7689500353292e28b6d3b27c9f6dc960c68 (patch)
tree162d75b237f0a87df9ecd28ecf8196b12ec68784
parentd3589b0d7954ed7f37dea0c19299341054cd3f3c (diff)
support vsdevcmd without vcvarsall.bat #4609
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index a95c48059..b28119bd6 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -276,18 +276,19 @@ function _find_vstudio(opt)
-- * version > 15.0 eschews registry entries; but `vswhere` (included with version >= 15.2) can be used to find VC install path
-- ref: https://github.com/Microsoft/vswhere/blob/master/README.md @@ https://archive.is/mEmdu
local vswhere_VCAuxiliaryBuildDir = nil
+ local vswhere_Common7ToolsDir = nil
if (tonumber(version) >= 15) and vswhere then
local vswhere_vrange = format("%s,%s)", version, (version + 1))
-- build tools: https://github.com/microsoft/vswhere/issues/22 @@ https://aka.ms/vs/workloads
local result = os.iorunv(vswhere.program, {"-products", "*", "-prerelease", "-property", "installationpath", "-version", vswhere_vrange})
if result then
vswhere_VCAuxiliaryBuildDir = path.join(result:trim(), "VC", "Auxiliary", "Build")
+ vswhere_Common7ToolsDir = path.join(result:trim(), "Common7", "Tools")
end
end
-- init paths
- local paths =
- {
+ local paths = {
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC7\\bin", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version),
@@ -330,6 +331,17 @@ function _find_vstudio(opt)
end
vcvarsall = find_file("vcvarsall.bat", paths) or find_file("vcvars32.bat", paths)
end
+ if not vcvarsall then
+ local paths = {
+ format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\Common7\\Tools", version),
+ format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\Common7\\Tools", version)
+ }
+ if vswhere_Common7ToolsDir and os.isdir(vswhere_Common7ToolsDir) then
+ table.insert(paths, 1, vswhere_Common7ToolsDir)
+ end
+ local vsdevcmd = find_file("VsDevCmd.bat", paths)
+ vcvarsall = vsdevcmd
+ end
if vcvarsall then
-- load vcvarsall