BlueGit

ict rusty-teams

build: add macos build script (#5)

metis Michael Corrigan · pushed by metis

Authored 2026-11-05 · 3 weeks ago

Hash
146edfcd78d82980a0b5902456b2f4c7de41b79b
Parent
47510b29
3 files changed +59 −1
.cargo/config.toml +11 −0
@@ -5,3 +5,14 @@ rustflags = ["-C", "target-feature=+crt-static"]
5 5 [target.x86_64-unknown-linux-gnu]
6 6 linker = "clang"
7 7 rustflags = ["-C", "link-arg=-fuse-ld=mold"]
8
9 # libwebrtc's ObjC categories (NSString+StdString, RTCVideoCodecInfo, ...) live in unlinked
10 # objects of the prebuilt static lib; without -ObjC the app aborts in a C++ static initializer
11 # (RTCH264ProfileLevelId.mm) before main. webrtc-sys already passes -ObjC, but a dependency's
12 # link flags never reach the final binary. The x86_64 prebuilt also autolinks a Swift runtime
13 # dylib (@rpath/libswiftCoreMedia.dylib) that lives in the dyld shared cache only.
14 [target.aarch64-apple-darwin]
15 rustflags = ["-C", "link-arg=-ObjC", "-C", "link-arg=-Wl,-rpath,/usr/lib/swift"]
16
17 [target.x86_64-apple-darwin]
18 rustflags = ["-C", "link-arg=-ObjC", "-C", "link-arg=-Wl,-rpath,/usr/lib/swift"]
@@ -5,3 +5,14 @@ rustflags = ["-C", "target-feature=+crt-static"]
5[target.x86_64-unknown-linux-gnu]
5[target.x86_64-unknown-linux-gnu]
6linker = "clang"
6linker = "clang"
7rustflags = ["-C", "link-arg=-fuse-ld=mold"]
7rustflags = ["-C", "link-arg=-fuse-ld=mold"]
8
9# libwebrtc's ObjC categories (NSString+StdString, RTCVideoCodecInfo, ...) live in unlinked
10# objects of the prebuilt static lib; without -ObjC the app aborts in a C++ static initializer
11# (RTCH264ProfileLevelId.mm) before main. webrtc-sys already passes -ObjC, but a dependency's
12# link flags never reach the final binary. The x86_64 prebuilt also autolinks a Swift runtime
13# dylib (@rpath/libswiftCoreMedia.dylib) that lives in the dyld shared cache only.
14[target.aarch64-apple-darwin]
15rustflags = ["-C", "link-arg=-ObjC", "-C", "link-arg=-Wl,-rpath,/usr/lib/swift"]
16
17[target.x86_64-apple-darwin]
18rustflags = ["-C", "link-arg=-ObjC", "-C", "link-arg=-Wl,-rpath,/usr/lib/swift"]
README.md +3 −1
@@ -8,7 +8,7 @@
8 8
9 9 [![Rust](https://img.shields.io/badge/Rust-2024-dea584?logo=rust&logoColor=white)](https://www.rust-lang.org/)
10 10 [![GPUI](https://img.shields.io/badge/UI-GPUI-c4642d)](https://www.gpui.rs/)
11 [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux-3b3b3b)](#status)
11 [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-3b3b3b)](#status)
12 12 [![License: MIT](https://img.shields.io/badge/license-MIT-2ea043)](LICENSE)
13 13
14 14 [Features](#features) · [Quick start](#quick-start) · [How it works](#how-it-works) · [Roadmap](ROADMAP.md)
@@ -85,6 +85,7 @@
85 85 |---|---|
86 86 | 🪟 Windows | Main target. Login through an embedded WebView2 |
87 87 | 🐧 Linux | Connects to a Chrome started with `--remote-debugging-port=9222`. Built-in login is planned |
88 | 🍎 macOS | Experimental. Universal arm64 + x86_64 binary, connects to a Chrome like Linux |
88 89
89 90 The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
90 91
@@ -101,6 +102,7 @@ cargo run -p app -- --demo
101 102 | Linux build needs clang + mold (set in `.cargo/config.toml`); sccache shares compiled deps across worktrees | `sudo apt install clang mold sccache` |
102 103 | Against Chrome on a debug port | `cargo run -p app -- --endpoint http://127.0.0.1:9222` |
103 104 | Windows exe from WSL/Linux | `scripts/build-windows.sh crates/app teams` |
105 | macOS universal binary (arm64 + x86_64), Xcode CLT only | `scripts/build-macos.sh crates/app teams` |
104 106 | Tests | `cargo test` |
105 107 | Headless screenshot (Xvfb, xdotool, xclip, mesa-vulkan-drivers) | `cargo build -p app && scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello"` |
106 108 | Layout sweep before every UI deploy: 8 screens at 640x480 and 1920x1080, PNGs in `target/layout-sweep` (look at each) | `cargo build -p app && scripts/layout-sweep.sh` |
@@ -8,7 +8,7 @@
8
8
9[![Rust](https://img.shields.io/badge/Rust-2024-dea584?logo=rust&logoColor=white)](https://www.rust-lang.org/)
9[![Rust](https://img.shields.io/badge/Rust-2024-dea584?logo=rust&logoColor=white)](https://www.rust-lang.org/)
10[![GPUI](https://img.shields.io/badge/UI-GPUI-c4642d)](https://www.gpui.rs/)
10[![GPUI](https://img.shields.io/badge/UI-GPUI-c4642d)](https://www.gpui.rs/)
11[![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux-3b3b3b)](#status)
11[![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-3b3b3b)](#status)
12[![License: MIT](https://img.shields.io/badge/license-MIT-2ea043)](LICENSE)
12[![License: MIT](https://img.shields.io/badge/license-MIT-2ea043)](LICENSE)
13
13
14[Features](#features) · [Quick start](#quick-start) · [How it works](#how-it-works) · [Roadmap](ROADMAP.md)
14[Features](#features) · [Quick start](#quick-start) · [How it works](#how-it-works) · [Roadmap](ROADMAP.md)
@@ -85,6 +85,7 @@
85|---|---|
85|---|---|
86| 🪟 Windows | Main target. Login through an embedded WebView2 |
86| 🪟 Windows | Main target. Login through an embedded WebView2 |
87| 🐧 Linux | Connects to a Chrome started with `--remote-debugging-port=9222`. Built-in login is planned |
87| 🐧 Linux | Connects to a Chrome started with `--remote-debugging-port=9222`. Built-in login is planned |
88| 🍎 macOS | Experimental. Universal arm64 + x86_64 binary, connects to a Chrome like Linux |
88
89
89The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
90The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
90
91
@@ -101,6 +102,7 @@ cargo run -p app -- --demo
101| Linux build needs clang + mold (set in `.cargo/config.toml`); sccache shares compiled deps across worktrees | `sudo apt install clang mold sccache` |
102| Linux build needs clang + mold (set in `.cargo/config.toml`); sccache shares compiled deps across worktrees | `sudo apt install clang mold sccache` |
102| Against Chrome on a debug port | `cargo run -p app -- --endpoint http://127.0.0.1:9222` |
103| Against Chrome on a debug port | `cargo run -p app -- --endpoint http://127.0.0.1:9222` |
103| Windows exe from WSL/Linux | `scripts/build-windows.sh crates/app teams` |
104| Windows exe from WSL/Linux | `scripts/build-windows.sh crates/app teams` |
105| macOS universal binary (arm64 + x86_64), Xcode CLT only | `scripts/build-macos.sh crates/app teams` |
104| Tests | `cargo test` |
106| Tests | `cargo test` |
105| Headless screenshot (Xvfb, xdotool, xclip, mesa-vulkan-drivers) | `cargo build -p app && scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello"` |
107| Headless screenshot (Xvfb, xdotool, xclip, mesa-vulkan-drivers) | `cargo build -p app && scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello"` |
106| Layout sweep before every UI deploy: 8 screens at 640x480 and 1920x1080, PNGs in `target/layout-sweep` (look at each) | `cargo build -p app && scripts/layout-sweep.sh` |
108| Layout sweep before every UI deploy: 8 screens at 640x480 and 1920x1080, PNGs in `target/layout-sweep` (look at each) | `cargo build -p app && scripts/layout-sweep.sh` |
scripts/build-macos.sh added +45 −0
@@ -0,0 +1,45 @@
1 #!/usr/bin/env bash
2 # Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.
3 # Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]
4 set -euo pipefail
5 repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6 crateDir="$(realpath "${1:-$repoRoot/crates/app}")"
7 binaryName="${2:-}"
8 export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"
9 export PATH="$HOME/.cargo/bin:$PATH"
10 targets=(aarch64-apple-darwin x86_64-apple-darwin)
11
12 rustup target add "${targets[@]}" >/dev/null
13
14 buildArguments=(build --release)
15 slicePathInTarget="release"
16 if [ -n "$binaryName" ] && [ -f "$crateDir/examples/$binaryName.rs" ]; then
17 buildArguments+=(--example "$binaryName")
18 slicePathInTarget="release/examples"
19 elif [ -n "$binaryName" ]; then
20 buildArguments+=(--bin "$binaryName")
21 fi
22
23 for target in "${targets[@]}"; do
24 (cd "$crateDir" && cargo "${buildArguments[@]}" --target "$target")
25 done
26
27 slices=()
28 for target in "${targets[@]}"; do
29 sliceDirectory="$CARGO_TARGET_DIR/$target/$slicePathInTarget"
30 if [ -n "$binaryName" ]; then
31 slices+=("$sliceDirectory/$binaryName")
32 else
33 candidates=("$sliceDirectory"/*)
34 [ "${#candidates[@]}" -eq 1 ] && [ -f "${candidates[0]}" ] ||
35 { echo "more than one binary in $sliceDirectory, pass the name" >&2; exit 1; }
36 slices+=("${candidates[0]}")
37 fi
38 done
39
40 outputDirectory="$CARGO_TARGET_DIR/universal/release"
41 mkdir -p "$outputDirectory"
42 output="$outputDirectory/$(basename "${slices[0]}")"
43 lipo -create -output "$output" "${slices[@]}"
44 file "$output"
45 ls -la "$output"
@@ -0,0 +1,45 @@
1#!/usr/bin/env bash
2# Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.
3# Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]
4set -euo pipefail
5repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6crateDir="$(realpath "${1:-$repoRoot/crates/app}")"
7binaryName="${2:-}"
8export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"
9export PATH="$HOME/.cargo/bin:$PATH"
10targets=(aarch64-apple-darwin x86_64-apple-darwin)
11
12rustup target add "${targets[@]}" >/dev/null
13
14buildArguments=(build --release)
15slicePathInTarget="release"
16if [ -n "$binaryName" ] && [ -f "$crateDir/examples/$binaryName.rs" ]; then
17 buildArguments+=(--example "$binaryName")
18 slicePathInTarget="release/examples"
19elif [ -n "$binaryName" ]; then
20 buildArguments+=(--bin "$binaryName")
21fi
22
23for target in "${targets[@]}"; do
24 (cd "$crateDir" && cargo "${buildArguments[@]}" --target "$target")
25done
26
27slices=()
28for target in "${targets[@]}"; do
29 sliceDirectory="$CARGO_TARGET_DIR/$target/$slicePathInTarget"
30 if [ -n "$binaryName" ]; then
31 slices+=("$sliceDirectory/$binaryName")
32 else
33 candidates=("$sliceDirectory"/*)
34 [ "${#candidates[@]}" -eq 1 ] && [ -f "${candidates[0]}" ] ||
35 { echo "more than one binary in $sliceDirectory, pass the name" >&2; exit 1; }
36 slices+=("${candidates[0]}")
37 fi
38done
39
40outputDirectory="$CARGO_TARGET_DIR/universal/release"
41mkdir -p "$outputDirectory"
42output="$outputDirectory/$(basename "${slices[0]}")"
43lipo -create -output "$output" "${slices[@]}"
44file "$output"
45ls -la "$output"