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

Update Electron Libs Mirror #3

Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aminya/cmake-ts",
"version": "0.3.0-aminya.7",
"version": "0.4.1-aminya.1",
"description": "cmake-js rewrite in typescript to support advanced build configurations",
"main": "build/lib.js",
"bin": "build/main.js",
Expand Down
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
2 changes: 1 addition & 1 deletion src/urlRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import os from 'os';

const NODE_MIRROR = process.env.NVM_NODEJS_ORG_MIRROR || "https://nodejs.org/dist";
const IOJS_MIRROR = process.env.NVM_IOJS_ORG_MIRROR || "https://iojs.org/dist";
const ELECTRON_MIRROR = process.env.ELECTRON_MIRROR || "https://atom.io/download/atom-shell";
const ELECTRON_MIRROR = process.env.ELECTRON_MIRROR || "https://artifacts.electronjs.org/headers/dist";

export const HOME_DIRECTORY = process.env[(os.platform() === "win32") ? "USERPROFILE" : "HOME"] as string;

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