@@ -3,6 +3,12 @@ import splitargs from 'splitargs2';
3
3
import { PathLike , stat as rawStat , StatOptions , Stats } from 'fs-extra' ;
4
4
5
5
export const GET_CMAKE_VS_GENERATOR = async ( cmake : string , arch : string ) : Promise < string > => {
6
+ const archString = arch === 'x64' ? 'Win64' : arch === "x86" ? '' : null ;
7
+ if ( archString === null ) {
8
+ console . error ( 'Failed to find valid VS gen, using native. Good Luck.' ) ;
9
+ return 'native' ;
10
+ }
11
+
6
12
const generators = await EXEC_CAPTURE ( `"${ cmake } " -G` ) ;
7
13
const hasCR = generators . includes ( '\r\n' ) ;
8
14
const output = hasCR ? generators . split ( '\r\n' ) : generators . split ( '\n' ) ;
@@ -19,23 +25,24 @@ export const GET_CMAKE_VS_GENERATOR = async (cmake: string, arch: string): Promi
19
25
// Some descriptions are multi-line
20
26
continue ;
21
27
}
22
- genParts [ 0 ] = genParts [ 0 ] . trim ( ) ;
28
+ /**
29
+ * Current MSVS compiler selected in Windows generally is prefixed with "* "
30
+ */
31
+ genParts [ 0 ] = genParts [ 0 ] . replace ( / ^ ( \* ) / , "" ) . trim ( ) ;
23
32
24
33
// eslint-disable-next-line optimize-regex/optimize-regex
25
- if ( genParts [ 0 ] . match ( / V i s u a l \s + S t u d i o \s + \d + \s + \d + \s + \[ a r c h \] / ) ) {
34
+ if ( genParts [ 0 ] . match ( / V i s u a l \s + S t u d i o \s + \d + \s + \d + ( \s + \[ a r c h \] ) ? / ) ) {
26
35
console . log ( 'Found generator: ' , genParts [ 0 ] ) ;
27
36
// The first entry is usually the latest entry
28
37
useVSGen = genParts [ 0 ] ;
29
38
break ;
30
39
}
31
40
}
32
- if ( arch === 'x64' ) {
33
- useVSGen = useVSGen . replace ( '[arch]' , 'Win64' ) . trim ( ) ;
34
- } else if ( arch === 'x86' ) {
35
- useVSGen = useVSGen . replace ( '[arch]' , '' ) . trim ( ) ;
41
+ const useSwitch = ! useVSGen . match ( / .* \[ a r c h \] / ) ;
42
+ if ( useSwitch ) {
43
+ useVSGen += " -A" // essentially using this as a flag
36
44
} else {
37
- console . error ( 'Failed to find valid VS gen, using native. Good Luck.' ) ;
38
- return 'native' ;
45
+ useVSGen = useVSGen . replace ( '[arch]' , archString ) . trim ( ) ;
39
46
}
40
47
return useVSGen ;
41
48
}
0 commit comments