@@ -280,6 +280,7 @@ $options = @{
280280 i = $false # perform install
281281 scope = ' local'
282282 aab = $false
283+ ide = $null
283284}
284285
285286$optName = $null
@@ -854,6 +855,8 @@ function fetch_pkg($url, $out = $null, $exrep = $null, $prefix = $null) {
854855# $Global:VS_INST
855856#
856857$Global :VS_INST = $null
858+ $Global :vs_full_ver = $null
859+ $Global :vs_major = $null
857860function find_vs () {
858861 if (! $Global :VS_INST ) {
859862 $VSWHERE_EXE = " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"
@@ -879,31 +882,40 @@ function find_vs() {
879882 }
880883 }
881884 $Global :VS_INST = $vs_inst_latest
885+
886+ $Global :vs_full_ver = $Global :VS_INST.installationVersion
887+ $Global :vs_major = $Global :vs_full_ver.Split (' .' )[0 ]
882888 }
883889 else {
884890 Write-Warning " Visual studio not found, your build may not work, required: $required_vs_ver "
885891 }
886892 }
887893}
888894
889- function install_msvc ($ver , $arch ) {
895+ function install_msvc ($ver , $arch , $vs_major ) {
890896
891897 $__install_code = @'
892- # install specified msvc for vs2022
898+ # install specified msvc for vs2022, vs2026
893899param(
894900 $ver = '14.39',
895901 $arch = 'x64',
896- $vs_major = 17,
897- $vs_minor_base = 9,
898- $msvc_minor_base = 39
902+ $vs_major = 17
899903)
900904
901905$msvc_minor = [int]$ver.Split('.')[1]
906+ if("$vs_major" -eq "17") {
907+ $vs_minor_base = 9
908+ $msvc_minor_base = 39
909+ }
910+ elseif("$vs_major" -eq "18") {
911+ $vs_minor_base = 0
912+ $msvc_minor_base = 45
913+ }
902914$vs_minor = $vs_minor_base + ($msvc_minor - $msvc_minor_base)
903915$vs_ver = "$vs_major.$vs_minor"
904916
905917$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
906- $vs_installs = ConvertFrom-Json "$(&$vswhere -version "$vs_major.0" -format 'json')"
918+ $vs_installs = ConvertFrom-Json "$(&$vswhere -version "$vs_major.0" -prerelease -format 'json')"
907919
908920$vs_installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
909921$vs_path = $vs_installs[0].installationPath
@@ -933,7 +945,7 @@ install_msvc_comp $mfc_comp_id
933945 $1k.println (" Installing $ver , please press YES in UAC dialog, and don't close popup install window ..." )
934946 $__install_script = [System.IO.Path ]::GetTempFileName() + ' .ps1'
935947 [System.IO.File ]::WriteAllText($__install_script , $__install_code )
936- $process = Start-Process powershell - ArgumentList " -File `"`" $__install_script `"`" -ver $ver -arch $arch " - Verb runas - PassThru - Wait
948+ $process = Start-Process powershell - ArgumentList " -File `"`" $__install_script `"`" -ver $ver -arch $arch -vs_major $vs_major " - Verb runas - PassThru - Wait
937949 $install_ret = $process.ExitCode
938950 [System.IO.File ]::Delete($__install_script )
939951
@@ -1508,6 +1520,7 @@ function setup_msvc() {
15081520 if (! $cl_prog ) {
15091521 if ($Global :VS_INST ) {
15101522 $vs_path = $Global :VS_INST.installationPath
1523+ $1k.println (" Found Visual Studio: $vs_path , version: $vs_full_ver " )
15111524 $dev_cmd_args = " -arch=$target_cpu -host_arch=x64 -no_logo"
15121525
15131526 # if explicit version specified, use it
@@ -1520,8 +1533,8 @@ function setup_msvc() {
15201533 $1k.println (' Enter vs dev shell success.' )
15211534 }
15221535 else {
1523- # vs2022 x64,x86 share same msvc component
1524- install_msvc $cl_ver $TARGET_CPU
1536+ # vs2022, vs2026: x64,x86 share same msvc component
1537+ install_msvc $cl_ver $TARGET_CPU $vs_major
15251538 $1k.println (" Enter vs dev shell ..." )
15261539 Enter-VsDevShell - VsInstanceId $Global :VS_INST.instanceId - SkipAutomaticLocation - DevCmdArguments $dev_cmd_args - ErrorAction SilentlyContinue
15271540 if ($? ) {
@@ -2262,7 +2275,16 @@ if (!$setupOnly) {
22622275 $gn_gen_args = @ (' gen' , $BUILD_DIR )
22632276 if ($Global :is_win_family ) {
22642277 $sln_name = Split-Path $ (Get-Location ).Path - Leaf
2265- $gn_gen_args += ' --ide=vs2022' , " --sln=$sln_name "
2278+ $vs_ide = $options.ide
2279+ if (! $vs_ide ) {
2280+ $MSVS_VERSIONS = @ {
2281+ ' 18' = ' 2026'
2282+ ' 17' = ' 2022'
2283+ }
2284+ $vs_year_ver = $MSVS_VERSIONS [$vs_major ]
2285+ $vs_ide = " vs$vs_year_ver "
2286+ }
2287+ $gn_gen_args += " --ide=$vs_ide " , " --sln=$sln_name "
22662288 }
22672289
22682290 if ($gn_buildargs_overrides ) {
0 commit comments