Skip to content

Commit

Permalink
Merge branch 'build_faster'
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Jan 5, 2024
2 parents f37b615 + 5a8bf51 commit 1b97311
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ if [[ "$UNIVERSAL" == "true" ]]; then
if [[ -n ${TARGETS:-""} ]]; then
log_error "'TARGETS' and '--universal' cannot be specified simultaneously."
exit 1
else
log_info "Building universal macOS distribution"
fi

TARGETS=(x86_64-apple-darwin aarch64-apple-darwin)
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
# folder even when it matches you local machine, as opposed to just the target folder.
# This causes the cached build not to get used when later running e.g.
# 'cargo run --bin mullvad --shell-completions'.
case $HOST in
x86_64-apple-darwin) TARGETS=("" aarch64-apple-darwin);;
aarch64-apple-darwin) TARGETS=("" x86_64-apple-darwin);;
esac

NPM_PACK_ARGS+=(--universal)
fi

Expand Down Expand Up @@ -188,7 +202,7 @@ function sign_win {
# sign them, strip them of debug symbols and copy to `dist-assets/`.
function build {
local current_target=${1:-""}
local for_target_string=""
local for_target_string=" for local target $HOST"
local stripbin="strip"
if [[ -n $current_target ]]; then
for_target_string=" for $current_target"
Expand Down Expand Up @@ -268,7 +282,7 @@ function build {
local destination_dir="dist-assets"
fi

for binary in ${BINARIES[*]}; do
for binary in "${BINARIES[@]}"; do
local source="$cargo_output_dir/$binary"
local destination="$destination_dir/$binary"

Expand Down Expand Up @@ -301,22 +315,10 @@ if [[ "$(uname -s)" == "MINGW"* ]]; then
fi
fi

# Compile for all defined targets, or the current architecture if unspecified.
if [[ -n ${TARGETS:-""} ]]; then
for t in ${TARGETS[*]}; do
source env.sh "$t"
build "$t"
done
else
source env.sh ""
if [[ "$(uname -s)" == "Darwin" ]]; then
# Provide target for non-universal macOS builds to use the same output location as for
# universal builds
build "$ENV_TARGET"
else
build
fi
fi
for t in "${TARGETS[@]:-""}"; do
source env.sh "$t"
build "$t"
done

################################################################################
# Package app.
Expand Down

0 comments on commit 1b97311

Please sign in to comment.