Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix VS CMake generator finder #30

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
61fd23d
chore: publish as @aminya/cmake-ts
aminya Oct 23, 2024
953d447
fix: replace deprecated zlib with minizlib
aminya Oct 23, 2024
8613514
chore(release): 0.3.0-aminya.2
aminya Oct 23, 2024
a63e502
fix: replace queueable with simple Promise
aminya Oct 23, 2024
9f0a65f
chore(release): 0.3.0-aminya.3
aminya Oct 23, 2024
dca7601
fix: allow redirects when requesting
aminya Oct 23, 2024
2f7f44a
chore(release): 0.3.0-aminya.4
aminya Oct 23, 2024
5489bdc
fix: downgarde to which 2 for node 10 support
aminya Oct 23, 2024
daaf939
chore(release): 0.3.0-aminya.5
aminya Oct 23, 2024
64a0498
fix: downgrade tar, npmlog, minizlib for Node 10 support
aminya Oct 23, 2024
bedf16f
chore(release): 0.3.0-aminya.6
aminya Oct 23, 2024
a663112
fix: downgrade fs-extra for node 10 support
aminya Oct 23, 2024
ddd5ae0
chore(release): 0.3.0-aminya.7
aminya Oct 23, 2024
45397a8
Fixed some bugs with getting VS generator from `cmake -G`
diefbell-grabcad Nov 19, 2024
e7e2f72
Bumped version number
diefbell-grabcad Nov 19, 2024
cd860a9
Won't add `-A arch` argument to non-Visual Studio generators
diefbell-grabcad Nov 19, 2024
3b8eeb0
Fixed condition I promise this time
diefbell-grabcad Nov 19, 2024
c144d18
Haven't broken older x86 builds I hope
diefbell-grabcad Nov 19, 2024
1f9c204
fix: fix VS CMake generator finder
diefbell-grabcad Nov 19, 2024
e15b1d4
Merge branch 'fix-vs-generator-finder' of https://github.com/diefbell…
diefbell-grabcad Nov 26, 2024
e9e8faf
Reverted version in package.json
diefbell-grabcad Nov 27, 2024
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
21 changes: 13 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,22 @@ export const GET_CMAKE_VS_GENERATOR = async (cmake: string, arch: string): Promi
// Some descriptions are multi-line
continue;
}
genParts[0] = genParts[0].trim();
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