From 7dc66b012ea0534cd6dbff72b13c42927b0fc9cd Mon Sep 17 00:00:00 2001 From: Frederick Vollbrecht Date: Wed, 8 Nov 2023 16:46:25 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A9=20add=20flag=20to=20only=20install?= =?UTF-8?q?=20riscv=20if=20user=20wants=20(#391)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚩 add flag to only install riscv if user wants * clippy * rename flag to esp_riscv_gcc * update comments * 📝 update CHANGEL + README * ✏️ typo * Update src/cli.rs Co-authored-by: Sergio Gasquez Arcos * Update src/toolchain/mod.rs Co-authored-by: Sergio Gasquez Arcos * alphabetical ordering --------- Co-authored-by: Sergio Gasquez Arcos --- CHANGELOG.md | 2 ++ README.md | 5 +++++ src/cli.rs | 5 +++++ src/toolchain/mod.rs | 6 +++--- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41695357..0ac0254f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Added new `--esp-riscv-gcc` flag to install esp-riscv-gcc toolchain instead of the system one (#391) ### Fixed ### Changed +- New Default behavior: install esp-riscv-gcc only if the user explicitly uses the `--esp-riscv-gcc` flag (#391) ### Removed diff --git a/README.md b/README.md index b05e58cf..f201f980 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,11 @@ Options: [possible values: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin] +-r, --esp-riscv-gcc + Install Espressif RISC-V toolchain built with croostool-ng + + Only install this if you don't want to use the systems RISC-V toolchain + -f, --export-file Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html) diff --git a/src/cli.rs b/src/cli.rs index 950428fc..c02e1da4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -19,6 +19,11 @@ pub struct InstallOpts { /// Target triple of the host. #[arg(short = 'd', long, value_parser = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu" , "x86_64-apple-darwin" , "aarch64-apple-darwin"])] pub default_host: Option, + /// Install Espressif RISC-V toolchain built with croostool-ng + /// + /// Only install this if you don't want to use the systems RISC-V toolchain + #[arg(short = 'r', long)] + pub esp_riscv_gcc: bool, /// Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html). #[arg(short = 'f', long)] pub export_file: Option, diff --git a/src/toolchain/mod.rs b/src/toolchain/mod.rs index 1ca9c965..5d09f8d6 100644 --- a/src/toolchain/mod.rs +++ b/src/toolchain/mod.rs @@ -215,9 +215,9 @@ pub async fn install(args: InstallOpts, install_mode: InstallMode) -> Result<()> let xtensa_gcc = Gcc::new(XTENSA_GCC, &host_triple, &toolchain_dir); to_install.push(Box::new(xtensa_gcc)); } - // All RISC-V targets use the same GCC toolchain - // ESP32S2 and ESP32S3 also install the RISC-V toolchain for their ULP coprocessor - if targets.iter().any(|t| t != &Target::ESP32) { + + // By default only install the Espressif RISC-V toolchain if the user explicitly wants to + if args.esp_riscv_gcc && targets.iter().any(|t| t != &Target::ESP32) { let riscv_gcc = Gcc::new(RISCV_GCC, &host_triple, &toolchain_dir); to_install.push(Box::new(riscv_gcc)); }