forked from axic/solc-rust
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.rs
71 lines (62 loc) · 2.2 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
use cmake::Config;
use std::env;
use std::process::Command;
fn main() {
let mut cmake = Config::new("solidity");
cmake
.define("TESTS", "OFF")
.define("TOOLS", "OFF")
.define("USE_Z3", "OFF")
.define("USE_CVC4", "OFF")
.define("Boost_USE_STATIC_LIBS", "ON");
if Command::new("sccache").arg("--version").output().is_ok() {
cmake
.define("CMAKE_CXX_COMPILER_LAUNCHER", "sccache")
.define("CMAKE_C_COMPILER_LAUNCHER", "sccache");
}
let dst = cmake.build();
for lib in vec![
"solc", "solidity", "yul", "langutil", "evmasm", "solutil", "smtutil",
] {
println!(
"cargo:rustc-link-search=native={}/build/lib{}",
dst.display(),
lib
);
println!("cargo:rustc-link-lib=static={}", lib);
}
println!("cargo:rustc-link-search=native={}/lib", dst.display());
// jsoncpp dependency
println!(
"cargo:rustc-link-search=native={}/build/deps/lib",
dst.display()
);
println!("cargo:rustc-link-lib=static=jsoncpp");
println!("cargo:rustc-link-search=native=/usr/lib/");
println!("cargo:rustc-link-search=native=/usr/lib64/");
println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
println!("cargo:rustc-link-search=native=/usr/local/lib/");
println!("cargo:rustc-link-lib=static=boost_system");
println!("cargo:rustc-link-lib=static=boost_filesystem");
println!("cargo:rustc-link-lib=static=boost_regex");
// We need to link against C++ std lib
if let Some(cpp_stdlib) = get_cpp_stdlib() {
println!("cargo:rustc-link-lib={}", cpp_stdlib);
}
}
// See https://github.com/alexcrichton/gcc-rs/blob/88ac58e25/src/lib.rs#L1197
fn get_cpp_stdlib() -> Option<String> {
env::var("TARGET").ok().and_then(|target| {
if target.contains("msvc") {
None
} else if target.contains("darwin") {
Some("c++".to_string())
} else if target.contains("freebsd") {
Some("c++".to_string())
} else if target.contains("musl") {
Some("static=stdc++".to_string())
} else {
Some("stdc++".to_string())
}
})
}