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

feat: add support for node-gyp --jobs option to parallelize an indivi… #1106

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Options:
Default is "prod,optional"
-p, --parallel Rebuild in parallel, this is enabled by default
on macOS and Linux
-j, --jobs Run make in parallel. The value max will use all available CPU cores
erickzhao marked this conversation as resolved.
Show resolved Hide resolved
-s, --sequential Rebuild modules sequentially, this is enabled by
default on Windows
-o, --only Only build specified module, or comma separated
Expand Down
2 changes: 2 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const argv = yargs(process.argv.slice(2)).version(false).options({
types: { alias: 't', type: 'string', description: 'The types of dependencies to rebuild. Comma separated list of "prod", "dev" and "optional". Default is "prod,optional"' },
parallel: { alias: 'p', type: 'boolean', description: 'Rebuild in parallel, this is enabled by default on macOS and Linux' },
sequential: { alias: 's', type: 'boolean', description: 'Rebuild modules sequentially, this is enabled by default on Windows' },
jobs: {alias: 'j', type: 'string', description: 'Run make in parallel. The value max will use all available CPU cores'},
erickzhao marked this conversation as resolved.
Show resolved Hide resolved
debug: { alias: 'b', type: 'boolean', description: 'Build debug version of modules' },
'prebuild-tag-prefix': { type: 'string', description: 'GitHub tag prefix passed to prebuild-install. Default is "v"' },
'force-abi': { type: 'number', description: 'Override the ABI version for the version of Electron you are targeting. Only use when targeting Nightly releases.' },
Expand Down Expand Up @@ -122,6 +123,7 @@ process.on('unhandledRejection', handler);
headerURL: argv.d as string,
types: argv.t ? (argv.t as string).split(',') as ModuleType[] : ['prod', 'optional'],
mode: argv.p ? 'parallel' : (argv.s ? 'sequential' : undefined),
jobs: argv.jobs as string,
debug: argv.debug,
prebuildTagPrefix: (argv.prebuildTagPrefix as string) || 'v',
forceABI: argv.forceAbi as number,
Expand Down
3 changes: 2 additions & 1 deletion src/module-type/node-gyp/node-gyp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export class NodeGyp extends NativeModule {
`--target=${this.rebuilder.electronVersion}`,
`--arch=${this.rebuilder.arch}`,
`--dist-url=${this.rebuilder.headerURL}`,
'--build-from-source'
'--build-from-source',
`--jobs=${this.rebuilder.jobs}`,
];

args.push(d.enabled ? '--verbose' : '--silent');
Expand Down
3 changes: 3 additions & 0 deletions src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface RebuildOptions {
headerURL?: string;
types?: ModuleType[];
mode?: RebuildMode;
jobs?: string;
debug?: boolean;
useCache?: boolean;
useElectronClang?: boolean;
Expand Down Expand Up @@ -54,6 +55,7 @@ export class Rebuilder implements IRebuilder {
public force: boolean;
public headerURL: string;
public mode: RebuildMode;
public jobs: string;
public debug: boolean;
public useCache: boolean;
public cachePath: string;
Expand All @@ -71,6 +73,7 @@ export class Rebuilder implements IRebuilder {
this.force = options.force || false;
this.headerURL = options.headerURL || 'https://www.electronjs.org/headers';
this.mode = options.mode || defaultMode;
this.jobs = options.jobs || '1';
this.debug = options.debug || false;
this.useCache = options.useCache || false;
this.useElectronClang = options.useElectronClang || false;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IRebuilder {
headerURL: string;
lifecycle: EventEmitter;
mode: RebuildMode;
jobs: string;
msvsVersion?: string;
platform: string;
prebuildTagPrefix: string;
Expand Down