1#!/bin/sh
2# cargo for Mac OS X 10.6, from any package: `cargo.sh build --release -p notebook ...`.
3# Needs nightly with rust-src and the SDK from `remote.sh sdk`.
4set -eu
5here=$(cd "$(dirname "$0")" && pwd)
6sdk=${SNOW_LEOPARD_SDK:-$(cd "$here/../.." && pwd)/target/snow-leopard/MacOSX10.6.sdk}
7target=x86_64-apple-macosx10.6
8command=$1
9shift
10# Cargo can't see link.sh's inputs; folding their hash into the flags relinks on change.
11runtime=$(cat "$here/link.sh" "$here"/rt/* | shasum | cut -c1-12)
12# The deployment target is for cc-rs (bundled SQLite); rustc warns that it ignores it.
13# rustc would infer ld64 from the name `link.sh`; it is a C compiler driver.
14# 10.6's EVFILT_USER drops mio's wakes, so Tokio wakes its I/O thread through a pipe.
15# objc2's debug builds check declared classes against today's SDKs, whose protocols have
16# methods 10.6's lack (winit's window delegate declares 10.7's), so they stay off.
17CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-$here/../../target/snow-leopard} \
18SNOW_LEOPARD_SDK=$sdk \
19TARGET_CFLAGS="-isysroot $sdk -mmacosx-version-min=10.6" \
20MACOSX_DEPLOYMENT_TARGET=10.6 \
21exec cargo +nightly -Zbuild-std=std,panic_unwind -Zjson-target-spec \
22 --config "target.$target.linker='$here/link.sh'" \
23 --config "target.$target.rustflags=['-C','linker-flavor=darwin-cc','-C','metadata=rt-$runtime','--cfg','mio_unsupported_force_waker_pipe']" \
24 --config "profile.dev.package.objc2.debug-assertions=false" \
25 "$command" --target "$here/$target.json" "$@"