Skip to content

Commit 4b3b009

Browse files
Blackhextargos
authored andcommitted
build: fix Visual Studio installation detection for Arm64
PR-URL: #46420 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent ecce647 commit 4b3b009

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

tools/msvs/vswhere_usability_wrapper.cmd

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55

66
@if not defined DEBUG_HELPER @ECHO OFF
77
setlocal
8-
if "%~2"=="prerelease" set VSWHERE_WITH_PRERELEASE=1
8+
if "%~3"=="prerelease" set VSWHERE_WITH_PRERELEASE=1
99
set "InstallerPath=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
1010
if not exist "%InstallerPath%" set "InstallerPath=%ProgramFiles%\Microsoft Visual Studio\Installer"
1111
if not exist "%InstallerPath%" goto :no-vswhere
1212
:: Manipulate %Path% for easier " handeling
1313
set "Path=%Path%;%InstallerPath%"
1414
where vswhere 2> nul > nul
1515
if errorlevel 1 goto :no-vswhere
16-
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
16+
if "%2"=="arm64" (
17+
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.ARM64
18+
) else (
19+
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
20+
)
1721
set VSWHERE_PRP=-property installationPath
1822
set VSWHERE_LMT=-version %1
1923
vswhere -prerelease > nul

vcbuild.bat

+5-5
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ if defined noprojgen if defined nobuild goto :after-build
242242
set msvs_host_arch=x86
243243
if _%PROCESSOR_ARCHITECTURE%_==_AMD64_ set msvs_host_arch=amd64
244244
if _%PROCESSOR_ARCHITEW6432%_==_AMD64_ set msvs_host_arch=amd64
245+
if _%PROCESSOR_ARCHITECTURE%_==_ARM64_ set msvs_host_arch=arm64
245246
@rem usually vcvarsall takes an argument: host + '_' + target
246247
set vcvarsall_arg=%msvs_host_arch%_%target_arch%
247-
@rem unless both host and target are x64
248+
@rem unless both the host and the target are the same
248249
if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
249-
@rem also if both are x86
250-
if %target_arch%==x86 if %msvs_host_arch%==x86 set vcvarsall_arg=x86
250+
if %target_arch%==%msvs_host_arch% set vcvarsall_arg=%target_arch%
251251

252252
@rem Look for Visual Studio 2022
253253
:vs-set-2022
@@ -257,7 +257,7 @@ echo Looking for Visual Studio 2022
257257
@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
258258
@rem detect the version searched for
259259
if not defined target_env set "VCINSTALLDIR="
260-
call tools\msvs\vswhere_usability_wrapper.cmd "[17.0,18.0)" "prerelease"
260+
call tools\msvs\vswhere_usability_wrapper.cmd "[17.0,18.0)" %target_arch% "prerelease"
261261
if "_%VCINSTALLDIR%_" == "__" goto vs-set-2019
262262
set "WIXSDKDIR=%WIX%\SDK\VS2017"
263263
if defined msi (
@@ -297,7 +297,7 @@ echo Looking for Visual Studio 2019
297297
@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
298298
@rem detect the version searched for
299299
if not defined target_env set "VCINSTALLDIR="
300-
call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)" "prerelease"
300+
call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)" %target_arch% "prerelease"
301301
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
302302
set "WIXSDKDIR=%WIX%\SDK\VS2017"
303303
if defined msi (

0 commit comments

Comments
 (0)