diff options
| author | David Lönnhager <david.l@mullvad.net> | 2024-12-06 10:15:20 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-12-10 14:34:21 +0100 |
| commit | 997e8c4e80d2992d11ed5bfe20151c233e83cd01 (patch) | |
| tree | a3d9b653f482367dbdc730aa7dfe392a3dda78c4 /scripts | |
| parent | fd5a95076d6b953cf22fdf8a0067d0759b3e1658 (diff) | |
| download | mullvadvpn-997e8c4e80d2992d11ed5bfe20151c233e83cd01.tar.xz mullvadvpn-997e8c4e80d2992d11ed5bfe20151c233e83cd01.zip | |
Pack universal installer in build script
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/pack-universal-win.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/pack-universal-win.sh b/scripts/pack-universal-win.sh new file mode 100644 index 0000000000..453b722011 --- /dev/null +++ b/scripts/pack-universal-win.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# shellcheck shell=bash +# Build universal installer for both ARM and x64. + +set -eu + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR/.." + +CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-"target"} + +# If enabled, build in release mode with optimizations enabled +OPTIMIZE="false" + +source scripts/utils/log + +echo "Computing build version..." +PRODUCT_VERSION=$(cargo run -q --bin mullvad-version) +log_header "Building universal Windows installer for Mullvad VPN $PRODUCT_VERSION" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --x64-installer) + export WIN_X64_INSTALLER="$2" + shift 2 + ;; + --arm64-installer) + export WIN_ARM64_INSTALLER="$2" + shift 2 + ;; + --optimize) + OPTIMIZE="true" + shift + ;; + *) + log_error "Unknown argument: $1" + exit 1 + ;; + esac +done + +CARGO_ARGS=() + +if [[ "$OPTIMIZE" == "true" ]]; then + CARGO_ARGS+=(--release) + RUST_BUILD_MODE="release" +else + RUST_BUILD_MODE="debug" +fi + +if [[ "$OPTIMIZE" == "true" && "$PRODUCT_VERSION" != *"-dev-"* ]]; then + CARGO_ARGS+=(--locked) +fi + +if [[ -z ${WIN_X64_INSTALLER-} ]] || [[ -z ${WIN_ARM64_INSTALLER-} ]]; then + log_error "Must provide --x64-installer and --arm64-installer" + exit 1 +fi + +cargo build "${CARGO_ARGS[@]}" -p windows-installer --target x86_64-pc-windows-msvc + +dest="dist/MullvadVPN-${PRODUCT_VERSION}.exe" + +cp "$CARGO_TARGET_DIR/x86_64-pc-windows-msvc/${RUST_BUILD_MODE}/windows-installer.exe" "$dest" + +log_success "Built universal installer: $dest" |
