Skip to content

Commit

Permalink
fix: Not a valid Win32 application
Browse files Browse the repository at this point in the history
Closes #844
  • Loading branch information
develar committed Nov 30, 2016
1 parent 6c90f30 commit 5d4b747
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,5 @@
"release": {
"verifyConditions": []
},
"typings": "./out/electron-builder.d.ts",
"publishConfig": {
"tag": "next"
}
"typings": "./out/electron-builder.d.ts"
}
2 changes: 1 addition & 1 deletion src/cli/node-gyp-rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main() {
const arch = args.arch || process.arch
log(`Execute node-gyp rebuild for arch ${arch}`)
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
env: getGypEnv(await getElectronVersion(await readPackageJson(devPackageFile), devPackageFile), arch),
env: getGypEnv(await getElectronVersion(await readPackageJson(devPackageFile), devPackageFile), arch, true),
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class Packager implements BuildInfo {
if (options.nodeGypRebuild === true) {
log(`Executing node-gyp rebuild for arch ${Arch[arch]}`)
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
env: getGypEnv(this.electronVersion, Arch[arch]),
env: getGypEnv(this.electronVersion, Arch[arch], true),
})
}

Expand Down
37 changes: 11 additions & 26 deletions src/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,30 @@ import { BuildMetadata } from "./metadata"
import { exists } from "./util/fs"

export async function installOrRebuild(options: BuildMetadata, appDir: string, electronVersion: string, arch: string, forceInstall: boolean = false) {
const args = computeExtraArgs(options)
const args = asArray(options.npmArgs)
if (forceInstall || !(await exists(path.join(appDir, "node_modules")))) {
await installDependencies(appDir, electronVersion, arch, args)
await installDependencies(appDir, electronVersion, arch, args, !options.npmSkipBuildFromSource)
}
else {
await rebuild(appDir, electronVersion, arch, args)
await rebuild(appDir, electronVersion, arch, args, !options.npmSkipBuildFromSource)
}
}

export function getGypEnv(electronVersion: string, arch: string) {
export function getGypEnv(electronVersion: string, arch: string, buildFromSource: boolean) {
const gypHome = path.join(homedir(), ".electron-gyp")
return Object.assign({}, process.env, {
npm_config_disturl: "https://atom.io/download/electron",
npm_config_target: electronVersion,
npm_config_runtime: "electron",
npm_config_arch: arch,
npm_config_target_arch: arch,
npm_config_build_from_source: buildFromSource,
HOME: gypHome,
USERPROFILE: gypHome,
})
}

function computeExtraArgs(options: BuildMetadata) {
const args = asArray(options.npmArgs)
if (options.npmSkipBuildFromSource !== true) {
args.push("--build-from-source")
}
return args
}

export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, additionalArgs: Array<string>): Promise<any> {
export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, additionalArgs: Array<string>, buildFromSource: boolean): Promise<any> {
log(`Installing app dependencies for arch ${arch} to ${appDir}`)
let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
const execArgs = ["install", "--production"]
Expand All @@ -57,15 +51,10 @@ export function installDependencies(appDir: string, electronVersion: string, arc
execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
}

for (let a of additionalArgs) {
if (!isYarn || a !== "--build-from-source") {
execArgs.push(a)
}
}

execArgs.push(...additionalArgs)
return spawn(execPath, execArgs, {
cwd: appDir,
env: getGypEnv(electronVersion, arch),
env: getGypEnv(electronVersion, arch, buildFromSource),
})
}

Expand Down Expand Up @@ -120,7 +109,7 @@ function isYarnPath(execPath: string | null) {
return execPath != null && path.basename(execPath).startsWith("yarn")
}

export async function rebuild(appDir: string, electronVersion: string, arch: string = process.arch, additionalArgs: Array<string>) {
export async function rebuild(appDir: string, electronVersion: string, arch: string = process.arch, additionalArgs: Array<string>, buildFromSource: boolean) {
const deps = new Set<string>()
await dependencies(appDir, false, deps)
const nativeDeps = await BluebirdPromise.filter(deps, it => exists(path.join(it, "binding.gyp")), {concurrency: 8})
Expand All @@ -141,13 +130,9 @@ export async function rebuild(appDir: string, electronVersion: string, arch: str
execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
}

const env = getGypEnv(electronVersion, arch)
const env = getGypEnv(electronVersion, arch, buildFromSource)
if (isYarnPath(execPath)) {
execArgs.push("run", "install", "--")
execArgs.push("--disturl=https://atom.io/download/electron")
execArgs.push(`--target=${electronVersion}`)
execArgs.push("--runtime=electron")
execArgs.push(`--arch=${arch}`)
execArgs.push(...additionalArgs)
await BluebirdPromise.each(nativeDeps, it => spawn(execPath, execArgs, {cwd: it, env: env}))
}
Expand Down

0 comments on commit 5d4b747

Please sign in to comment.