Skip to content

Commit

Permalink
update scripts to allow cross compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored and theofficialgman committed Jul 7, 2023
1 parent 205313e commit cb4be09
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
run: yarn
env:
npm_config_arch: ${{ matrix.arch }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Validate Electron version
run: yarn run validate-electron-version
- name: Lint
Expand All @@ -66,7 +65,6 @@ jobs:
run: yarn build:prod
env:
npm_config_arch: ${{ matrix.arch }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Prepare testing environment
if: matrix.arch == 'x64'
run: yarn test:setup
Expand All @@ -79,6 +77,8 @@ jobs:
- name: Package application
run: yarn run package
if: ${{ matrix.os == 'ubuntu-20.04' }}
env:
npm_config_arch: ${{ matrix.arch }}
- name: Create Release
uses: softprops/action-gh-release@v1
if:
Expand Down
20 changes: 2 additions & 18 deletions docs/contributing/building-arm64.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,12 @@ In order to build for `arm64`, you will need the following:
* A 64-bit OS. You can use [Ubuntu 16.04](#ubuntu-1604) and then follow the
instructions on setup there.

## Setup

Once you have the required tools installed, run this script to install the
dependencies that Desktop needs for `arm64`:

```shellsession
$ script/install-arm64-deps.sh
```

**Note:** Do not use `yarn` here as there is no current way to set environment
variables to rebuild native modules against `arm64`.

Ensure you set the `TARGET_ARCH` environment variable in your shell:

```shellsession
$ export TARGET_ARCH=arm64
```

## Building

After that, you should be able to build the development version of Desktop:

```shellsession
$ yarn
$ yarn build:dev
$ yarn start
```
Expand All @@ -42,6 +25,7 @@ Or if you want to test the production build:


```shellsession
$ yarn
$ yarn build:prod
$ yarn start:prod
```
2 changes: 1 addition & 1 deletion script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function packageApp() {
return packager({
name: getExecutableName(),
platform: toPackagePlatform(process.platform),
arch: toPackageArch(process.env.TARGET_ARCH),
arch: toPackageArch(process.env.npm_config_arch),
asar: false, // TODO: Probably wanna enable this down the road.
out: getDistRoot(),
icon,
Expand Down
6 changes: 0 additions & 6 deletions script/install-arm64-deps.sh

This file was deleted.

11 changes: 11 additions & 0 deletions script/package-debian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import { getVersion } from '../app/package-info'
import { getDistPath, getDistRoot } from './dist-info'

function getArchitecture() {
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)
if (process.env.npm_config_arch === 'arm64' ) {
return 'arm64'
}
if (process.env.npm_config_arch === 'x64' ) {
return 'amd64'
}
if ( process.env.npm_config_arch === 'armv7l' ) {
return 'armhf'
}
// If no specific npm_config_arch is set, use current process.arch
switch (process.arch) {
case 'arm64':
return 'arm64'
Expand Down
11 changes: 11 additions & 0 deletions script/package-electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ const globPromise = promisify(glob)
import { getDistPath, getDistRoot } from './dist-info'

function getArchitecture() {
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)
if (process.env.npm_config_arch === 'arm64' ) {
return '--arm64'
}
if (process.env.npm_config_arch === 'x64' ) {
return '--x64'
}
if ( process.env.npm_config_arch === 'armv7l' ) {
return '--armv7l'
}
// If no specific npm_config_arch is set, use current process.arch
switch (process.arch) {
case 'arm64':
return '--arm64'
Expand Down
11 changes: 11 additions & 0 deletions script/package-redhat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import { getVersion } from '../app/package-info'
import { getDistPath, getDistRoot } from './dist-info'

function getArchitecture() {
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)
if (process.env.npm_config_arch === 'arm64' ) {
return 'aarch64'
}
if (process.env.npm_config_arch === 'x64' ) {
return 'x86_64'
}
if ( process.env.npm_config_arch === 'armv7l' ) {
return 'armv7l'
}
// If no specific npm_config_arch is set, use current process.arch
switch (process.arch) {
case 'arm64':
return 'aarch64'
Expand Down

0 comments on commit cb4be09

Please sign in to comment.