From 4060c3def88f82d4e4f48de7137ce365167ef265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas=20Rodr=C3=ADguez?= Date: Wed, 20 Mar 2024 21:06:47 +0100 Subject: RISC-V support over CLINT (#815) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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 --- xtask/src/run.rs | 78 ++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 45 deletions(-) (limited to 'xtask/src/run.rs') diff --git a/xtask/src/run.rs b/xtask/src/run.rs index 6057551..ff81e6a 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -15,7 +15,9 @@ mod iter; use iter::{into_iter, CoalescingRunner}; use crate::{ - argument_parsing::{Backends, BuildOrCheck, ExtraArguments, Globals, PackageOpt, TestMetadata}, + argument_parsing::{ + Backends, BuildOrCheck, ExtraArguments, Globals, PackageOpt, Platforms, TestMetadata, + }, cargo_command::{BuildMode, CargoCommand}, }; @@ -62,7 +64,12 @@ fn command_parser( }; match *command { - CargoCommand::Qemu { example, .. } | CargoCommand::Run { example, .. } => { + CargoCommand::Qemu { + platform, example, .. + } + | CargoCommand::Run { + platform, example, .. + } => { /// Check if `run` was successful. /// returns Ok in case the run went as expected, /// Err otherwise @@ -99,8 +106,9 @@ fn command_parser( res } + let platform_name = platform.name(); let run_file = format!("{example}.run"); - let expected_output_file = ["rtic", "ci", "expected", &run_file] + let expected_output_file = ["ci", "expected", &platform_name, &run_file] .iter() .collect::() .into_os_string() @@ -191,72 +199,41 @@ pub fn cargo<'c>( runner.run_and_coalesce() } -/// Cargo command to build a usage example. -/// -/// The usage examples are in examples/ -pub fn cargo_usage_example( - globals: &Globals, - operation: BuildOrCheck, - usage_examples: Vec, -) -> Vec> { - into_iter(&usage_examples) - .map(|example| { - let path = format!("examples/{example}"); - - let command = match operation { - BuildOrCheck::Check => CargoCommand::Check { - cargoarg: &None, - mode: BuildMode::Release, - dir: Some(path.into()), - package: None, - target: None, - features: None, - deny_warnings: globals.deny_warnings, - }, - BuildOrCheck::Build => CargoCommand::Build { - cargoarg: &None, - package: None, - target: None, - features: None, - mode: BuildMode::Release, - dir: Some(path.into()), - deny_warnings: globals.deny_warnings, - }, - }; - (globals, command, false) - }) - .run_and_coalesce() -} - /// Cargo command to either build or check all examples /// -/// The examples are in rtic/examples +/// The examples are in examples//examples pub fn cargo_example<'c>( globals: &Globals, operation: BuildOrCheck, cargoarg: &'c Option<&'c str>, + platform: Platforms, backend: Backends, examples: &'c [String], ) -> Vec> { let runner = into_iter(examples).map(|example| { + let path = format!("examples/{}", platform.name()); + let dir = Some(PathBuf::from(path)); let features = Some(backend.to_target().and_features(backend.to_rtic_feature())); let command = match operation { BuildOrCheck::Check => CargoCommand::ExampleCheck { cargoarg, + platform, example, target: Some(backend.to_target()), features, mode: BuildMode::Release, + dir, deny_warnings: globals.deny_warnings, }, BuildOrCheck::Build => CargoCommand::ExampleBuild { cargoarg, + platform, example, target: Some(backend.to_target()), features, mode: BuildMode::Release, - dir: Some(PathBuf::from("./rtic")), + dir, deny_warnings: globals.deny_warnings, }, }; @@ -368,9 +345,12 @@ pub fn cargo_book<'c>( /// Run examples /// /// Supports updating the expected output via the overwrite argument +/// +/// The examples are in examples//examples pub fn qemu_run_examples<'c>( globals: &Globals, cargoarg: &'c Option<&'c str>, + platform: Platforms, backend: Backends, examples: &'c [String], overwrite: bool, @@ -380,11 +360,13 @@ pub fn qemu_run_examples<'c>( into_iter(examples) .flat_map(|example| { + let path = format!("examples/{}", platform.name()); + let dir = Some(PathBuf::from(path)); let target = target.into(); - let dir = Some(PathBuf::from("./rtic")); let cmd_build = CargoCommand::ExampleBuild { cargoarg: &None, + platform, example, target, features: features.clone(), @@ -395,6 +377,7 @@ pub fn qemu_run_examples<'c>( let cmd_qemu = CargoCommand::Qemu { cargoarg, + platform, example, target, features: features.clone(), @@ -413,6 +396,7 @@ pub fn qemu_run_examples<'c>( pub fn build_and_check_size<'c>( globals: &Globals, cargoarg: &'c Option<&'c str>, + platform: Platforms, backend: Backends, examples: &'c [String], arguments: &'c Option, @@ -422,27 +406,31 @@ pub fn build_and_check_size<'c>( let runner = into_iter(examples) .flat_map(|example| { + let path = format!("examples/{}", platform.name()); + let dir = Some(PathBuf::from(path)); let target = target.into(); // Make sure the requested example(s) are built let cmd_build = CargoCommand::ExampleBuild { cargoarg: &Some("--quiet"), + platform, example, target, features: features.clone(), mode: BuildMode::Release, - dir: Some(PathBuf::from("./rtic")), + dir: dir.clone(), deny_warnings: globals.deny_warnings, }; let cmd_size = CargoCommand::ExampleSize { cargoarg, + platform, example, target, features: features.clone(), mode: BuildMode::Release, arguments: arguments.clone(), - dir: Some(PathBuf::from("./rtic")), + dir, deny_warnings: globals.deny_warnings, }; -- cgit v1.2.3