-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reenable cap-async-std. async-std 1.13.0 is now released with the "io_safety" feature, which means we can now reenable cap-async-std. * Update to io-extras 0.18.3.
- Loading branch information
1 parent
ef0c8ac
commit f38cbd7
Showing
18 changed files
with
329 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
use std::env::var; | ||
use std::io::Write; | ||
|
||
fn main() { | ||
use_feature_or_nothing("windows_file_type_ext"); | ||
|
||
// Cfgs that users may set. | ||
println!("cargo:rustc-check-cfg=cfg(io_lifetimes_use_std)"); | ||
|
||
// Don't rerun this on changes other than build.rs, as we only depend on | ||
// the rustc version. | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
} | ||
|
||
fn use_feature_or_nothing(feature: &str) { | ||
if has_feature(feature) { | ||
use_feature(feature); | ||
} | ||
println!("cargo:rustc-check-cfg=cfg({})", feature); | ||
} | ||
|
||
fn use_feature(feature: &str) { | ||
println!("cargo:rustc-cfg={}", feature); | ||
} | ||
|
||
/// Test whether the rustc at `var("RUSTC")` supports the given feature. | ||
fn has_feature(feature: &str) -> bool { | ||
can_compile(&format!( | ||
"#![allow(stable_features)]\n#![feature({})]", | ||
feature | ||
)) | ||
} | ||
|
||
/// Test whether the rustc at `var("RUSTC")` can compile the given code. | ||
fn can_compile<T: AsRef<str>>(test: T) -> bool { | ||
use std::process::Stdio; | ||
|
||
let out_dir = var("OUT_DIR").unwrap(); | ||
let rustc = var("RUSTC").unwrap(); | ||
let target = var("TARGET").unwrap(); | ||
|
||
// Use `RUSTC_WRAPPER` if it's set, unless it's set to an empty string, | ||
// as documented [here]. | ||
// [here]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads | ||
let wrapper = var("RUSTC_WRAPPER") | ||
.ok() | ||
.and_then(|w| if w.is_empty() { None } else { Some(w) }); | ||
|
||
let mut cmd = if let Some(wrapper) = wrapper { | ||
let mut cmd = std::process::Command::new(wrapper); | ||
// The wrapper's first argument is supposed to be the path to rustc. | ||
cmd.arg(rustc); | ||
cmd | ||
} else { | ||
std::process::Command::new(rustc) | ||
}; | ||
|
||
cmd.arg("--crate-type=rlib") // Don't require `main`. | ||
.arg("--emit=metadata") // Do as little as possible but still parse. | ||
.arg("--target") | ||
.arg(target) | ||
.arg("--out-dir") | ||
.arg(out_dir); // Put the output somewhere inconsequential. | ||
|
||
// If Cargo wants to set RUSTFLAGS, use that. | ||
if let Ok(rustflags) = var("CARGO_ENCODED_RUSTFLAGS") { | ||
if !rustflags.is_empty() { | ||
for arg in rustflags.split('\x1f') { | ||
cmd.arg(arg); | ||
} | ||
} | ||
} | ||
|
||
let mut child = cmd | ||
.arg("-") // Read from stdin. | ||
.stdin(Stdio::piped()) // Stdin is a pipe. | ||
.stderr(Stdio::null()) // Errors from feature detection aren't interesting and can be confusing. | ||
.spawn() | ||
.unwrap(); | ||
|
||
writeln!(child.stdin.take().unwrap(), "{}", test.as_ref()).unwrap(); | ||
|
||
child.wait().unwrap().success() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.