build: add macos build script (#5)
@@ -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]6
linker = "clang"6
linker = "clang"7
rustflags = ["-C", "link-arg=-fuse-ld=mold"]7
rustflags = ["-C", "link-arg=-fuse-ld=mold"]8
9
# libwebrtc's ObjC categories (NSString+StdString, RTCVideoCodecInfo, ...) live in unlinked10
# objects of the prebuilt static lib; without -ObjC the app aborts in a C++ static initializer11
# (RTCH264ProfileLevelId.mm) before main. webrtc-sys already passes -ObjC, but a dependency's12
# link flags never reach the final binary. The x86_64 prebuilt also autolinks a Swift runtime13
# 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"]@@ -8,7 +8,7 @@
8
8
9
9
[](https://www.rust-lang.org/)
10
10
[](https://www.gpui.rs/)
11
[](#status)
11
[](#status)
12
12
[](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
[](https://www.rust-lang.org/)9
[](https://www.rust-lang.org/)10
[](https://www.gpui.rs/)10
[](https://www.gpui.rs/)11
[](#status)11
[](#status)12
[](LICENSE)12
[](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
89
The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).90
The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).90
91
@@ -101,6 +102,7 @@ cargo run -p app -- --demo101
| 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` |@@ -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 bash2
# 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 pipefail5
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/null13
14
buildArguments=(build --release)15
slicePathInTarget="release"16
if [ -n "$binaryName" ] && [ -f "$crateDir/examples/$binaryName.rs" ]; then17
buildArguments+=(--example "$binaryName")18
slicePathInTarget="release/examples"19
elif [ -n "$binaryName" ]; then20
buildArguments+=(--bin "$binaryName")21
fi22
23
for target in "${targets[@]}"; do24
(cd "$crateDir" && cargo "${buildArguments[@]}" --target "$target")25
done26
27
slices=()28
for target in "${targets[@]}"; do29
sliceDirectory="$CARGO_TARGET_DIR/$target/$slicePathInTarget"30
if [ -n "$binaryName" ]; then31
slices+=("$sliceDirectory/$binaryName")32
else33
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
fi38
done39
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"