@@ -434,9 +434,9 @@ export function vsDisplayName(inst: VSInstallation): string {
434
434
*
435
435
* @param inst The VSInstallation to use
436
436
* @param hostArch The architecture of the toolset host (e.g. x86, x64|amd64)
437
- * @param targetArch The architecture of the toolset target (e.g. x86, x64|amd64, arm, arm64)
437
+ * @param targetArch The architecture of the toolset target (e.g. win32| x86, x64|amd64, arm, arm64)
438
438
*/
439
- function kitName ( inst : VSInstallation , hostArch : string , targetArch ?: string ) : string {
439
+ function vsKitName ( inst : VSInstallation , hostArch : string , targetArch ?: string ) : string {
440
440
// We still keep the amd64 alias for x64, only in the name of the detected VS kits,
441
441
// for compatibility reasons. Switching to 'x64' means leaving
442
442
// orphaned 'amd64' kits around ("Scan for kits" does not delete them yet)
@@ -467,10 +467,20 @@ function kitHostTargetArch(hostArch: string, targetArch?: string, amd64Alias: bo
467
467
}
468
468
}
469
469
470
- if ( targetArch ) {
471
- return hostArch === targetArch ? hostArch : ` ${ hostArch } _ ${ targetArch } ` ;
470
+ if ( ! targetArch ) {
471
+ targetArch = hostArch ;
472
472
}
473
- return hostArch ;
473
+
474
+ // CMake preferred generator platform requires 'win32', while vcvars are still using 'x86'.
475
+ // This function is called only for VS generators, so it is safe to overwrite
476
+ // targetArch with the vcvars naming.
477
+ // In case of any future new mismatches, use the vsArchFromGeneratorPlatform table
478
+ // instead of hard coding for win32 and x86.
479
+ // Currently, there is no need of a similar overwrite operation on hostArch,
480
+ // because CMake host target does not have the same name mismatch with VS.
481
+ targetArch = vsArchFromGeneratorPlatform [ targetArch ] || targetArch ;
482
+
483
+ return ( hostArch === targetArch ) ? hostArch : `${ hostArch } _${ targetArch } ` ;
474
484
}
475
485
476
486
/**
@@ -626,10 +636,15 @@ export async function getShellScriptEnvironment(kit: Kit): Promise<Map<string, s
626
636
* Currently, there is a mismatch only between x86 and win32.
627
637
* For example, VS kits x86 and amd64_x86 will generate -A win32
628
638
*/
629
- const genPlatformFromVsHostTargetArchs : { [ key : string ] : string } = {
639
+ const generatorPlatformFromVSArch : { [ key : string ] : string } = {
630
640
x86 : 'win32'
631
641
} ;
632
642
643
+ // The reverse of generatorPlatformFromVSArch
644
+ const vsArchFromGeneratorPlatform : { [ key : string ] : string } = {
645
+ win32 : 'x86'
646
+ } ;
647
+
633
648
/**
634
649
* Preferred CMake VS generators by VS version
635
650
*/
@@ -707,10 +722,11 @@ async function varsForVSInstallation(inst: VSInstallation, hostArch: string, tar
707
722
/**
708
723
* Try to get a VSKit from a VS installation and architecture
709
724
* @param inst A VS installation from vswhere
710
- * @param hostTargetArch The host-target architecture combination to try
725
+ * @param hostArch The host architecture
726
+ * @param targetArch The target architecture
711
727
*/
712
728
async function tryCreateNewVCEnvironment ( inst : VSInstallation , hostArch : string , targetArch : string , pr ?: ProgressReporter ) : Promise < Kit | null > {
713
- const name = kitName ( inst , hostArch , targetArch ) ;
729
+ const name = vsKitName ( inst , hostArch , targetArch ) ;
714
730
log . debug ( localize ( 'checking.for.kit' , 'Checking for kit: {0}' , name ) ) ;
715
731
if ( pr ) {
716
732
pr . report ( { message : localize ( 'checking' , 'Checking {0}' , name ) } ) ;
@@ -737,7 +753,7 @@ async function tryCreateNewVCEnvironment(inst: VSInstallation, hostArch: string,
737
753
log . debug ( ` ${ localize ( 'generator.present' , 'Generator Present: {0}' , generatorName ) } ` ) ;
738
754
kit . preferredGenerator = {
739
755
name : generatorName ,
740
- platform : genPlatformFromVsHostTargetArchs [ targetArch ] as string || targetArch ,
756
+ platform : generatorPlatformFromVSArch [ targetArch ] as string || targetArch ,
741
757
// CMake generator toolsets support also different versions (via -T version=).
742
758
toolset : "host=" + hostArch
743
759
} ;
0 commit comments