-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.rs
84 lines (78 loc) · 2.17 KB
/
build.rs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
extern crate cc;
use std::path::PathBuf;
fn main() {
for lang in &[
#[cfg(feature = "bash")]
"bash",
#[cfg(feature = "c_sharp")]
"c-sharp",
#[cfg(feature = "c")]
"c",
#[cfg(feature = "clojure")]
"clojure",
#[cfg(feature = "cpp")]
"cpp",
#[cfg(feature = "css")]
"css",
#[cfg(feature = "elm")]
"elm",
#[cfg(feature = "go")]
"go",
#[cfg(feature = "haskell")]
"haskell",
#[cfg(feature = "html")]
"html",
#[cfg(feature = "java")]
"java",
#[cfg(feature = "javascript")]
"javascript",
#[cfg(feature = "json")]
"json",
#[cfg(feature = "julia")]
"julia",
#[cfg(feature = "ocaml")]
"ocaml",
#[cfg(feature = "php")]
"php",
#[cfg(feature = "python")]
"python",
#[cfg(feature = "racket")]
"racket",
#[cfg(feature = "ruby")]
"ruby",
#[cfg(feature = "rust")]
"rust",
#[cfg(feature = "scala")]
"scala",
#[cfg(feature = "typescript")]
"typescript",
] {
let mut build = cc::Build::new();
let tree_sitter: PathBuf = match *lang {
"typescript" => [
"vendor",
&format!("tree-sitter-{}", lang),
"typescript",
"src",
]
.iter()
.collect(),
_ => ["vendor", &format!("tree-sitter-{}", lang), "src"]
.iter()
.collect(),
};
build
.include(&tree_sitter)
.file(tree_sitter.join("parser.c"));
if tree_sitter.join("scanner.c").exists() {
build.file(tree_sitter.join("scanner.c"));
} else if tree_sitter.join("scanner.cc").exists() {
let mut build = cc::Build::new();
build.include(&tree_sitter);
build.cpp(true);
build.file(tree_sitter.join("scanner.cc"));
build.compile(&format!("tree_sitter_{}_scanner", lang));
};
build.compile(&format!("tree_sitter_{}", lang));
}
}