This commit is contained in:
Slowlife 2025-03-30 03:00:45 +00:00 committed by GitHub
commit 29bb45b9e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 3 deletions

View file

@ -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',
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,
},

View file

@ -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)
}
}

View file

@ -108,7 +108,10 @@ 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
View file

@ -25,6 +25,7 @@ export interface Cmd {
export interface CmdOption {
arg: string
description: string
parse?: (val: string) => unknown
}
export type CmdFlagPlatform = NodeJS.Platform