/// Supposed to be used for all variables except those set for build scripts by cargo
/// <https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts>
fn tracked_env_var_os<K: AsRef<OsStr> + Display>(key: K) -> Option<OsString> {
- println!("cargo:rerun-if-env-changed={}", key);
+ println!("cargo:rerun-if-env-changed={key}");
env::var_os(key)
}
let output = match cmd.stderr(Stdio::inherit()).output() {
Ok(status) => status,
Err(e) => {
- println!("\n\nfailed to execute command: {:?}\nerror: {}\n\n", cmd, e);
+ println!("\n\nfailed to execute command: {cmd:?}\nerror: {e}\n\n");
std::process::exit(1);
}
};
fn main() {
for component in REQUIRED_COMPONENTS.iter().chain(OPTIONAL_COMPONENTS.iter()) {
- println!("cargo:rustc-check-cfg=values(llvm_component,\"{}\")", component);
+ println!("cargo:rustc-check-cfg=values(llvm_component,\"{component}\")");
}
if tracked_env_var_os("RUST_CHECK").is_some() {
for component in REQUIRED_COMPONENTS {
if !components.contains(component) {
- panic!("require llvm component {} but wasn't found", component);
+ panic!("require llvm component {component} but wasn't found");
}
}
for component in components.iter() {
- println!("cargo:rustc-cfg=llvm_component=\"{}\"", component);
+ println!("cargo:rustc-cfg=llvm_component=\"{component}\"");
}
// Link in our own LLVM shims, compiled with the same flags as LLVM
}
let kind = if name.starts_with("LLVM") { llvm_kind } else { "dylib" };
- println!("cargo:rustc-link-lib={}={}", kind, name);
+ println!("cargo:rustc-link-lib={kind}={name}");
}
// LLVM ldflags
println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
}
} else if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
- println!("cargo:rustc-link-search=native={}", stripped);
+ println!("cargo:rustc-link-search=native={stripped}");
} else if let Some(stripped) = lib.strip_prefix("-l") {
- println!("cargo:rustc-link-lib={}", stripped);
+ println!("cargo:rustc-link-lib={stripped}");
} else if let Some(stripped) = lib.strip_prefix("-L") {
- println!("cargo:rustc-link-search=native={}", stripped);
+ println!("cargo:rustc-link-search=native={stripped}");
}
}
if let Some(s) = llvm_linker_flags {
for lib in s.into_string().unwrap().split_whitespace() {
if let Some(stripped) = lib.strip_prefix("-l") {
- println!("cargo:rustc-link-lib={}", stripped);
+ println!("cargo:rustc-link-lib={stripped}");
} else if let Some(stripped) = lib.strip_prefix("-L") {
- println!("cargo:rustc-link-search=native={}", stripped);
+ println!("cargo:rustc-link-search=native={stripped}");
}
}
}
let path = PathBuf::from(s);
println!("cargo:rustc-link-search=native={}", path.parent().unwrap().display());
if target.contains("windows") {
- println!("cargo:rustc-link-lib=static:-bundle={}", stdcppname);
+ println!("cargo:rustc-link-lib=static:-bundle={stdcppname}");
} else {
- println!("cargo:rustc-link-lib=static={}", stdcppname);
+ println!("cargo:rustc-link-lib=static={stdcppname}");
}
} else if cxxflags.contains("stdlib=libc++") {
println!("cargo:rustc-link-lib=c++");
} else {
- println!("cargo:rustc-link-lib={}", stdcppname);
+ println!("cargo:rustc-link-lib={stdcppname}");
}
}