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