-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_mac.bash
More file actions
executable file
·79 lines (72 loc) · 3.2 KB
/
Copy pathbuild_mac.bash
File metadata and controls
executable file
·79 lines (72 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
# Xcode post-compile step for the macOS target: build the Rust bin with the
# standalone cargo (into target-macapp/, separate from the dev /target) and drop
# it where Xcode code-signs the .app. Sibling of build_ios.bash (M8b / Mac App
# Store). See PLAN-chain-notes-app.md.
#
# Universal by $ARCHS: Xcode archives a Mac app for `arm64 x86_64`, so each
# requested arch is built and lipo'd into one fat binary. A Debug/run build with
# ONLY_ACTIVE_ARCH=YES asks for just arm64 (fast path).
#
# Release also emits a **dSYM** for App Store Connect crash symbolication: the
# Rust bin IS the app's main executable, so it's built WITH debug info, a .dSYM
# is extracted into Xcode's dSYM folder (so the archive carries it and
# exportArchive's uploadSymbols pushes it), then the in-app copy is stripped.
# Debug-info + strip overrides are env-only, so Cargo.toml's release strip=true
# (and thus iOS/Android/dev builds) is unchanged.
set -euxo pipefail
export PATH="$HOME/.cargo/bin:$PATH"
export CARGO_TARGET_DIR="$SRCROOT/target-macapp"
NAME="$1"
if [ "${CONFIGURATION:-Debug}" = "Debug" ]; then
PROFILE=debug; REL=""
else
PROFILE=release; REL="--release"
fi
# Map Xcode's $ARCHS (space-separated) to rust triples. Fall back to the host's
# arm64 when ARCHS is unset (a plain `bash build_mac.bash` outside Xcode).
ARCHS="${ARCHS:-arm64}"
TRIPLES=()
for a in $ARCHS; do
case "$a" in
arm64) TRIPLES+=(aarch64-apple-darwin) ;;
x86_64) TRIPLES+=(x86_64-apple-darwin) ;;
*) echo "!! unknown arch '$a'" >&2; exit 1 ;;
esac
done
BINS=()
for T in "${TRIPLES[@]}"; do
if [ "$PROFILE" = release ]; then
# Full debug info in release so a dSYM can be produced. Env overrides only —
# Cargo.toml (and thus other platforms) keep strip=true / no debug.
CARGO_PROFILE_RELEASE_DEBUG=2 CARGO_PROFILE_RELEASE_STRIP=false \
cargo build $REL --bin "$NAME" --target "$T" --manifest-path "$SRCROOT/Cargo.toml"
else
cargo build $REL --bin "$NAME" --target "$T" --manifest-path "$SRCROOT/Cargo.toml"
fi
BINS+=("$CARGO_TARGET_DIR/$T/$PROFILE/$NAME")
done
# One arch → copy; multiple → lipo into a fat binary.
FAT="$CARGO_TARGET_DIR/$NAME-lipo"
if [ "${#BINS[@]}" -eq 1 ]; then
cp -f "${BINS[0]}" "$FAT"
else
lipo -create "${BINS[@]}" -output "$FAT"
fi
cp -f "$FAT" "$TARGET_BUILD_DIR/$EXECUTABLE_PATH"
# Release: extract the dSYM (same UUID(s) as the fat binary) into Xcode's dSYM
# folder so it rides in the archive, then strip debug info from the in-app copy.
if [ "$PROFILE" = release ] && [ -n "${DWARF_DSYM_FOLDER_PATH:-}" ]; then
mkdir -p "$DWARF_DSYM_FOLDER_PATH"
DSYM="$DWARF_DSYM_FOLDER_PATH/${WRAPPER_NAME:-$NAME.app}.dSYM"
dsymutil "$FAT" -o "$DSYM"
strip -S "$TARGET_BUILD_DIR/$EXECUTABLE_PATH" || true
fi
# App Review rejects a binary that merely REFERENCES a non-public API — and it
# does so AFTER upload, costing a review cycle. macOS 1.0 build 31 was rejected
# for winit's `_CGSSetWindowBackgroundBlurRadius`; catch the next one here
# instead. Checks every arch of the fat binary. Release only: this guards what
# ships, and a debug build links the same crates anyway.
if [ "$PROFILE" = release ]; then
"$SRCROOT/scripts/check-private-apis.sh" "$TARGET_BUILD_DIR/$EXECUTABLE_PATH"
fi