Skip to content

Commit

Permalink
feat: do not force build from sources by default
Browse files Browse the repository at this point in the history
Close #1703
  • Loading branch information
develar committed Jun 26, 2017
1 parent 50fe277 commit 86be5d7
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions docs/Multi Platform Build.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Don't expect that you can build app for all platforms on one platform.

* If your app has native dependencies, it can be compiled only on the target platform.
[prebuild](https://www.npmjs.com/package/prebuild) is a solution, but most node modules [don't provide](https://github.com/atom/node-keytar/issues/27) prebuilt binaries.
By default build from sources is forced, set [npmSkipBuildFromSource](https://github.com/electron-userland/electron-builder/wiki/Options#Config-npmSkipBuildFromSource) to `true` to use prebuild binaries (if available).
[prebuild](https://www.npmjs.com/package/prebuild) is a solution, but most node modules [don't provide](https://github.com/atom/node-keytar/issues/27) prebuilt binaries.
* macOS Code Signing works only on macOS. [Cannot be fixed](http://stackoverflow.com/a/12156576).

Don't think that mentioned issues are major, you should use build servers — e.g. [AppVeyor](http://www.appveyor.com/) to build Windows app and [Travis](https://travis-ci.org) to build MacOS/Linux apps.
Expand Down
3 changes: 2 additions & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ Configuration Options
* <a name="Config-nodeGypRebuild"></a>`nodeGypRebuild` = `false` Boolean - Whether to execute `node-gyp rebuild` before starting to package the app.
* <a name="Config-npmArgs"></a>`npmArgs` Array&lt;String&gt; | String - Additional command line arguments to use when installing app native deps.
* <a name="Config-npmRebuild"></a>`npmRebuild` = `true` Boolean - Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app.
* <a name="Config-npmSkipBuildFromSource"></a>`npmSkipBuildFromSource` = `false` Boolean - Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps.
* <a name="Config-buildDependenciesFromSource"></a>`buildDependenciesFromSource` = `false` Boolean - Whether to build the application native dependencies from source.
* <a name="Config-npmSkipBuildFromSource"></a>`npmSkipBuildFromSource` Boolean - Deprecated: {tag.description}
* <a name="Config-publish"></a>`publish` String | [GithubOptions](Publishing-Artifacts#GithubOptions) | [S3Options](Publishing-Artifacts#S3Options) | [GenericServerOptions](Publishing-Artifacts#GenericServerOptions) | [BintrayOptions](Publishing-Artifacts#BintrayOptions) | Array - The [publish configuration](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#publish-options). Order is important — first item will be used as a default auto-update server.

If `GH_TOKEN` is set — defaults to `[{provider: "github"}]`.
Expand Down
7 changes: 6 additions & 1 deletion packages/electron-builder/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,14 @@ export interface Config extends PlatformSpecificBuildOptions {
readonly npmRebuild?: boolean

/**
* Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps.
* Whether to build the application native dependencies from source.
* @default false
*/
buildDependenciesFromSource?: boolean

/**
* @deprecated Please use npmBuildFromSource.
*/
readonly npmSkipBuildFromSource?: boolean

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/electron-builder/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,20 @@ export class Packager implements BuildInfo {
}

const frameworkInfo = {version: this.config.muonVersion || this.config.electronVersion!, useCustomDist: this.config.muonVersion == null}
const options = this.config
if (options.nodeGypRebuild === true) {
const config = this.config
if (config.nodeGypRebuild === true) {
log(`Executing node-gyp rebuild for arch ${Arch[arch]}`)
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
env: getGypEnv(frameworkInfo, platform.nodeName, Arch[arch], true),
})
}

if (options.npmRebuild === false) {
if (config.npmRebuild === false) {
log("Skip app dependencies rebuild because npmRebuild is set to false")
return
}

const beforeBuild = options.beforeBuild
const beforeBuild = config.beforeBuild
if (beforeBuild != null) {
const performDependenciesInstallOrRebuild = await beforeBuild({
appDir: this.appDir,
Expand All @@ -307,11 +307,11 @@ export class Packager implements BuildInfo {
if (!performDependenciesInstallOrRebuild) return
}

if (options.npmSkipBuildFromSource !== true && platform.nodeName !== process.platform) {
log("Skip app dependencies rebuild because platform is different")
if (config.buildDependenciesFromSource === true && platform.nodeName !== process.platform) {
log("Skip app dependencies rebuild because platform is different and buildDependenciesFromSource is set to true")
}
else {
await installOrRebuild(options, this.appDir, frameworkInfo, platform.nodeName, Arch[arch])
await installOrRebuild(config, this.appDir, frameworkInfo, platform.nodeName, Arch[arch])
}
}

Expand Down
5 changes: 5 additions & 0 deletions packages/electron-builder/src/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export async function validateConfig(config: Config) {
}
}

// noinspection JSDeprecatedSymbols
if (config.npmSkipBuildFromSource === false) {
config.buildDependenciesFromSource = false
}

if (validatorPromise == null) {
validatorPromise = createConfigValidator()
}
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/util/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { readInstalled } from "./packageDependencies"
export async function installOrRebuild(config: Config, appDir: string, frameworkInfo: DesktopFrameworkInfo, platform: string, arch: string, forceInstall: boolean = false) {
const args = asArray(config.npmArgs)
if (forceInstall || !(await exists(path.join(appDir, "node_modules")))) {
await installDependencies(appDir, frameworkInfo, platform, arch, args, !config.npmSkipBuildFromSource)
await installDependencies(appDir, frameworkInfo, platform, arch, args, config.buildDependenciesFromSource === true)
}
else {
await rebuild(appDir, frameworkInfo, platform, arch, args, !config.npmSkipBuildFromSource)
await rebuild(appDir, frameworkInfo, platform, arch, args, config.buildDependenciesFromSource === true)
}
}

Expand Down
76 changes: 46 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.31.tgz#54aeb8bcaaf94a7b1a64311bc318dbfe601a593a"

"@types/node@*":
version "8.0.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.2.tgz#8ab9456efb87d57f11d04f313d3da1041948fb4d"
version "8.0.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.3.tgz#fca61c26f83e5f453166114f57d53a47feb36d45"

"@types/source-map-support@^0.4.0":
version "0.4.0"
Expand Down Expand Up @@ -130,6 +130,10 @@ ansi-regex@^2.0.0, ansi-regex@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"

ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"

ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
Expand Down Expand Up @@ -209,6 +213,12 @@ array-back@^1.0.2, array-back@^1.0.3, array-back@^1.0.4:
dependencies:
typical "^2.6.0"

array-back@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/array-back/-/array-back-2.0.0.tgz#6877471d51ecc9c9bfa6136fb6c7d5fe69748022"
dependencies:
typical "^2.6.1"

array-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
Expand Down Expand Up @@ -252,8 +262,8 @@ async@^1.4.0:
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

async@^2.0.0, async@^2.1.4:
version "2.4.1"
resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7"
version "2.5.0"
resolved "https://registry.yarnpkg.com/async/-/async-2.5.0.tgz#843190fd6b7357a0b9e1c956edddd5ec8462b54d"
dependencies:
lodash "^4.14.0"

Expand Down Expand Up @@ -520,22 +530,18 @@ babel-types@^6.18.0, babel-types@^6.24.1, babel-types@^6.25.0:
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babylon@^6.1.21, babylon@^6.13.0, babylon@^6.17.2:
babylon@^6.1.21, babylon@^6.17.2, babylon@^6.17.4:
version "6.17.4"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a"

balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"

[email protected]:
[email protected], base64-js@^1.0.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1"

base64-js@^1.0.2:
version "1.2.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"

bcrypt-pbkdf@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d"
Expand Down Expand Up @@ -1693,14 +1699,14 @@ isstream@~0.1.2:
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"

istanbul-api@^1.1.1:
version "1.1.9"
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.9.tgz#2827920d380d4286d857d57a2968a841db8a7ec8"
version "1.1.10"
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.10.tgz#f27e5e7125c8de13f6a80661af78f512e5439b2b"
dependencies:
async "^2.1.4"
fileset "^2.0.2"
istanbul-lib-coverage "^1.1.1"
istanbul-lib-hook "^1.0.7"
istanbul-lib-instrument "^1.7.2"
istanbul-lib-instrument "^1.7.3"
istanbul-lib-report "^1.1.1"
istanbul-lib-source-maps "^1.2.1"
istanbul-reports "^1.1.1"
Expand All @@ -1718,15 +1724,15 @@ istanbul-lib-hook@^1.0.7:
dependencies:
append-transform "^0.4.0"

istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.2.tgz#6014b03d3470fb77638d5802508c255c06312e56"
istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.2, istanbul-lib-instrument@^1.7.3:
version "1.7.3"
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.3.tgz#925b239163eabdd68cc4048f52c2fa4f899ecfa7"
dependencies:
babel-generator "^6.18.0"
babel-template "^6.16.0"
babel-traverse "^6.18.0"
babel-types "^6.18.0"
babylon "^6.13.0"
babylon "^6.17.4"
istanbul-lib-coverage "^1.1.1"
semver "^5.3.0"

Expand Down Expand Up @@ -2344,7 +2350,7 @@ minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

mkdirp2@^1.0.2:
mkdirp2@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.3.tgz#cc8dd8265f1f06e2d8f5b10b6e52f4e050bed21b"

Expand Down Expand Up @@ -2850,7 +2856,7 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"

req-then@^0.6.1:
req-then@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/req-then/-/req-then-0.6.2.tgz#7f9e6ebbcab327adc9280aa92b3698d3fc1c5b0d"
dependencies:
Expand Down Expand Up @@ -3102,11 +3108,11 @@ string-width@^1.0.1, string-width@^1.0.2:
strip-ansi "^3.0.0"

string-width@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e"
version "2.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.0.tgz#030664561fc146c9423ec7d978fe2457437fe6d0"
dependencies:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^3.0.0"
strip-ansi "^4.0.0"

string.prototype.codepointat@^0.2.0:
version "0.2.0"
Expand All @@ -3132,6 +3138,12 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1:
dependencies:
ansi-regex "^2.0.0"

strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
dependencies:
ansi-regex "^3.0.0"

[email protected], strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
Expand Down Expand Up @@ -3459,15 +3471,15 @@ [email protected]:
querystring "0.2.0"

usage-stats@^0.9.0:
version "0.9.1"
resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.1.tgz#3b34997dbef1e151f48a118a93a5c595e1d4269a"
version "0.9.3"
resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.3.tgz#6c906491becb9b4e8659f2e0d27f337fcf8f087e"
dependencies:
array-back "^1.0.4"
array-back "^2.0.0"
home-path "^1.0.5"
mkdirp2 "^1.0.2"
req-then "^0.6.1"
typical "^2.6.0"
uuid "^3.0.1"
mkdirp2 "^1.0.3"
req-then "^0.6.2"
typical "^2.6.1"
uuid "^3.1.0"

utf8-byte-length@^1.0.1:
version "1.0.4"
Expand All @@ -3483,14 +3495,18 @@ uuid-1345@^0.99.6:
dependencies:
macaddress "^0.2.7"

[email protected], uuid@^3.0.0, uuid@^3.0.1:
[email protected], uuid@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"

uuid@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a"

uuid@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"

validate-npm-package-license@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"
Expand Down

0 comments on commit 86be5d7

Please sign in to comment.