Skip to content

Commit

Permalink
fix: cross-platform build for native modules using prebuild
Browse files Browse the repository at this point in the history
The `rebuild()` method has not been passing the platform to the electron-rebuild, which meant, electron-rebuild has been using the `process.platform` no matter what platform you specify, which means no cross-platform build if an app includes native modules that include prebuilt binaries.
  • Loading branch information
cocktailpeanut committed Mar 7, 2023
1 parent c1448c6 commit 73f751b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/app-builder-lib/src/util/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function installOrRebuild(config: Configuration, appDir: string, op
}
await installDependencies(appDir, effectiveOptions)
} else {
await rebuild(appDir, config.buildDependenciesFromSource === true, options.arch)
await rebuild(appDir, config.buildDependenciesFromSource === true, options)
}
}

Expand Down Expand Up @@ -149,18 +149,19 @@ export interface RebuildOptions {
}

/** @internal */
export async function rebuild(appDir: string, buildFromSource: boolean, arch = process.arch) {
log.info({ appDir, arch }, "executing @electron/rebuild")
const options: electronRebuild.RebuildOptions = {
export async function rebuild(appDir: string, buildFromSource: boolean, options: RebuildOptions) {
log.info({ appDir, arch: options.arch, platform: options.platform }, "executing @electron/rebuild")
const effectiveOptions: electronRebuild.RebuildOptions = {
buildPath: appDir,
electronVersion: await getElectronVersion(appDir),
arch,
arch: options.arch,
platform: options.platform,
force: true,
debug: log.isDebugEnabled,
projectRootPath: await searchModule.getProjectRootPath(appDir),
}
if (buildFromSource) {
options.prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild"
effectiveOptions.prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild"
}
return electronRebuild.rebuild(options)
return electronRebuild.rebuild(effectiveOptions)
}

0 comments on commit 73f751b

Please sign in to comment.