use std::env; //use std::ffi::OsString; //use std::process::Command;
fn main() { // We don't currently need to check the Version anymore... // But leaving this in place in case we need to in the future. /* letrustc=env::var_os("RUSTC").unwrap_or(OsString::from("rustc")); letoutput=Command::new(&rustc) .arg("--version") .output() .expect("failedtocheck'rustc--version'") .stdout;
fn enable_simd(/*version: Version*/) { if env::var_os("CARGO_FEATURE_STD").is_none() {
println!("cargo:warning=building for no_std disables httparse SIMD"); return;
} if env::var_os("CARGO_CFG_MIRI").is_some() {
println!("cargo:warning=building for Miri disables httparse SIMD"); return;
}
let env_disable = "CARGO_CFG_HTTPARSE_DISABLE_SIMD"; if var_is(env_disable, "1") {
println!("cargo:warning=detected {} environment variable, disabling SIMD", env_disable); return;
}
println!("cargo:rustc-cfg=httparse_simd");
// cfg(target_feature) isn't stable yet, but CARGO_CFG_TARGET_FEATURE has // a list... We aren't doing anything unsafe, since the is_x86_feature_detected // macro still checks in the actual lib, BUT! // // By peeking at the list here, we can change up slightly how we do feature // detection in the lib. If our features aren't in the feature list, we // stick with a cached runtime detection strategy. // // But if the features *are* in the list, we benefit from removing our cache, // since the compiler will eliminate several branches with its internal // cfg(target_feature) usage.
let env_runtime_only = "CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME"; if var_is(env_runtime_only, "1") {
println!("cargo:warning=detected {} environment variable, using runtime SIMD detection only", env_runtime_only); return;
} let feature_list = match env::var_os("CARGO_CFG_TARGET_FEATURE") {
Some(var) => match var.into_string() {
Ok(s) => s,
Err(_) => {
println!("cargo:warning=CARGO_CFG_TARGET_FEATURE was not valid utf-8"); return;
},
},
None => {
println!("cargo:warning=CARGO_CFG_TARGET_FEATURE was not set"); return
},
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.