diff --git a/xtask/src/arch.rs b/xtask/src/arch.rs index 46ca7674d9..52c743eb6f 100644 --- a/xtask/src/arch.rs +++ b/xtask/src/arch.rs @@ -17,10 +17,14 @@ pub enum Arch { impl Arch { pub fn install(&self) -> Result<()> { let sh = crate::sh()?; + let triple = self.triple(); + cmd!(sh, "rustup target add {triple}").run()?; + Ok(()) + } + + pub fn install_for_build(&self) -> Result<()> { if self == &Self::X86_64 { - eprintln!("Installing target"); - let triple = self.triple(); - cmd!(sh, "rustup target add {triple}").run()?; + self.install()?; } Ok(()) } diff --git a/xtask/src/build.rs b/xtask/src/build.rs index e4afe179dc..24c3b22a2e 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -26,7 +26,7 @@ impl Build { pub fn run(self) -> Result<()> { let sh = crate::sh()?; - self.cargo_build.artifact.arch.install()?; + self.cargo_build.artifact.arch.install_for_build()?; eprintln!("Building kernel"); cmd!(sh, "cargo build") diff --git a/xtask/src/clippy.rs b/xtask/src/clippy.rs index 6b86a7e7c7..c8f0d13e6a 100644 --- a/xtask/src/clippy.rs +++ b/xtask/src/clippy.rs @@ -15,29 +15,32 @@ impl Clippy { for target in [Arch::X86_64, Arch::Aarch64] { target.install()?; - let target_args = target.cargo_args(); - cmd!(sh, "cargo clippy {target_args...}").run()?; - cmd!(sh, "cargo clippy {target_args...}") + let triple = target.triple(); + cmd!(sh, "cargo clippy --target={triple}").run()?; + cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") .run()?; - cmd!(sh, "cargo clippy {target_args...}") + cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") .arg("--features=acpi,fsgsbase,pci,smp,vga") .run()?; // TODO: Enable clippy for newlib // https://github.com/hermit-os/kernel/issues/470 - // cmd!(sh, "cargo clippy {target_args...}") + // cmd!(sh, "cargo clippy --target={triple}") // .arg("--no-default-features") // .arg("--features=acpi,fsgsbase,newlib,smp,vga") // .run()?; } { - let target_args = Arch::Riscv64.cargo_args(); - cmd!(sh, "cargo clippy {target_args...}") + let target = Arch::Riscv64; + target.install()?; + + let triple = target.triple(); + cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") .run()?; - cmd!(sh, "cargo clippy {target_args...}") + cmd!(sh, "cargo clippy --target={triple}") .arg("--no-default-features") .arg("--features=smp,tcp") .run()?;