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
use std::{fs, path::Path};
fn main() {
let out_path = Path::new("src/resources/logo.ansi");
let logo_bytes = include_bytes!("src/resources/logo.png");
let ansi = logo_art::image_to_ansi(logo_bytes, 90);
fs::write(out_path, ansi).unwrap();
println!("cargo::rerun-if-changed=src/resources/logo.png");
// Vendored WGSL grammar — compiled only when lang-wgsl is enabled.
// Using vendored sources avoids pulling in tree-sitter-wgsl 0.0.6 which was
// built against the incompatible tree-sitter 0.20 API.
if std::env::var("CARGO_FEATURE_LANG_WGSL").is_ok() {
let wgsl_dir = Path::new("vendor/tree-sitter-wgsl/src");
cc::Build::new()
.include(wgsl_dir)
.file(wgsl_dir.join("parser.c"))
.file(wgsl_dir.join("scanner.c"))
.warnings(false)
.compile("tree_sitter_wgsl");
println!("cargo::rerun-if-changed=vendor/tree-sitter-wgsl/src/parser.c");
println!("cargo::rerun-if-changed=vendor/tree-sitter-wgsl/src/scanner.c");
}
// Vendored ActionScript grammar (tree-sitter-actionscript, jcs090218).
// parser.c only — the grammar has no external scanner.
if std::env::var("CARGO_FEATURE_LANG_ACTIONSCRIPT").is_ok() {
let as_dir = Path::new("vendor/tree-sitter-actionscript/src");
cc::Build::new()
.include(as_dir)
.file(as_dir.join("parser.c"))
.warnings(false)
.compile("tree_sitter_actionscript");
println!("cargo::rerun-if-changed=vendor/tree-sitter-actionscript/src/parser.c");
}
// Vendored GDScript grammar (tree-sitter-gdscript, PrestonKnopp).
// parser.c + scanner.c — the grammar has an external scanner.
if std::env::var("CARGO_FEATURE_LANG_GDSCRIPT").is_ok() {
let gdscript_dir = Path::new("vendor/tree-sitter-gdscript/src");
cc::Build::new()
.include(gdscript_dir)
.file(gdscript_dir.join("parser.c"))
.file(gdscript_dir.join("scanner.c"))
.warnings(false)
.compile("tree_sitter_gdscript");
println!("cargo::rerun-if-changed=vendor/tree-sitter-gdscript/src/parser.c");
println!("cargo::rerun-if-changed=vendor/tree-sitter-gdscript/src/scanner.c");
}
}