forked from scroll-tech/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
55 lines (48 loc) · 1.47 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
use std::{
env,
io::{self, Write},
};
fn main() {
let lib_name = "go-geth-utils";
let out_dir = env::var("OUT_DIR").unwrap();
// Build
let mut build = gobuild::Build::new();
// Replace to a custom go-ethereum for scroll.
#[cfg(feature = "scroll")]
build.modfile("scroll.mod");
if let Err(e) = build.file("./lib/lib.go").try_compile(lib_name) {
// The error type is private so have to check the error string
if format!("{}", e).starts_with("Failed to find tool.") {
fail(
" Failed to find Go. Please install Go 1.16 or later \
following the instructions at https://golang.org/doc/install.
On linux it is also likely available as a package."
.to_string(),
);
} else {
fail(format!("{}", e));
}
}
// Files the lib depends on that should recompile the lib
let dep_files = vec![
"./gethutil/asm.go",
"./gethutil/trace.go",
"./gethutil/util.go",
"./go.mod",
"./scroll.mod",
];
for file in dep_files {
println!("cargo:rerun-if-changed={}", file);
}
// Link
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static={}", lib_name);
}
fn fail(message: String) {
let _ = writeln!(
io::stderr(),
"\n\nError while building geth-utils: {}\n\n",
message
);
std::process::exit(1);
}