Files
codegraph/codegraph-kernel/build.rs
T
bdd687b49f feat(kernel): R7b Scala walker — scala module, vendored-grammar-C master@0aca5d0a6f, scala default-routed (#1385)
R7b batch 4 #3 (docs/design/scala-kernel-port-checklist.md is the
authoritative quirk list). The third vendored-grammar-C language and the
biggest grammar in the tree (35MB parser.c): the vendored wasm is
tree-sitter/tree-sitter-scala master@0aca5d0a6f — a post-v0.26.0 generation
sync that is not a release (the 0.26.0 crate is 30 states BEHIND, so a
crate pin would be a silent downgrade). NO wasm change: production has
parsed with this exact revision since #91 — the kernel-grammar-parity row
(ABI 15, 26,650 states, 32 fields, id-by-id tables) is the whole alignment
proof.

Preserved bug-for-bug (all probe-pinned): the leak-through asymmetries —
extension methods mint NO nodes (first def's body calls leak to the
enclosing scope, later defs invisible, and the braced form resolves its
body field to the `{` TOKEN via first-match-wins field lookup → whole
extension invisible); anonymous `new T { … }` template_body members leak to
the enclosing scope (findAnonymousClassBody misses template_body); the
bodied-vs-bodiless class asymmetry (bodiless headers walk class_parameters
→ default-value calls emit FROM the class; bodied ones never see them) —
plus first-segment import names (`import com.example.C` → `com`), the
val/var hook keyed on the enclosing-definition NODE TYPE (object vals →
constants/value-ref targets, class/trait/enum/given vals → fields) with
consumed initializers, every def routed through extractMethod with the
top-level function fallback, nested defs in bodies minting NOTHING (the
inverse of kotlin) while body-local classes extract fully, curried
signatures keeping only the FIRST parameter list (type params win the
`parameters` field), enum cases positioned at the CASE node with invisible
params/extends tails, extends with-chains via scalaBaseTypeName,
`@deprecated(args)` decorates, the #750 capitalized-chain re-encode
(`WidgetS.create().render`), literal-receiver silence, static-member reads
AND writes, infix invisibility, `derives` silence, scaladoc retention with
the CRLF `\r` pin, full value-reference machinery (shadow prune, last-wins
same-name targets, `$X`/`${X}` interpolation reads), and SCALA_SPEC
fn-refs (bare ids + postfix eta unwrap + varinit, var-init non-capture).

Gates: parity sweeps first-run 0-diff on os-lib/cats/scala3-compiler-src/
scala3-library-src — 1,935 clean files byte-parity, deferrals 0/15/57/116
matching the survey's predictions exactly (scala-3's PHANTOM hasError
files — flag-true, zero ERROR nodes, capture-checking `^` — defer on the
FLAG); full-init dumps byte-identical ×3 (os-lib, cats, scala3 whole-repo
950,889 dump lines); kernel-scala-parity suite (9 fixtures + 9 in-memory
CRLF variants incl. Scala-3 indentation through the external scanner +
phantom/real-error defer pins + first-segment/namespace/value-ref pins);
full suite 2,669 green ×3 with CODEGRAPH_KERNEL_EXPECT=1
(kernel-scaffold's stays-wasm example moved scala → pascal).
DEFAULT_ROUTED += scala (19 langs).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 19:02:52 -05:00

64 lines
3.3 KiB
Rust

fn main() {
napi_build::setup();
// Kotlin grammar — vendored C, compiled here instead of a crate dep: the
// crates.io tree-sitter-kotlin 0.3.8 pins `tree-sitter >= 0.21, < 0.23`
// (the kernel links 0.25) and tree-sitter-kotlin-ng is a DIFFERENT
// grammar (8 fields vs 0, renamed kinds — extractor-breaking). Sources
// are the fwcd 0.3.8 tag's checked-in generated artifacts, sha-matched
// against the crates.io tarball (kotlin checklist §Grammar prep):
// parser.c 54104a7ef1555c265b746c790e0f8bb953cc17806e9df0c3af82f7f62c06a70a
// scanner.c 27f73337ec357fc341fa57538f34c14277b0346980c3405dc30beab6202ec6d0
// Flags crib the tarball's own bindings/rust/build.rs.
let mut c = cc::Build::new();
c.include("grammars/kotlin");
c.file("grammars/kotlin/parser.c");
c.file("grammars/kotlin/scanner.c");
c.flag_if_supported("-Wno-unused-parameter");
c.flag_if_supported("-Wno-unused-but-set-variable");
c.flag_if_supported("-Wno-trigraphs");
c.flag_if_supported("-utf-8"); // msvc
c.compile("tree-sitter-kotlin");
println!("cargo:rerun-if-changed=grammars/kotlin");
// Lua grammar — vendored C (second vendored-grammar-C language): the
// vendored wasm is tree-sitter-grammars/tree-sitter-lua v0.4.1 (tag
// 816840c592), which is NOT on crates.io (only 0.1/0.2/0.5 exist; 0.5.0
// adds Lua-5.5 `global` — a future bump with its own gate). Sources are
// the v0.4.1 tag's checked-in generated artifacts, sha-recorded in the
// lua-luau checklist §Grammar prep:
// parser.c b34a362e43f0311f405721f3089e94f97f31da403b154d456d093e64609a4081
// scanner.c 35bbd630b5a7421d46d2e91185eeea09bf78565d44cb676b63ca20d0f1b54bbd
let mut lua = cc::Build::new();
lua.include("grammars/lua");
lua.file("grammars/lua/parser.c");
lua.file("grammars/lua/scanner.c");
lua.flag_if_supported("-Wno-unused-parameter");
lua.flag_if_supported("-Wno-unused-but-set-variable");
lua.flag_if_supported("-Wno-trigraphs");
lua.flag_if_supported("-utf-8"); // msvc
lua.compile("tree-sitter-lua");
println!("cargo:rerun-if-changed=grammars/lua");
// Scala grammar — vendored C (third vendored-grammar-C language): the
// vendored wasm is tree-sitter/tree-sitter-scala master@0aca5d0a6f (the
// 2026-04-22 generation sync — 30 states PAST the v0.26.0 tag/crate, so a
// crate pin would be a silent downgrade). Sources are that commit's
// checked-in generated artifacts, sha-recorded in the scala checklist
// §Grammar prep:
// parser.c bc3c3c794f19461d99d04de6c31d57fa3e41243509b9ab023a9b88ed3273d102
// scanner.c e4ba242568ee3493015598997bf60f613802616eade62717c21109287ef64752
// parser.c is 35 MB — the biggest grammar in the tree; expect a slow cc
// step on clean builds.
let mut scala = cc::Build::new();
scala.include("grammars/scala");
scala.file("grammars/scala/parser.c");
scala.file("grammars/scala/scanner.c");
scala.flag_if_supported("-Wno-unused-parameter");
scala.flag_if_supported("-Wno-unused-but-set-variable");
scala.flag_if_supported("-Wno-trigraphs");
scala.flag_if_supported("-utf-8"); // msvc
scala.compile("tree-sitter-scala");
println!("cargo:rerun-if-changed=grammars/scala");
}