diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:42 +0000 |
commit | 837b550238aa671a591ccf282dddeab29cadb206 (patch) | |
tree | 914b6b8862bace72bd3245ca184d374b08d8a672 /vendor/link-cplusplus/build.rs | |
parent | Adding debian version 1.70.0+dfsg2-1. (diff) | |
download | rustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz rustc-837b550238aa671a591ccf282dddeab29cadb206.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/link-cplusplus/build.rs')
-rw-r--r-- | vendor/link-cplusplus/build.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/link-cplusplus/build.rs b/vendor/link-cplusplus/build.rs new file mode 100644 index 000000000..1f679229e --- /dev/null +++ b/vendor/link-cplusplus/build.rs @@ -0,0 +1,34 @@ +use std::env; +use std::fs; +use std::path::PathBuf; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let libstdcxx = cfg!(feature = "libstdc++"); + let libcxx = cfg!(feature = "libc++"); + let nothing = cfg!(feature = "nothing"); + + if nothing { + return; + } + + if libstdcxx && libcxx { + println!( + "cargo:warning=-lstdc++ and -lc++ are both requested, \ + using the platform's default" + ); + } + + match (libstdcxx, libcxx) { + (true, false) => println!("cargo:rustc-link-lib=stdc++"), + (false, true) => println!("cargo:rustc-link-lib=c++"), + (false, false) | (true, true) => { + // The platform's default. + let out_dir = env::var_os("OUT_DIR").expect("missing OUT_DIR"); + let path = PathBuf::from(out_dir).join("dummy.cc"); + fs::write(&path, "int rust_link_cplusplus;\n").unwrap(); + cc::Build::new().cpp(true).file(&path).compile("link-cplusplus"); + } + } +} |