Browse Source

Merge pull request #311 from tomaka/cxxstdlib

Allow overwriting the default cpp_link_stdlib
cl-test
Alex Crichton 7 years ago
committed by GitHub
parent
commit
a4790a6255
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/lib.rs

10
src/lib.rs

@ -582,6 +582,8 @@ impl Build {
/// The default value of this property depends on the current target: On /// The default value of this property depends on the current target: On
/// OS X `Some("c++")` is used, when compiling for a Visual Studio based /// OS X `Some("c++")` is used, when compiling for a Visual Studio based
/// target `None` is used and for other targets `Some("stdc++")` is used. /// target `None` is used and for other targets `Some("stdc++")` is used.
/// If the `CXXSTDLIB` environment variable is set, its value will
/// override the default value.
/// ///
/// A value of `None` indicates that no automatic linking should happen, /// A value of `None` indicates that no automatic linking should happen,
/// otherwise cargo will link against the specified library. /// otherwise cargo will link against the specified library.
@ -1716,6 +1718,13 @@ impl Build {
match self.cpp_link_stdlib.clone() { match self.cpp_link_stdlib.clone() {
Some(s) => Ok(s), Some(s) => Ok(s),
None => { None => {
if let Ok(stdlib) = self.get_var("CXXSTDLIB") {
if stdlib.is_empty() {
Ok(None)
} else {
Ok(Some(stdlib))
}
} else {
let target = self.get_target()?; let target = self.get_target()?;
if target.contains("msvc") { if target.contains("msvc") {
Ok(None) Ok(None)
@ -1731,6 +1740,7 @@ impl Build {
} }
} }
} }
}
fn get_ar(&self) -> Result<(Command, String), Error> { fn get_ar(&self) -> Result<(Command, String), Error> {
if let Some(ref p) = self.archiver { if let Some(ref p) = self.archiver {

Loading…
Cancel
Save