From 5d4b747866c639a9cc54d20be9277a551e045153 Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 30 Nov 2016 10:34:54 +0100 Subject: [PATCH] fix: Not a valid Win32 application Closes #844 --- package.json | 5 +---- src/cli/node-gyp-rebuild.ts | 2 +- src/packager.ts | 2 +- src/yarn.ts | 37 +++++++++++-------------------------- 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 0c347302839..e2dc77bc5ae 100644 --- a/package.json +++ b/package.json @@ -182,8 +182,5 @@ "release": { "verifyConditions": [] }, - "typings": "./out/electron-builder.d.ts", - "publishConfig": { - "tag": "next" - } + "typings": "./out/electron-builder.d.ts" } diff --git a/src/cli/node-gyp-rebuild.ts b/src/cli/node-gyp-rebuild.ts index 7640db6aa53..32ef496f74b 100644 --- a/src/cli/node-gyp-rebuild.ts +++ b/src/cli/node-gyp-rebuild.ts @@ -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), }) } diff --git a/src/packager.ts b/src/packager.ts index 57ed2e3173b..9f213a34f98 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -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), }) } diff --git a/src/yarn.ts b/src/yarn.ts index 00a50d572a3..8675dd358db 100644 --- a/src/yarn.ts +++ b/src/yarn.ts @@ -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): Promise { +export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, additionalArgs: Array, buildFromSource: boolean): Promise { log(`Installing app dependencies for arch ${arch} to ${appDir}`) let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS const execArgs = ["install", "--production"] @@ -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), }) } @@ -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) { +export async function rebuild(appDir: string, electronVersion: string, arch: string = process.arch, additionalArgs: Array, buildFromSource: boolean) { const deps = new Set() await dependencies(appDir, false, deps) const nativeDeps = await BluebirdPromise.filter(deps, it => exists(path.join(it, "binding.gyp")), {concurrency: 8}) @@ -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})) }