diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2024-01-09 16:32:28 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2024-01-15 16:30:01 +0100 |
| commit | 441466e650d541c88ae246cf5cb110a90cee9898 (patch) | |
| tree | 47daf5aea4f1474a8c2aa7bf69666a1f281fc089 | |
| parent | 6bc4b86b278ec0b4187b35294ab7e889b638504d (diff) | |
| download | mullvadvpn-441466e650d541c88ae246cf5cb110a90cee9898.tar.xz mullvadvpn-441466e650d541c88ae246cf5cb110a90cee9898.zip | |
Fix binaries paths in mac build
| -rwxr-xr-x | build.sh | 5 | ||||
| -rwxr-xr-x | env.sh | 17 | ||||
| -rw-r--r-- | gui/tasks/distribution.js | 25 | ||||
| -rw-r--r-- | scripts/utils/host | 21 |
4 files changed, 41 insertions, 27 deletions
@@ -8,6 +8,7 @@ set -eu SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$SCRIPT_DIR" +source scripts/utils/host source scripts/utils/log ################################################################################ @@ -71,6 +72,8 @@ if [[ -n ${TARGETS:-""} ]]; then NPM_PACK_ARGS+=(--targets "${TARGETS[*]}") fi +NPM_PACK_ARGS+=(--host-target-triple "$HOST") + if [[ "$UNIVERSAL" == "true" ]]; then if [[ -n ${TARGETS:-""} ]]; then log_error "'TARGETS' and '--universal' cannot be specified simultaneously." @@ -79,8 +82,6 @@ if [[ "$UNIVERSAL" == "true" ]]; then log_info "Building universal macOS distribution" fi - source env.sh - # Universal macOS builds package targets for both aarch64-apple-darwin and x86_64-apple-darwin. # We leave the target corresponding to the host machine empty to avoid rebuilding multiple times. # When the --target flag is provided to cargo it always puts the build in the target/$ENV_TARGET @@ -4,22 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -case "$(uname -s)" in - Linux*) - arch="$(uname -m)" - HOST="${arch}-unknown-linux-gnu" - ;; - Darwin*) - arch="$(uname -m)" - if [[ ("${arch}" == "arm64") ]]; then - arch="aarch64" - fi - HOST="${arch}-apple-darwin" - ;; - MINGW*|MSYS_NT*) - HOST="x86_64-pc-windows-msvc" - ;; -esac +source scripts/utils/host ENV_TARGET=${1:-$HOST} diff --git a/gui/tasks/distribution.js b/gui/tasks/distribution.js index 59348c4f0c..99c8fb87ef 100644 --- a/gui/tasks/distribution.js +++ b/gui/tasks/distribution.js @@ -11,11 +11,14 @@ const shouldNotarize = process.argv.includes('--notarize'); const universal = process.argv.includes('--universal'); const release = process.argv.includes('--release'); -const targetsIndex = process.argv.indexOf('--targets'); -let targets = null; +const targets = getOptionValue('--targets'); +const hostTargetTriple = getOptionValue('--host-target-triple'); -if (targetsIndex !== -1) { - targets = process.argv[targetsIndex + 1]; +function getOptionValue(option) { + const optionIndex = process.argv.indexOf(option); + if (optionIndex !== -1) { + return process.argv[optionIndex + 1]; + } } const config = { @@ -90,12 +93,12 @@ const config = { NSUserNotificationAlertStyle: 'banner', }, extraResources: [ - { from: distAssets(path.join('${env.TARGET_TRIPLE}', 'mullvad')), to: '.' }, - { from: distAssets(path.join('${env.TARGET_TRIPLE}', 'mullvad-problem-report')), to: '.' }, - { from: distAssets(path.join('${env.TARGET_TRIPLE}', 'mullvad-daemon')), to: '.' }, - { from: distAssets(path.join('${env.TARGET_TRIPLE}', 'mullvad-setup')), to: '.' }, + { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad')), to: '.' }, + { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad-problem-report')), to: '.' }, + { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad-daemon')), to: '.' }, + { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad-setup')), to: '.' }, { - from: distAssets(path.join('${env.TARGET_TRIPLE}', 'libtalpid_openvpn_plugin.dylib')), + from: distAssets(path.join('${env.BINARIES_PATH}', 'libtalpid_openvpn_plugin.dylib')), to: '.', }, { from: distAssets(path.join('binaries', '${env.TARGET_TRIPLE}', 'openvpn')), to: '.' }, @@ -284,6 +287,10 @@ function packMac() { break; } + process.env.BINARIES_PATH = hostTargetTriple !== process.env.TARGET_TRIPLE + ? process.env.TARGET_TRIPLE + : ''; + return true; }, beforePack: async (context) => { diff --git a/scripts/utils/host b/scripts/utils/host new file mode 100644 index 0000000000..28301e636d --- /dev/null +++ b/scripts/utils/host @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# shellcheck shell=bash + +# This function returns the target triple of the machine running this script + +case "$(uname -s)" in + Linux*) + arch="$(uname -m)" + HOST="${arch}-unknown-linux-gnu" + ;; + Darwin*) + arch="$(uname -m)" + if [[ ("${arch}" == "arm64") ]]; then + arch="aarch64" + fi + HOST="${arch}-apple-darwin" + ;; + MINGW*|MSYS_NT*) + HOST="x86_64-pc-windows-msvc" + ;; +esac |
