-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
47 lines (41 loc) · 1.25 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
// SPDX-FileCopyrightText: 2022 Kevin Amado <[email protected]>
//
// SPDX-License-Identifier: GPL-3.0-only
fn main() -> Result<(), Box<dyn std::error::Error>> {
for path in [
"src/lexer",
"src/parser",
"src/types.hh",
"src/utils.cc",
"src/utils.hh",
"src/vendored",
] {
println!("cargo:rerun-if-changed={path}");
}
let out = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
bindgen::Builder::default()
.derive_copy(false)
.derive_debug(false)
.derive_default(false)
.derive_eq(false)
.derive_hash(false)
.derive_ord(false)
.derive_partialeq(false)
.derive_partialord(false)
.header("src/types.hh")
.generate()
.expect("Unable to generate bindings")
.write_to_file(out.join("ffi.rs"))?;
cc::Build::new()
.include("src")
.file("src/vendored/lexer.cc")
.file("src/vendored/parser.cc")
.file("src/utils.cc")
.warnings(false)
.compile("something");
println!("cargo:rustc-link-lib=static=something");
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-arg=-lc");
println!("cargo:rustc-link-arg=-lstdc++");
Ok(())
}