interplane.Get Omega
Read in your language

tree-sitter-omega

aien-dev/tree-sitter-omega

Brought by drakestapleton

branch main Branches Tags History

tree-sitter-omega / bindings / rust / build.rs

46 lines · 1856 bytes Raw Blame History
1fn main() {
2 let src_dir = std::path::Path::new("src");
3
4 let mut c_config = cc::Build::new();
5 c_config.std("c11").include(src_dir);
6
7 #[cfg(target_env = "msvc")]
8 c_config.flag("-utf-8");
9
10 if std::env::var("TARGET").unwrap() == "wasm32-unknown-unknown" {
11 let Ok(wasm_headers) = std::env::var("DEP_TREE_SITTER_LANGUAGE_WASM_HEADERS") else {
12 panic!("Environment variable DEP_TREE_SITTER_LANGUAGE_WASM_HEADERS must be set by the language crate");
13 };
14
15 c_config.include(&wasm_headers);
16 }
17
18 let parser_path = src_dir.join("parser.c");
19 c_config.file(&parser_path);
20 println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
21
22 let scanner_path = src_dir.join("scanner.c");
23 if scanner_path.exists() {
24 c_config.file(&scanner_path);
25 println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
26 }
27
28 c_config.compile("tree-sitter-omega");
29
30 println!("cargo:rustc-check-cfg=cfg(with_highlights_query)");
31 if !"queries/highlights.scm".is_empty() && std::path::Path::new("queries/highlights.scm").exists() {
32 println!("cargo:rustc-cfg=with_highlights_query");
33 }
34 println!("cargo:rustc-check-cfg=cfg(with_injections_query)");
35 if !"queries/injections.scm".is_empty() && std::path::Path::new("queries/injections.scm").exists() {
36 println!("cargo:rustc-cfg=with_injections_query");
37 }
38 println!("cargo:rustc-check-cfg=cfg(with_locals_query)");
39 if !"queries/locals.scm".is_empty() && std::path::Path::new("queries/locals.scm").exists() {
40 println!("cargo:rustc-cfg=with_locals_query");
41 }
42 println!("cargo:rustc-check-cfg=cfg(with_tags_query)");
43 if !"queries/tags.scm".is_empty() && std::path::Path::new("queries/tags.scm").exists() {
44 println!("cargo:rustc-cfg=with_tags_query");
45 }
46}