Skip to content

Commit

Permalink
Leeloo Dallas Multiarch, resolves #1424
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed Oct 6, 2020
1 parent 8248f85 commit edceb6f
Show file tree
Hide file tree
Showing 7 changed files with 923 additions and 694 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ install:
- npm prune
script:
- npm run lint
- '[ "$TRAVIS_OS_NAME" == "linux" ] || npm run dist:mac'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || npm run dist:linux:deb'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || npm run dist:linux:appimage'
- '[ "$TRAVIS_OS_NAME" == "linux" ] || ./build.js -o darwin -p dmg -a x64'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || ./build.js -o linux -p deb -a arm64'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || ./build.js -o linux -p AppImage -a arm64'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || ./build.js -o linux -p deb -a x64'
- '[ "$TRAVIS_OS_NAME" == "osx" ] || ./build.js -o linux -p AppImage -a x64'
deploy:
provider: releases
api_key:
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ Before filing a PR, please make sure you follow our coding style. Just run `npm
### Build packages

```
$ npm run-script dist:linux # builds an AppImage, a deb, and a snap
$ npm run-script dist:mac # builds a dmg
$ npm run-script dist:win # builds an exe
$ ./build.js --help
Usage: ./build.js -o <os> -p <package> -a <arch> [options]
# or
$ ./build.js -o <os> -p <package> [options] # see ./build.js --help
Options:
-V, --version output the version number
-o, --os <os> Target operating system (darwin, win32, linux) (default: "linux")
-p, --package <package> Target package (deb, snap, AppImage, dmg, portable, dir) (default: "dir")
-a, --arch <architecture> Target architecture (armv7l, x64, ia32, arm64) (default: "x64")
-e, --extra-metadata [JSON] extra data for package.json (default: "{}")
-h, --help output usage information
```
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ version: '{build}'
clone_depth: 1
test_script:
- npm run lint
- npm run dist:win
- ./build.js -o win32 -p portable -a x64
artifacts:
- path: dist\ubports-installer*.exe
name: Releases
deploy:
provider: GitHub
auth_token:
secure: kuVj7rmTfk7fuOFpF9H/G7Toqj3A27+5h2PjbYEGkuX3U4X34O/rYGUR52kvF+im
artifact: /ubports-installer.*\.exe/
artifact: /ubports-installer*\.exe/
draft: false
prerelease: true
on:
Expand Down
37 changes: 29 additions & 8 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,31 @@ const builder = require("electron-builder");
const cli = require("commander");

const PLATFORMS = ["darwin", "win32", "linux"];
const PACKAGES = ["deb", "snap", "AppImage", "dmg", "exe", "dir"];
const PACKAGES = ["deb", "snap", "AppImage", "dmg", "portable", "dir"];
const ARCH = ["armv7l", "x64", "ia32", "arm64"];

cli
.version(require("./package.json").version)
.usage("./build.js -o <os> -p <package> [options]")
.name("./build.js")
.usage("-o <os> -p <package> -a <arch> [options]") // remember the cant
.option(
"-o, --os <os>",
`Target operating system (${PLATFORMS.join(", ")})`,
p => (PLATFORMS.includes(p) ? p : process.platform),
process.platform
)
.option(
"-p, --package [package]",
"-p, --package <package>",
`Target package (${PACKAGES.join(", ")})`,
p => (PACKAGES.includes(p) ? p : "dir"),
"dir"
)
.option(
"-a, --arch <architecture>",
`Target architecture (${ARCH.join(", ")})`,
a => (ARCH.includes(a) ? a : "x64"),
"x64"
)
.option(
"-e, --extra-metadata [JSON]",
"extra data for package.json",
Expand All @@ -53,32 +61,45 @@ var buildConfig = {
appId: "com.ubports.installer",
productName: "ubports-installer",
copyright: "Copyright © 2017-2020 UBports Foundation",
artifactName: "${name}_${version}_${os}_${arch}.${ext}",
publish: [],
files: [
"src/**/*",
"!src/pug/*",
"node_modules/**/*",
"build/icons/icon.*",
...PLATFORMS.filter(p => p !== cli.os).map(p => `!**/${p}/**`)
// exclude binaries for other operating systems
...PLATFORMS.filter(p => p !== cli.os).map(
p => `!node_modules/android-tools-bin/dist/${p}`
),
// exclude binaries for other architectures
`!node_modules/android-tools-bin/dist/**/${
cli.arch.includes("arm") ? "x86" : "arm"
}/**`
],
asarUnpack: [
// Unpack dependencies of pakcages containing binaries
"node_modules/7zip-min/*", // for 7zip-bin
"node_modules/@babel/runtime/**/*" // for android-tools-bin
"node_modules/@babel/runtime/**/*", // for android-tools-bin
],
extraMetadata: {
package: cli.package,
...cli.extraMetadata
}
};

const target = {
target: cli.package,
arch: cli.arch
};

// Validate and configure operating system
switch (cli.os) {
case "linux":
targetOs = builder.Platform.LINUX;
buildConfig = Object.assign(buildConfig, {
linux: {
target: cli.package,
target,
icon: "build/icons",
synopsis: "Install Ubuntu Touch on UBports devices",
category: "Utility"
Expand All @@ -103,7 +124,7 @@ switch (cli.os) {
targetOs = builder.Platform.WINDOWS;
buildConfig = Object.assign(buildConfig, {
win: {
target: ["portable"],
target,
icon: "build/icons/icon.ico"
}
});
Expand All @@ -112,7 +133,7 @@ switch (cli.os) {
targetOs = builder.Platform.MAC;
buildConfig = Object.assign(buildConfig, {
mac: {
target: "dmg",
target,
icon: "build/icons/icon.icns",
category: "public.app-category.utilities"
}
Expand Down
Loading

0 comments on commit edceb6f

Please sign in to comment.