mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-03 21:54:27 +01:00
build(tools): add the fake C compiler and mac-check.sh for the macOS type-check on Linux
macOS cannot be built or linked on the Linux host; the way to type-check it is
`cargo check --target aarch64-apple-darwin --all-targets` with a fake C compiler so the
C -sys crates' build scripts succeed. That compiler was only a scratchpad file outside the
repository and mac-check.sh hardcoded a workspace path.
tools/cc-fake.sh: verbatim copy of the scratchpad cc-fake.sh (emits an empty object for
every compile, hands -E to the real gcc). No difference.
tools/mac-check.sh: new copy of the old script with these differences:
- no hardcoded `cd /home/jado/komomono-work/ws-step4/komorebi-for-mac`: the root comes from
`jj root` (fallback `git rev-parse --show-toplevel`);
- the fake CC is `$HERE/cc-fake.sh` (next to the script) instead of `$S/kfm/cc-fake.sh`;
- the target dir is `${FAST_CHECK_SCRATCH:-${XDG_CACHE_HOME:-$HOME/.cache}/komorebi-fast-check}/target-fast-mac`
instead of a /tmp/claude-1000 scratchpad;
- in the merged tree (komorebi-for-kde has its own Cargo.toml only in the old layout) it checks the
packages fast-check checks (-p komorebi -p komorebi-macos -p komorebic-macos
-p komorebi-client-macos -p komorebi-bar-macos) from the root; with the old separate workspace it
keeps `cd komorebi-for-mac` and --workspace;
- /bin/sh became bash with `set -euo pipefail`; the old script's omission of --locked is kept
(pass it as an extra argument).
Verified: bash -n and shellcheck clean. Not run: the check itself needs nix and the toolchain build.
This commit is contained in:
1 parent
acbe816fb4
commit
2a8b71f1c9
2 files changed
+35
No files matched your search
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# check-only hack: emit an empty object for every compile so C -sys build scripts "succeed"
|
||||
out=""; prev=""; compile=0
|
||||
for a in "$@"; do
|
||||
[ "$prev" = "-o" ] && out="$a"
|
||||
[ "$a" = "-c" ] && compile=1
|
||||
[ "$a" = "-E" ] && { exec gcc "${@}" ; }
|
||||
case "$a" in -Fo*) out="${a#-Fo}";; esac
|
||||
prev="$a"
|
||||
done
|
||||
if [ $compile = 1 ] && [ -n "$out" ]; then exec gcc -x c -c /dev/null -o "$out"; fi
|
||||
exit 0
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# usage: tools/mac-check.sh [extra cargo args]
|
||||
# Type-check of the macOS code on Linux (target aarch64-apple-darwin) through the fake C compiler
|
||||
# tools/cc-fake.sh. Cannot link or run anything. Same command as the macOS step of tools/fast-check, but
|
||||
# unconditional. Run from anywhere inside the repository; uses FAST_CHECK_SCRATCH like fast-check.
|
||||
set -euo pipefail
|
||||
S="${FAST_CHECK_SCRATCH:-${XDG_CACHE_HOME:-$HOME/.cache}/komorebi-fast-check}"
|
||||
HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
||||
ROOT="$(jj root 2>/dev/null || git rev-parse --show-toplevel)"
|
||||
cd "$ROOT"
|
||||
# merged root workspace (one Cargo.toml for the three platforms) or the old separate komorebi-for-mac workspace
|
||||
if [ -f komorebi-for-kde/Cargo.toml ]; then
|
||||
cd komorebi-for-mac
|
||||
PKGS=(--workspace)
|
||||
else
|
||||
PKGS=(-p komorebi -p komorebi-macos -p komorebic-macos -p komorebi-client-macos -p komorebi-bar-macos)
|
||||
fi
|
||||
export CARGO_TARGET_DIR="$S/target-fast-mac" COMMIT_HASH="${COMMIT_HASH:-dev}"
|
||||
export CC_aarch64_apple_darwin="$HERE/cc-fake.sh" AR_aarch64_apple_darwin=ar
|
||||
PKG_CONFIG_PATH="$(nix build --no-link --print-out-paths nixpkgs#openssl.dev)/lib/pkgconfig"
|
||||
export PKG_CONFIG_PATH
|
||||
exec nix shell nixpkgs#gcc nixpkgs#pkg-config nixpkgs#openssl.dev -c \
|
||||
cargo check --target aarch64-apple-darwin "${PKGS[@]}" --all-targets "$@"
|
||||
Reference in new issue
Block a user