mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-07 17:05:33 +02:00
add option to specify number of jobs for build command
This commit is contained in:
parent
fd234005ec
commit
fc713c85db
4 changed files with 23 additions and 3 deletions
12
src/cmds.ts
12
src/cmds.ts
|
@ -29,6 +29,18 @@ export const commands: Cmd[] = [
|
|||
description:
|
||||
"Doesn't check to see if all of the patches have been applied",
|
||||
},
|
||||
{
|
||||
arg: "-j, --jobs <number>",
|
||||
description:
|
||||
'Number of jobs to run in parallel. Defaults to the number of cores on your machine.',
|
||||
parse: (val: string) => {
|
||||
const parsed = parseInt(val, 10)
|
||||
if (isNaN(parsed)) {
|
||||
throw new Error('Invalid number of jobs')
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
}
|
||||
],
|
||||
requestController: async () => (await import('./commands/build')).build,
|
||||
},
|
||||
|
|
|
@ -110,7 +110,7 @@ const applyConfig = async (os: string) => {
|
|||
writeFileSync(join(ENGINE_DIR, 'browser/config/version_display.txt'), version)
|
||||
}
|
||||
|
||||
const genericBuild = async (os: string, fast = false): Promise<boolean> => {
|
||||
const genericBuild = async (os: string, fast = false, jobs: number): Promise<boolean> => {
|
||||
log.info(`Building for "${os}"...`)
|
||||
|
||||
log.warning(
|
||||
|
@ -123,6 +123,10 @@ const genericBuild = async (os: string, fast = false): Promise<boolean> => {
|
|||
buildOptions.push('faster')
|
||||
}
|
||||
|
||||
if (jobs) {
|
||||
buildOptions.push(`-j${jobs}`)
|
||||
}
|
||||
|
||||
log.debug(`Running with build options ${buildOptions.join(', ')}`)
|
||||
log.debug(`Mach exists: ${existsSync(join(ENGINE_DIR, 'mach'))}`)
|
||||
log.debug(
|
||||
|
@ -156,6 +160,7 @@ const success = (date: number) => {
|
|||
|
||||
interface Options {
|
||||
ui: boolean
|
||||
jobs: number
|
||||
skipPatchCheck: boolean
|
||||
}
|
||||
|
||||
|
@ -177,7 +182,7 @@ export const build = async (options: Options): Promise<void> => {
|
|||
|
||||
log.info('Starting build...')
|
||||
|
||||
let exit = await genericBuild(prettyHost, options.ui)
|
||||
let exit = await genericBuild(prettyHost, options.ui, options.jobs)
|
||||
process.exit(exit ? 0 : 1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,9 @@ for (const command of commands) {
|
|||
|
||||
// Register all of the required options
|
||||
for (const opt of command?.options || []) {
|
||||
buildCommand = buildCommand.option(opt.arg, opt.description)
|
||||
buildCommand = opt.parse !== undefined ?
|
||||
buildCommand.option(opt.arg, opt.description, opt.parse) :
|
||||
buildCommand.option(opt.arg, opt.description);
|
||||
}
|
||||
|
||||
buildCommand = buildCommand.action(async (...arguments_) => {
|
||||
|
|
1
src/types.d.ts
vendored
1
src/types.d.ts
vendored
|
@ -25,6 +25,7 @@ export interface Cmd {
|
|||
export interface CmdOption {
|
||||
arg: string
|
||||
description: string
|
||||
parse?: (val: string) => unknown
|
||||
}
|
||||
|
||||
export type CmdFlagPlatform = NodeJS.Platform
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue