-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
22 lines (18 loc) · 744 Bytes
/
build.rs
File metadata and controls
22 lines (18 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::process::Command;
fn main() {
println!("cargo:rerun-if-changed=Cargo.toml");
patch_crate::run().expect("Failed while patching");
// Run `rustc --print sysroot` to get the toolchain’s sysroot path
let sysroot = Command::new("rustc")
.arg("--print")
.arg("sysroot")
.output()
.expect("Failed to run rustc --print sysroot");
let sysroot_str = String::from_utf8(sysroot.stdout)
.expect("Non-UTF8 output from rustc --print sysroot")
.trim()
.to_owned();
// Emit a linker argument to set the RPATH to "<sysroot>/lib"
// `cargo:rustc-link-arg` allows us to pass arbitrary flags to the final linker invocation.
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", format!("{}/lib", sysroot_str));
}