From 5699981509737cef679890125c84d48405496118 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 10 May 2024 00:48:48 +0800 Subject: improve msvc host #5077 --- xmake/modules/detect/sdks/find_vstudio.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index d928fafe7..ad1d933a0 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -118,13 +118,21 @@ 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) + 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\" -arch=%s -winsdk=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "") + file:print("call \"%s\" -host_arch=%s -arch=%s -winsdk=%s > nul", vcvarsall, host_arch, arch, opt.sdkver and opt.sdkver or "") end else + -- @see https://github.com/xmake-io/xmake/issues/5077 + if 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 -- cgit v1.3.1 From 183d83075a29d30acd8c27132f151c5db13bc951 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 10 May 2024 22:29:55 +0800 Subject: improve host arch for msvc --- xmake/modules/detect/sdks/find_vstudio.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index ad1d933a0..617940d67 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -120,14 +120,22 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt) end local host_arch = os.arch() if is_vsdevcmd 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) + 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\" -host_arch=%s -arch=%s -winsdk=%s > nul", vcvarsall, host_arch, 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 host_arch ~= arch then + if vsver and tonumber(vsver) >= 16 and host_arch ~= arch then if host_arch == "x64" then host_arch = "amd64" end -- cgit v1.3.1