Skip to content

Commit

Permalink
Merge branch 'pilip/cleanup' into 'master'
Browse files Browse the repository at this point in the history
Clean up build.rs

See merge request TankerHQ/sdk-rust!62
  • Loading branch information
blastrock committed Sep 13, 2021
2 parents 1c46a03 + 2720483 commit 8136eba
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,35 @@ fn main() -> Result<(), Box<dyn Error>> {
panic!(
"Target platform {} is not supported ({} does not exist)",
target_triplet,
bindings_folder.to_string_lossy()
bindings_folder.display()
);
}
if target_family == "unix" && !bindings_folder.join(lib_filename).exists() {
if target_family != "windows" && !bindings_folder.join(lib_filename).exists() {
panic!(
"Couldn't find {} in {}",
lib_filename,
bindings_folder.to_string_lossy()
bindings_folder.display()
);
}
if !bindings_folder.join(BINDGEN_OUTPUT_FILENAME).exists() {
panic!(
"Couldn't find the bindgen-generated {} in {}",
BINDGEN_OUTPUT_FILENAME,
bindings_folder.to_string_lossy()
bindings_folder.display()
);
}

let bindings_folder = bindings_folder.to_str().expect("Invalid character in path");

println!(
"cargo:rerun-if-changed={}/{}",
bindings_folder.to_string_lossy(),
BINDGEN_OUTPUT_FILENAME
bindings_folder, BINDGEN_OUTPUT_FILENAME
);
println!(
"cargo:rerun-if-changed={}/{}",
bindings_folder.to_string_lossy(),
lib_filename
bindings_folder, lib_filename
);

let bindings_folder = bindings_folder.to_string_lossy();

// Paths can contain anything, but env vars are a liiitle more restricted. Sanity checks!
assert!(!bindings_folder.contains(&"="));
assert!(!bindings_folder.contains(&"\0"));
Expand All @@ -58,7 +56,7 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rustc-env=NATIVE_BINDINGS_FOLDER={}", bindings_folder);

// Tell cargo to link with our native library
if target_family == "unix" {
if target_family != "windows" {
println!("cargo:rustc-link-search={}", bindings_folder);
println!("cargo:rustc-link-lib=static=ctanker",);
match target_triplet.as_str() {
Expand Down

0 comments on commit 8136eba

Please sign in to comment.