forked from model-checking/kani
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
32 lines (28 loc) · 1.28 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
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::env;
use std::path::PathBuf;
macro_rules! path_str {
($input:expr) => {
String::from(
$input
.iter()
.collect::<PathBuf>()
.to_str()
.unwrap_or_else(|| panic!("Invalid path {}", stringify!($input))),
)
};
}
/// Configure the compiler to build kani-compiler binary. We currently support building
/// kani-compiler with nightly only. We also link to the rustup rustc_driver library for now.
pub fn main() {
// Add rustup to the rpath in order to properly link with the correct rustc version.
let rustup_home = env::var("RUSTUP_HOME").unwrap();
let rustup_tc = env::var("RUSTUP_TOOLCHAIN").unwrap();
let rustup_lib = path_str!([&rustup_home, "toolchains", &rustup_tc, "lib"]);
println!("cargo:rustc-link-arg-bin=kani-compiler=-Wl,-rpath,{}", rustup_lib);
// While we hard-code the above for development purposes, for a release/install we look
// in a relative location for a symlink to the local rust toolchain
let origin = if cfg!(target_os = "macos") { "@loader_path" } else { "$ORIGIN" };
println!("cargo:rustc-link-arg-bin=kani-compiler=-Wl,-rpath,{}/../toolchain/lib", origin);
}