diff options
| author | ruki <[email protected]> | 2025-05-22 22:12:13 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-22 22:12:13 +0800 |
| commit | 7bb9e19b4a3a4fa074c122e0e5c229b5388f348d (patch) | |
| tree | 58e69697a0565fd08009bdfde6a5db84a4cbe146 | |
| parent | 9d6f52f4eda17ce1dfe69b86a6fa990d75a4a653 (diff) | |
| parent | 7d2b149206a53cb8f5bbfc7f3b70065a07faf11c (diff) | |
Merge pull request #6490 from xiaobfly/dev
fix more versions of the same vstudio in the system.
| -rw-r--r-- | xmake/modules/detect/sdks/find_vstudio.lua | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 3e687228a..bf698c1b9 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -491,15 +491,17 @@ function _find_vstudio(opt) -- find VC install path (and aux build path) using `vswhere` (for version >= 15.0) -- * 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 + local vswhere_VCAuxiliaryBuildDir = {} + local vswhere_Common7ToolsDir = {} 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") + for _, vc_path in ipairs(result:split("\n")) do + table.insert(vswhere_VCAuxiliaryBuildDir, path.join(vc_path:trim(), "VC", "Auxiliary", "Build")) + table.insert(vswhere_Common7ToolsDir, path.join(vc_path:trim(), "Common7", "Tools")) + end end end @@ -514,8 +516,13 @@ function _find_vstudio(opt) if vsenvs[version] then table.insert(paths, format("$(env %s)\\..\\..\\VC", vsenvs[version])) end - if vswhere_VCAuxiliaryBuildDir and os.isdir(vswhere_VCAuxiliaryBuildDir) then - table.insert(paths, 1, vswhere_VCAuxiliaryBuildDir) + + if vswhere_VCAuxiliaryBuildDir then + for _, vc_path in ipairs(vswhere_VCAuxiliaryBuildDir) do + if os.isdir(vc_path) then + table.insert(paths, 1, vc_path) + end + end end if version == "6.0" and os.arch() == "x64" then table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\DevStudio\\6.0\\Products\\Microsoft Visual C++;ProductDir)\\Bin") @@ -557,8 +564,12 @@ function _find_vstudio(opt) 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) + if vswhere_Common7ToolsDir then + for _, vc_path in ipairs(vswhere_Common7ToolsDir) do + if os.isdir(vc_path) then + table.insert(paths, 1, vc_path) + end + end end vcvarsall = find_file("VsDevCmd.bat", paths) end |
