Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/argumentBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export class ArgumentBuilder {
const defines = await this.buildDefines();
baseCommand += ` ${ defines.map(d => `-D${d[0]}="${d[1]}"`).join(" ")}`;
if (this.options.generatorToUse !== 'native') {
baseCommand += ` -G"${this.options.generatorToUse}"`;
let generatorString = ` -G"${this.options.generatorToUse}"`;
if(generatorString.match(/Visual\s+Studio\s+\d+\s+\d+\s-A/)) {
generatorString = generatorString.replace(/\s-A/, '');
generatorString += ` -A ${this.config.arch}`;
}
baseCommand += generatorString;
}
console.log(baseCommand)
return baseCommand;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export async function defaultBuildOptions(configs: BuildOptions, buildmode: Buil
let ninja: string | null;
let make: string | null;
if (configs.generatorToUse === undefined) {
console.log('no generator specified, checking ninja');
console.log('no generator specified in package.json, checking ninja');
ninja = await ninjaP;
if (!ninja) {
console.log('ninja not found, checking make');
Expand Down
23 changes: 15 additions & 8 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import splitargs from 'splitargs2';
import { PathLike, stat as rawStat, StatOptions, Stats } from 'fs-extra';

export const GET_CMAKE_VS_GENERATOR = async (cmake: string, arch: string): Promise<string> => {
const archString = arch === 'x64' ? 'Win64' : arch === "x86" ? '' : null;
if(archString === null) {
console.error('Failed to find valid VS gen, using native. Good Luck.');
return 'native';
}

const generators = await EXEC_CAPTURE(`"${cmake}" -G`);
const hasCR = generators.includes('\r\n');
const output = hasCR ? generators.split('\r\n') : generators.split('\n');
Expand All @@ -19,23 +25,24 @@ export const GET_CMAKE_VS_GENERATOR = async (cmake: string, arch: string): Promi
// Some descriptions are multi-line
continue;
}
genParts[0] = genParts[0].trim();
/**
* Current MSVS compiler selected in Windows generally is prefixed with "* "
*/
genParts[0] = genParts[0].replace(/^(\* )/, "").trim();

// eslint-disable-next-line optimize-regex/optimize-regex
if (genParts[0].match(/Visual\s+Studio\s+\d+\s+\d+\s+\[arch\]/)) {
if (genParts[0].match(/Visual\s+Studio\s+\d+\s+\d+(\s+\[arch\])?/)) {
console.log('Found generator: ', genParts[0]);
// The first entry is usually the latest entry
useVSGen = genParts[0];
break;
}
}
if (arch === 'x64') {
useVSGen = useVSGen.replace('[arch]', 'Win64').trim();
} else if (arch === 'x86') {
useVSGen = useVSGen.replace('[arch]', '').trim();
const useSwitch = !useVSGen.match(/.*\[arch\]/);
if(useSwitch) {
useVSGen += " -A" // essentially using this as a flag
} else {
console.error('Failed to find valid VS gen, using native. Good Luck.');
return 'native';
useVSGen = useVSGen.replace('[arch]', archString).trim();
}
return useVSGen;
}
Expand Down