Print the c++ library that cargo should link against

This is used when calling "cargo build" when no actual recompile is needed.

BUG: 400393
master
Jos van den Oever 2018-10-28 22:05:20 +01:00
parent ed2de05492
commit 89c86642f8
1 changed files with 19 additions and 1 deletions

View File

@ -238,7 +238,7 @@ impl Build {
// normally cc::Build outputs this information
println!("cargo:rustc-link-lib=static={}", lib_name);
println!("cargo:rustc-link-search=native={}", self.out_dir.display());
println!("cargo:rustc-link-lib=stdc++");
print_cpp_link_stdlib();
}
println!("cargo:rustc-link-search={}", self.qt_library_path.display());
println!("cargo:rustc-link-lib=Qt5Core");
@ -248,6 +248,24 @@ impl Build {
}
}
// Print the c++ library that cargo should link against
// This is used when calling 'cargo build' when no actual recompile is needed.
fn print_cpp_link_stdlib() {
let target = ::std::env::var("TARGET").unwrap();
let stdlib = if target.contains("msvc") {
None
} else if target.contains("apple")
|| target.contains("freebsd")
|| target.contains("openbsd") {
Some("c++")
} else {
Some("stdc++")
};
if let Some(stdlib) = stdlib {
println!("cargo:rustc-link-lib={}", stdlib);
}
}
/// Return true if all outputs and exist are older than the given input time.
fn are_outputs_up_to_date(paths: &[&Path], input: SystemTime) -> bool {
for path in paths {