diff options
| author | David Czihak <git@dcz.at> | 2026-05-07 14:33:19 +0200 |
|---|---|---|
| committer | David Czihak <git@dcz.at> | 2026-05-07 14:33:19 +0200 |
| commit | ddf2de739068b5ff0866ccb1d067f3cb53a4fc55 (patch) | |
| tree | 1a77efe9d73a6172be3c37d29b321eadd4efe379 /Scripts/build-parser.sh | |
Initial commitv0.1.7
Diffstat (limited to 'Scripts/build-parser.sh')
| -rwxr-xr-x | Scripts/build-parser.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Scripts/build-parser.sh b/Scripts/build-parser.sh new file mode 100755 index 0000000..3b93a1c --- /dev/null +++ b/Scripts/build-parser.sh | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # build-parser.sh — Compile the Nova-compatible tree-sitter-zig parser. | ||
| 4 | # | ||
| 5 | # Purpose: | ||
| 6 | # Build vendor/tree-sitter-zig/src/parser.c into a universal macOS dylib | ||
| 7 | # that Nova loads via its private SyntaxKit framework. | ||
| 8 | # | ||
| 9 | # What it does: | ||
| 10 | # - clang -dynamiclib for arm64 + x86_64 | ||
| 11 | # - links against Nova’s SyntaxKit framework (from /Applications/Nova.app) | ||
| 12 | # - sets rpath @loader_path/../Frameworks so the dylib finds SyntaxKit | ||
| 13 | # when Nova loads it from the bundled extension | ||
| 14 | # - ad-hoc codesigns the dylib (Gatekeeper requirement) | ||
| 15 | # - writes the result to Syntaxes/libtree-sitter-zig.dylib | ||
| 16 | # | ||
| 17 | # Usage: | ||
| 18 | # ./Scripts/build-parser.sh | ||
| 19 | # | ||
| 20 | # Environment overrides: | ||
| 21 | # NOVA_APP Path to Nova.app (default: /Applications/Nova.app) | ||
| 22 | # SDKROOT macOS SDK path (default: `xcrun --show-sdk-path`) | ||
| 23 | # | ||
| 24 | # Requirements: | ||
| 25 | # macOS, Xcode Command Line Tools (clang + xcrun), Nova installed. | ||
| 26 | |||
| 27 | set -eu | ||
| 28 | |||
| 29 | ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" | ||
| 30 | VENDOR_DIR="$ROOT/vendor/tree-sitter-zig" | ||
| 31 | BUILD_DIR="$ROOT/build" | ||
| 32 | OUTPUT="$ROOT/Syntaxes/libtree-sitter-zig.dylib" | ||
| 33 | NOVA_APP="${NOVA_APP:-/Applications/Nova.app}" | ||
| 34 | SDKROOT="${SDKROOT:-$(xcrun --show-sdk-path)}" | ||
| 35 | |||
| 36 | mkdir -p "$BUILD_DIR" | ||
| 37 | |||
| 38 | clang \ | ||
| 39 | -dynamiclib \ | ||
| 40 | -O2 \ | ||
| 41 | -fPIC \ | ||
| 42 | -arch arm64 \ | ||
| 43 | -arch x86_64 \ | ||
| 44 | -isysroot "$SDKROOT" \ | ||
| 45 | -I"$VENDOR_DIR/src" \ | ||
| 46 | -F"$NOVA_APP/Contents/Frameworks" \ | ||
| 47 | -framework SyntaxKit \ | ||
| 48 | -Wl,-rpath,@loader_path/../Frameworks \ | ||
| 49 | -o "$BUILD_DIR/libtree-sitter-zig.dylib" \ | ||
| 50 | "$VENDOR_DIR/src/parser.c" | ||
| 51 | |||
| 52 | codesign --force --sign - "$BUILD_DIR/libtree-sitter-zig.dylib" | ||
| 53 | cp "$BUILD_DIR/libtree-sitter-zig.dylib" "$OUTPUT" | ||
