summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-05-10 09:23:07 +0800
committerGitHub <[email protected]>2024-05-10 09:23:07 +0800
commit3a0714384a64076168984ec2bf207d2cf16b113e (patch)
tree09b012c8cbe6acdb760bf88ba7d2006d57bbe247
parentf66ae558c39dfa1411c1e1e2653b8bd4249f477d (diff)
parent183d83075a29d30acd8c27132f151c5db13bc951 (diff)
Merge pull request #5079 from xmake-io/msvc
improve msvc host #5077
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua22
1 files changed, 19 insertions, 3 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index d928fafe7..617940d67 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -118,13 +118,29 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
if vsver and tonumber(vsver) >= 16 then
file:print("set VSCMD_SKIP_SENDTELEMETRY=yes")
end
+ local host_arch = os.arch()
if is_vsdevcmd then
- if opt.vcvars_ver then
- file:print("call \"%s\" -arch=%s -winsdk=%s -vcvars_ver=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
+ if vsver and tonumber(vsver) >= 16 then
+ if opt.vcvars_ver then
+ file:print("call \"%s\" -host_arch=%s -arch=%s -winsdk=%s -vcvars_ver=%s > nul", vcvarsall, host_arch, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
+ else
+ file:print("call \"%s\" -host_arch=%s -arch=%s -winsdk=%s > nul", vcvarsall, host_arch, arch, opt.sdkver and opt.sdkver or "")
+ end
else
- file:print("call \"%s\" -arch=%s -winsdk=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "")
+ if opt.vcvars_ver then
+ file:print("call \"%s\" -arch=%s -winsdk=%s -vcvars_ver=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
+ else
+ file:print("call \"%s\" -arch=%s -winsdk=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "")
+ end
end
else
+ -- @see https://github.com/xmake-io/xmake/issues/5077
+ if vsver and tonumber(vsver) >= 16 and host_arch ~= arch then
+ if host_arch == "x64" then
+ host_arch = "amd64"
+ end
+ arch = host_arch .. "_" .. arch
+ end
if opt.vcvars_ver then
file:print("call \"%s\" %s %s -vcvars_ver=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
else