diff options
| author | Román Cárdenas Rodríguez <rcardenas.rod@gmail.com> | 2024-03-20 21:06:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 20:06:47 +0000 |
| commit | 4060c3def88f82d4e4f48de7137ce365167ef265 (patch) | |
| tree | f326f0687092cab2b772952b579d63d12d3d34aa /xtask/src/cargo_command.rs | |
| parent | 22ac33a826dedacde5d3d5c0964ff072555a9b32 (diff) | |
RISC-V support over CLINT (#815)
* Rebase to master
* using interrupt_mod
* bug fixes
* fix other backends
* Add changelog
* forgot about rtic-macros
* backend-specific configuration
* core peripherals optional over macro argument
* pre_init_preprocessing binding
* CI for RISC-V (WIP)
* separation of concerns
* add targets for RISC-V examples
* remove qemu feature
* prepare examples folder
* move examples all together
* move ci out of examples
* minor changes
* add cortex-m
* new xtask: proof of concept
* fix build.yml
* feature typo
* clean rtic examples
* reproduce weird issue
* remove unsafe code in user app
* update dependencies
* allow builds on riscv32imc
* let's fix QEMU
* Update .github/workflows/build.yml
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
* New build.rs
* removing test features
* adapt ui test to new version of clippy
* add more examples to RISC-V backend
* proper configuration of heapless for riscv32imc
* opt-out examples for riscv32imc
* point to new version of riscv-slic
* adapt new macro bindings
* adapt examples and CI to stable
* fix cortex-m CI
* Review
---------
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
Diffstat (limited to 'xtask/src/cargo_command.rs')
| -rw-r--r-- | xtask/src/cargo_command.rs | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/xtask/src/cargo_command.rs b/xtask/src/cargo_command.rs index c5387c2..78e81b1 100644 --- a/xtask/src/cargo_command.rs +++ b/xtask/src/cargo_command.rs @@ -1,4 +1,4 @@ -use crate::{ExtraArguments, Target}; +use crate::{ExtraArguments, Platforms, Target}; use core::fmt; use std::path::PathBuf; @@ -15,6 +15,7 @@ pub enum CargoCommand<'a> { #[allow(dead_code)] Run { cargoarg: &'a Option<&'a str>, + platform: Platforms, // to tell which platform. If None, it assumes lm3s6965 example: &'a str, target: Option<Target<'a>>, features: Option<String>, @@ -23,6 +24,7 @@ pub enum CargoCommand<'a> { }, Qemu { cargoarg: &'a Option<&'a str>, + platform: Platforms, // to tell which platform. If None, it assumes lm3s6965 example: &'a str, target: Option<Target<'a>>, features: Option<String>, @@ -32,6 +34,7 @@ pub enum CargoCommand<'a> { }, ExampleBuild { cargoarg: &'a Option<&'a str>, + platform: Platforms, // to tell which platform. If None, it assumes lm3s6965 example: &'a str, target: Option<Target<'a>>, features: Option<String>, @@ -41,10 +44,12 @@ pub enum CargoCommand<'a> { }, ExampleCheck { cargoarg: &'a Option<&'a str>, + platform: Platforms, // to tell which platform. If None, it assumes lm3s6965 example: &'a str, target: Option<Target<'a>>, features: Option<String>, mode: BuildMode, + dir: Option<PathBuf>, deny_warnings: bool, }, Build { @@ -94,6 +99,7 @@ pub enum CargoCommand<'a> { }, ExampleSize { cargoarg: &'a Option<&'a str>, + platform: Platforms, // to tell which platform. If None, it assumes lm3s6965 example: &'a str, target: Option<Target<'a>>, features: Option<String>, @@ -137,6 +143,7 @@ impl core::fmt::Display for CargoCommand<'_> { features: &Option<String>, cargoarg: &&Option<&str>, path: Option<&PathBuf>, + // no need to add platform, as it is implicit in the path ) -> String { let feat = feat(features); let carg = carg(cargoarg); @@ -179,6 +186,7 @@ impl core::fmt::Display for CargoCommand<'_> { match self { CargoCommand::Run { cargoarg, + platform: _, example, target, features, @@ -193,6 +201,7 @@ impl core::fmt::Display for CargoCommand<'_> { } CargoCommand::Qemu { cargoarg, + platform: _, example, target, features, @@ -206,6 +215,7 @@ impl core::fmt::Display for CargoCommand<'_> { } CargoCommand::ExampleBuild { cargoarg, + platform: _, example, target, features, @@ -219,16 +229,18 @@ impl core::fmt::Display for CargoCommand<'_> { } CargoCommand::ExampleCheck { cargoarg, + platform: _, example, target, features, mode, + dir, deny_warnings, - } => write!( - f, - "Check example {example} {}", - details(*deny_warnings, target, Some(mode), features, cargoarg, None) - ), + } => { + let warns = *deny_warnings; + let details = details(warns, target, Some(mode), features, cargoarg, dir.as_ref()); + write!(f, "Check example {example} {details}",) + } CargoCommand::Build { cargoarg, package, @@ -329,17 +341,14 @@ impl core::fmt::Display for CargoCommand<'_> { .clone() .map(|t| format!("test {t}")) .unwrap_or("all tests".into()); - let deny_warnings = if *deny_warnings { - format!("deny warnings, ") - } else { - format!("") - }; - let feat = feat(features); - write!(f, "Run {test} in {p} ({deny_warnings}features: {feat})") + + let details = details(*deny_warnings, &None, None, features, &&None, None); + write!(f, "Run {test} in {p} {details}") } CargoCommand::Book { arguments: _ } => write!(f, "Build the book"), CargoCommand::ExampleSize { cargoarg, + platform: _, example, target, features, @@ -475,6 +484,7 @@ impl<'a> CargoCommand<'a> { // For future embedded-ci, for now the same as Qemu CargoCommand::Run { cargoarg, + platform: _, example, features, mode, @@ -491,6 +501,7 @@ impl<'a> CargoCommand<'a> { ), CargoCommand::Qemu { cargoarg, + platform: _, example, features, mode, @@ -606,6 +617,7 @@ impl<'a> CargoCommand<'a> { } CargoCommand::ExampleBuild { cargoarg, + platform: _, example, features, mode, @@ -624,9 +636,11 @@ impl<'a> CargoCommand<'a> { ), CargoCommand::ExampleCheck { cargoarg, + platform: _, example, features, mode, + dir: _, // Target is added by build_args target: _, // deny_warnings is exposed through `extra_env` @@ -640,6 +654,7 @@ impl<'a> CargoCommand<'a> { ), CargoCommand::ExampleSize { cargoarg, + platform: _, example, features, mode, @@ -664,6 +679,7 @@ impl<'a> CargoCommand<'a> { pub fn chdir(&self) -> Option<&PathBuf> { match self { CargoCommand::Qemu { dir, .. } + | CargoCommand::ExampleCheck { dir, .. } | CargoCommand::ExampleBuild { dir, .. } | CargoCommand::ExampleSize { dir, .. } | CargoCommand::Build { dir, .. } @@ -687,20 +703,35 @@ impl<'a> CargoCommand<'a> { } } - pub fn extra_env(&self) -> Option<(&str, &str)> { + pub fn extra_env(&self) -> Option<(&str, String)> { match self { // Clippy is a special case: it sets deny warnings // through an argument to rustc. CargoCommand::Clippy { .. } => None, - CargoCommand::Doc { .. } => Some(("RUSTDOCFLAGS", "-D warnings")), + CargoCommand::Doc { .. } => Some(("RUSTDOCFLAGS", "-D warnings".to_string())), - CargoCommand::Qemu { deny_warnings, .. } - | CargoCommand::ExampleBuild { deny_warnings, .. } - | CargoCommand::ExampleSize { deny_warnings, .. } => { + CargoCommand::Qemu { + platform, + deny_warnings, + .. + } + | CargoCommand::ExampleBuild { + platform, + deny_warnings, + .. + } + | CargoCommand::ExampleSize { + platform, + deny_warnings, + .. + } => { if *deny_warnings { + let rust_flags = platform.rust_flags().join(" "); + let rust_flags = format!("-D warnings {}", rust_flags); // NOTE: this also needs the link-arg because .cargo/config.toml // is ignored if you set the RUSTFLAGS env variable. - Some(("RUSTFLAGS", "-D warnings -C link-arg=-Tlink.x")) + Some(("RUSTFLAGS", rust_flags)) + // TODO make this configurable } else { None } @@ -711,7 +742,7 @@ impl<'a> CargoCommand<'a> { | CargoCommand::Build { deny_warnings, .. } | CargoCommand::Test { deny_warnings, .. } => { if *deny_warnings { - Some(("RUSTFLAGS", "-D warnings")) + Some(("RUSTFLAGS", "-D warnings".to_string())) } else { None } |
