Skip to content
Snippets Groups Projects
Unverified Commit 7c2ba33b authored by bors[bot]'s avatar bors[bot] Committed by GitHub
Browse files

Merge #454


454: Apply loader's xtask updates r=mkroening a=mkroening



Co-authored-by: default avatarMartin Kröning <mkroening@posteo.net>
parents 6cc34a22 cc5e0b2b
No related branches found
No related tags found
No related merge requests found
Pipeline #722630 passed
......@@ -126,6 +126,12 @@ version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
[[package]]
name = "llvm-tools"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955be5d0ca0465caf127165acb47964f911e2bc26073e865deb8be7189302faf"
[[package]]
name = "log"
version = "0.4.17"
......@@ -405,15 +411,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "rusty-hermit"
version = "0.4.0"
......@@ -463,12 +460,6 @@ dependencies = [
"syn",
]
[[package]]
name = "semver"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
[[package]]
name = "shell-words"
version = "1.1.0"
......@@ -603,7 +594,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"goblin",
"rustc_version",
"llvm-tools",
"xflags",
"xshell",
]
......@@ -6,6 +6,6 @@ edition = "2021"
[dependencies]
anyhow = "1.0"
goblin = { version = "0.5", default-features = false, features = ["archive", "elf32", "elf64", "std"] }
rustc_version = "0.4"
llvm-tools = "0.1"
xflags = "0.2"
xshell = "0.2"
//! See <https://github.com/matklad/cargo-xtask/>.
mod flags;
mod rustc;
use std::{
env::{self, VarError},
......@@ -11,6 +10,7 @@ use std::{
use anyhow::{anyhow, Result};
use goblin::{archive::Archive, elf64::header};
use llvm_tools::LlvmTools;
use xshell::{cmd, Shell};
const RUSTFLAGS: &[&str] = &[
......@@ -47,7 +47,6 @@ impl flags::Build {
.args(self.target_dir_args())
.args(self.no_default_features_args())
.args(self.features_args())
.args(self.release_args())
.args(self.profile_args())
.run()?;
......@@ -106,19 +105,8 @@ impl flags::Build {
}
}
fn release_args(&self) -> &[&str] {
if self.release {
&["--release"]
} else {
&[]
}
}
fn profile_args(&self) -> Vec<&str> {
match self.profile.as_deref() {
Some(profile) => vec!["--profile", profile],
None => vec![],
}
vec!["--profile", self.profile()]
}
fn set_osabi(&self) -> Result<()> {
......@@ -287,8 +275,11 @@ fn binutil(name: &str) -> Result<PathBuf> {
let exe_suffix = env::consts::EXE_SUFFIX;
let exe = format!("llvm-{name}{exe_suffix}");
let mut path = rustc::rustlib()?;
path.push(exe);
let path = LlvmTools::new()
.map_err(|err| anyhow!("{err:?}"))?
.tool(&exe)
.ok_or_else(|| anyhow!("could not find {exe}"))?;
Ok(path)
}
......
//! Taken from <https://github.com/rust-embedded/cargo-binutils/blob/980607cf8e4bb1b7db5cc7a35aafa38463818f7e/src/rustc.rs>.
use std::env;
use std::path::PathBuf;
use std::process::Command;
use anyhow::Result;
pub fn sysroot() -> Result<String> {
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
let output = Command::new(rustc).arg("--print").arg("sysroot").output()?;
// Note: We must trim() to remove the `\n` from the end of stdout
Ok(String::from_utf8(output.stdout)?.trim().to_owned())
}
// See: https://github.com/rust-lang/rust/blob/564758c4c329e89722454dd2fbb35f1ac0b8b47c/src/bootstrap/dist.rs#L2334-L2341
pub fn rustlib() -> Result<PathBuf> {
let sysroot = sysroot()?;
let mut pathbuf = PathBuf::from(sysroot);
pathbuf.push("lib");
pathbuf.push("rustlib");
pathbuf.push(rustc_version::version_meta()?.host); // TODO: Prevent calling rustc_version::version_meta() multiple times
pathbuf.push("bin");
Ok(pathbuf)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment