forked from hyperledger-solang/solang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
56 lines (44 loc) · 1.54 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
use std::process::Command;
fn main() {
lalrpop::Configuration::new()
.use_cargo_dir_conventions()
.emit_rerun_directives(true)
.process()
.unwrap();
// compile our linker
let cxxflags = Command::new("llvm-config")
.args(&["--cxxflags"])
.output()
.expect("could not execute llvm-config");
let cxxflags = String::from_utf8(cxxflags.stdout).unwrap();
let mut build = cc::Build::new();
build.file("src/linker/linker.cpp").cpp(true);
if !cfg!(target_os = "windows") {
build.flag("-Wno-unused-parameter");
}
for flag in cxxflags.split_whitespace() {
build.flag(flag);
}
build.compile("liblinker.a");
// add the llvm linker
let libdir = Command::new("llvm-config")
.args(&["--libdir"])
.output()
.unwrap();
let libdir = String::from_utf8(libdir.stdout).unwrap();
println!("cargo:libdir={}", libdir);
for lib in &["lldELF", "lldDriver", "lldCore", "lldCommon", "lldWasm"] {
println!("cargo:rustc-link-lib=static={}", lib);
}
// And all the symbols were not using, needed by Windows and debug builds
for lib in &["lldReaderWriter", "lldMachO", "lldYAML"] {
println!("cargo:rustc-link-lib=static={}", lib);
}
// note: add error checking yourself.
let output = Command::new("git")
.args(&["describe", "--tags"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}