From 84c6d647290667678ca58f7c2035b695acda8d80 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 12 Aug 2022 06:52:52 +0000 Subject: [PATCH] Add RiscV target installation --- src/main.rs | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e81c69c..e58ddb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,10 +23,11 @@ use std::fs; // General TODOs: // - Prettify prints (add emojis) +// - Reorder files: toolchain (esp, clang and gcc instalaltion), utils(?) // - Add subcommand test that downloads a projects and builds it // - Esp-idf version should be contained in an enum with the possible values (see chips in espflash for reference) // - Check if LdProxy is needed when no esp-idf is installed (if not needed only install it for esp-idf) -// - Do a Tauri App so we can install it with gui +// - Do a Tauri App so we can install it with gui. If no subcommand is passed, run gui installator // - Add tests // - Clean unused code // - Add progress bar @@ -278,6 +279,12 @@ fn install(args: InstallOpts) -> Result<()> { exports.push(format!("export LIBCLANG_PATH=\"{}\"", &libclang_path)); // TODO: Insall riscv target in nigthly if installing esp32c3 + if targets.contains(&Chip::Esp32c3) { + println!("Installing riscv target"); + install_riscv_target(&args.nightly_version); + } + + if args.espidf_version.is_some() { idf::install_espidf(&args.build_target, args.espidf_version.unwrap())?; @@ -383,6 +390,45 @@ fn install_rust_nightly(version: &str) { } } +fn install_riscv_target(version: &str){ + + match std::process::Command::new("rustup") + .arg("component") + .arg("add") + .arg("rust-src") + .arg("--toolchain") + .arg(version) + .stdout(Stdio::piped()) + .output() + { + Ok(child_output) => { + let result = String::from_utf8_lossy(&child_output.stdout); + println!("Rust-src for RiscV target installed suscesfully: {}", result); + } + Err(e) => { + println!("Rust-src for RiscV target installation failed: {}", e); + } + } + + match std::process::Command::new("rustup") + .arg("target") + .arg("add") + .arg("--toolchain") + .arg(version) + .arg("riscv32imc-unknown-none-elf") + .stdout(Stdio::piped()) + .output() + { + Ok(child_output) => { + let result = String::from_utf8_lossy(&child_output.stdout); + println!("RiscV target installed suscesfully: {}", result); + } + Err(e) => { + println!("RiscV target installation failed: {}", e); + } + } +} + fn install_rustup() { #[cfg(windows)] let rustup_init_path =