Skip to content

Commit 86be5d7

Browse files
committed
feat: do not force build from sources by default
Close #1703
1 parent 50fe277 commit 86be5d7

File tree

8 files changed

+71
-43
lines changed

8 files changed

+71
-43
lines changed

.idea/dictionaries/develar.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Multi Platform Build.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Don't expect that you can build app for all platforms on one platform.
22

33
* If your app has native dependencies, it can be compiled only on the target platform.
4-
[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.
5-
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).
4+
[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.
65
* macOS Code Signing works only on macOS. [Cannot be fixed](http://stackoverflow.com/a/12156576).
76

87
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.

docs/Options.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ Configuration Options
179179
* <a name="Config-nodeGypRebuild"></a>`nodeGypRebuild` = `false` Boolean - Whether to execute `node-gyp rebuild` before starting to package the app.
180180
* <a name="Config-npmArgs"></a>`npmArgs` Array&lt;String&gt; | String - Additional command line arguments to use when installing app native deps.
181181
* <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.
182-
* <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.
182+
* <a name="Config-buildDependenciesFromSource"></a>`buildDependenciesFromSource` = `false` Boolean - Whether to build the application native dependencies from source.
183+
* <a name="Config-npmSkipBuildFromSource"></a>`npmSkipBuildFromSource` Boolean - Deprecated: {tag.description}
183184
* <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.
184185

185186
If `GH_TOKEN` is set — defaults to `[{provider: "github"}]`.

packages/electron-builder/src/metadata.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,14 @@ export interface Config extends PlatformSpecificBuildOptions {
225225
readonly npmRebuild?: boolean
226226

227227
/**
228-
* Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps.
228+
* Whether to build the application native dependencies from source.
229229
* @default false
230230
*/
231+
buildDependenciesFromSource?: boolean
232+
233+
/**
234+
* @deprecated Please use npmBuildFromSource.
235+
*/
231236
readonly npmSkipBuildFromSource?: boolean
232237

233238
/**

packages/electron-builder/src/packager.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,20 @@ export class Packager implements BuildInfo {
283283
}
284284

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

294-
if (options.npmRebuild === false) {
294+
if (config.npmRebuild === false) {
295295
log("Skip app dependencies rebuild because npmRebuild is set to false")
296296
return
297297
}
298298

299-
const beforeBuild = options.beforeBuild
299+
const beforeBuild = config.beforeBuild
300300
if (beforeBuild != null) {
301301
const performDependenciesInstallOrRebuild = await beforeBuild({
302302
appDir: this.appDir,
@@ -307,11 +307,11 @@ export class Packager implements BuildInfo {
307307
if (!performDependenciesInstallOrRebuild) return
308308
}
309309

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

packages/electron-builder/src/util/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ export async function validateConfig(config: Config) {
168168
}
169169
}
170170

171+
// noinspection JSDeprecatedSymbols
172+
if (config.npmSkipBuildFromSource === false) {
173+
config.buildDependenciesFromSource = false
174+
}
175+
171176
if (validatorPromise == null) {
172177
validatorPromise = createConfigValidator()
173178
}

packages/electron-builder/src/util/yarn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { readInstalled } from "./packageDependencies"
1010
export async function installOrRebuild(config: Config, appDir: string, frameworkInfo: DesktopFrameworkInfo, platform: string, arch: string, forceInstall: boolean = false) {
1111
const args = asArray(config.npmArgs)
1212
if (forceInstall || !(await exists(path.join(appDir, "node_modules")))) {
13-
await installDependencies(appDir, frameworkInfo, platform, arch, args, !config.npmSkipBuildFromSource)
13+
await installDependencies(appDir, frameworkInfo, platform, arch, args, config.buildDependenciesFromSource === true)
1414
}
1515
else {
16-
await rebuild(appDir, frameworkInfo, platform, arch, args, !config.npmSkipBuildFromSource)
16+
await rebuild(appDir, frameworkInfo, platform, arch, args, config.buildDependenciesFromSource === true)
1717
}
1818
}
1919

yarn.lock

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.31.tgz#54aeb8bcaaf94a7b1a64311bc318dbfe601a593a"
3636

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

4141
"@types/source-map-support@^0.4.0":
4242
version "0.4.0"
@@ -130,6 +130,10 @@ ansi-regex@^2.0.0, ansi-regex@^2.1.1:
130130
version "2.1.1"
131131
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
132132

133+
ansi-regex@^3.0.0:
134+
version "3.0.0"
135+
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
136+
133137
ansi-styles@^2.2.1:
134138
version "2.2.1"
135139
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
@@ -209,6 +213,12 @@ array-back@^1.0.2, array-back@^1.0.3, array-back@^1.0.4:
209213
dependencies:
210214
typical "^2.6.0"
211215

216+
array-back@^2.0.0:
217+
version "2.0.0"
218+
resolved "https://registry.yarnpkg.com/array-back/-/array-back-2.0.0.tgz#6877471d51ecc9c9bfa6136fb6c7d5fe69748022"
219+
dependencies:
220+
typical "^2.6.1"
221+
212222
array-equal@^1.0.0:
213223
version "1.0.0"
214224
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
@@ -252,8 +262,8 @@ async@^1.4.0:
252262
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
253263

254264
async@^2.0.0, async@^2.1.4:
255-
version "2.4.1"
256-
resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7"
265+
version "2.5.0"
266+
resolved "https://registry.yarnpkg.com/async/-/async-2.5.0.tgz#843190fd6b7357a0b9e1c956edddd5ec8462b54d"
257267
dependencies:
258268
lodash "^4.14.0"
259269

@@ -520,22 +530,18 @@ babel-types@^6.18.0, babel-types@^6.24.1, babel-types@^6.25.0:
520530
lodash "^4.2.0"
521531
to-fast-properties "^1.0.1"
522532

523-
babylon@^6.1.21, babylon@^6.13.0, babylon@^6.17.2:
533+
babylon@^6.1.21, babylon@^6.17.2, babylon@^6.17.4:
524534
version "6.17.4"
525535
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a"
526536

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

531-
base64-js@1.2.0:
541+
base64-js@1.2.0, base64-js@^1.0.2:
532542
version "1.2.0"
533543
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1"
534544

535-
base64-js@^1.0.2:
536-
version "1.2.1"
537-
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"
538-
539545
bcrypt-pbkdf@^1.0.0:
540546
version "1.0.1"
541547
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d"
@@ -1693,14 +1699,14 @@ isstream@~0.1.2:
16931699
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
16941700

16951701
istanbul-api@^1.1.1:
1696-
version "1.1.9"
1697-
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.9.tgz#2827920d380d4286d857d57a2968a841db8a7ec8"
1702+
version "1.1.10"
1703+
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.10.tgz#f27e5e7125c8de13f6a80661af78f512e5439b2b"
16981704
dependencies:
16991705
async "^2.1.4"
17001706
fileset "^2.0.2"
17011707
istanbul-lib-coverage "^1.1.1"
17021708
istanbul-lib-hook "^1.0.7"
1703-
istanbul-lib-instrument "^1.7.2"
1709+
istanbul-lib-instrument "^1.7.3"
17041710
istanbul-lib-report "^1.1.1"
17051711
istanbul-lib-source-maps "^1.2.1"
17061712
istanbul-reports "^1.1.1"
@@ -1718,15 +1724,15 @@ istanbul-lib-hook@^1.0.7:
17181724
dependencies:
17191725
append-transform "^0.4.0"
17201726

1721-
istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.2:
1722-
version "1.7.2"
1723-
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.2.tgz#6014b03d3470fb77638d5802508c255c06312e56"
1727+
istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.2, istanbul-lib-instrument@^1.7.3:
1728+
version "1.7.3"
1729+
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.3.tgz#925b239163eabdd68cc4048f52c2fa4f899ecfa7"
17241730
dependencies:
17251731
babel-generator "^6.18.0"
17261732
babel-template "^6.16.0"
17271733
babel-traverse "^6.18.0"
17281734
babel-types "^6.18.0"
1729-
babylon "^6.13.0"
1735+
babylon "^6.17.4"
17301736
istanbul-lib-coverage "^1.1.1"
17311737
semver "^5.3.0"
17321738

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

2347-
mkdirp2@^1.0.2:
2353+
mkdirp2@^1.0.3:
23482354
version "1.0.3"
23492355
resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.3.tgz#cc8dd8265f1f06e2d8f5b10b6e52f4e050bed21b"
23502356

@@ -2850,7 +2856,7 @@ repeating@^2.0.0:
28502856
dependencies:
28512857
is-finite "^1.0.0"
28522858

2853-
req-then@^0.6.1:
2859+
req-then@^0.6.2:
28542860
version "0.6.2"
28552861
resolved "https://registry.yarnpkg.com/req-then/-/req-then-0.6.2.tgz#7f9e6ebbcab327adc9280aa92b3698d3fc1c5b0d"
28562862
dependencies:
@@ -3102,11 +3108,11 @@ string-width@^1.0.1, string-width@^1.0.2:
31023108
strip-ansi "^3.0.0"
31033109

31043110
string-width@^2.0.0:
3105-
version "2.0.0"
3106-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e"
3111+
version "2.1.0"
3112+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.0.tgz#030664561fc146c9423ec7d978fe2457437fe6d0"
31073113
dependencies:
31083114
is-fullwidth-code-point "^2.0.0"
3109-
strip-ansi "^3.0.0"
3115+
strip-ansi "^4.0.0"
31103116

31113117
string.prototype.codepointat@^0.2.0:
31123118
version "0.2.0"
@@ -3132,6 +3138,12 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1:
31323138
dependencies:
31333139
ansi-regex "^2.0.0"
31343140

3141+
strip-ansi@^4.0.0:
3142+
version "4.0.0"
3143+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
3144+
dependencies:
3145+
ansi-regex "^3.0.0"
3146+
31353147
strip-bom@3.0.0, strip-bom@^3.0.0:
31363148
version "3.0.0"
31373149
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
@@ -3459,15 +3471,15 @@ url@0.10.3:
34593471
querystring "0.2.0"
34603472

34613473
usage-stats@^0.9.0:
3462-
version "0.9.1"
3463-
resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.1.tgz#3b34997dbef1e151f48a118a93a5c595e1d4269a"
3474+
version "0.9.3"
3475+
resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.3.tgz#6c906491becb9b4e8659f2e0d27f337fcf8f087e"
34643476
dependencies:
3465-
array-back "^1.0.4"
3477+
array-back "^2.0.0"
34663478
home-path "^1.0.5"
3467-
mkdirp2 "^1.0.2"
3468-
req-then "^0.6.1"
3469-
typical "^2.6.0"
3470-
uuid "^3.0.1"
3479+
mkdirp2 "^1.0.3"
3480+
req-then "^0.6.2"
3481+
typical "^2.6.1"
3482+
uuid "^3.1.0"
34713483

34723484
utf8-byte-length@^1.0.1:
34733485
version "1.0.4"
@@ -3483,14 +3495,18 @@ uuid-1345@^0.99.6:
34833495
dependencies:
34843496
macaddress "^0.2.7"
34853497

3486-
uuid@3.0.1, uuid@^3.0.0, uuid@^3.0.1:
3498+
uuid@3.0.1, uuid@^3.0.0:
34873499
version "3.0.1"
34883500
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"
34893501

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

3506+
uuid@^3.1.0:
3507+
version "3.1.0"
3508+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
3509+
34943510
validate-npm-package-license@^3.0.1:
34953511
version "3.0.1"
34963512
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"

0 commit comments

Comments
 (0)