diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 87614fdcb..249c97e8b 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -269,19 +269,44 @@ fn build_package(workspace: &Path, chip: &Chip) -> Result<()> { let target = build_target(&path)?; log::info!("building PAC using '{channel}' channel and targeting '{target}'"); - Command::new("cargo") - .args([ - &format!("+{channel}"), - "build", - "-Z", - "build-std=core", - "--target", - &target, - ]) - .current_dir(path) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .output()?; + + if target.starts_with("riscv") { + Command::new("rustup") + .args([ + "target", + "add", + &target, + ]) + .current_dir(&path) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .output()?; + Command::new("cargo") + .args([ + &format!("+{channel}"), + "build", + "--target", + &target, + ]) + .current_dir(path) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .output()?; + } else { + Command::new("cargo") + .args([ + &format!("+{channel}"), + "build", + "-Z", + "build-std=core", + "--target", + &target, + ]) + .current_dir(path) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .output()?; + } Ok(()) }