diff options
author | Brian Cully <bjc@kublai.com> | 2022-11-06 16:34:44 -0500 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2022-11-06 16:37:38 -0500 |
commit | 20377d4522d513b66406d4ef8231a7cdbfedc157 (patch) | |
tree | 3b391f48c056c8a0fadbb3915dac11984a8b814d | |
parent | a484a97111d0897ac6e0e291c4432a91ebdee416 (diff) | |
download | luchie-20377d4522d513b66406d4ef8231a7cdbfedc157.tar.gz luchie-20377d4522d513b66406d4ef8231a7cdbfedc157.zip |
cargo: rejigger crate type
convert to hybrid crate, with arch-dependent stuff as a ‘bin’ crate,
with the underlying support in ‘lib’.
the reason for this change is to allow for automated unit-testing on
the device-independent bits. to facilitate this, a ‘t’ alias is
provided which will run the unit tests. this target assumes you're on
a linux system, but you can't have everything.
-rw-r--r-- | .cargo/config.toml | 5 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rwxr-xr-x | src/bin/luchie.rs (renamed from src/main.rs) | 10 | ||||
-rwxr-xr-x | src/lib.rs | 18 | ||||
-rw-r--r-- | src/logger.rs (renamed from src/log.rs) | 2 |
5 files changed, 32 insertions, 7 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml index 4339ec3..68eea01 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,8 +1,11 @@ +[alias] +t = "test --target x86_64-unknown-linux-gnu" + [build] target = "thumbv7em-none-eabihf" [target.thumbv7em-none-eabihf] -runner = "arm-none-eabi-gdb" +runner = "arm-none-eabi-gdb -i=mi" rustflags = [ "-C", "link-arg=-Tlink.x", ] @@ -35,5 +35,9 @@ name = "luchie" test = false bench = false +[lib] +test = true +bench = true + [patch.crates-io] #usb-device = { path = "../usb-device" } diff --git a/src/main.rs b/src/bin/luchie.rs index 9797da5..7dedc8d 100755 --- a/src/main.rs +++ b/src/bin/luchie.rs @@ -3,10 +3,10 @@ //extern crate panic_semihosting; -mod cirque; -mod log; - -use cirque::Cirque; +use luchie::{ + cirque::Cirque, + log, logger, logln, +}; use cortex_m::{ asm::{bkpt, wfi}, @@ -62,7 +62,7 @@ fn main() -> ! { ); let (tx, _) = serial.split(); - log::init(tx); + logger::init(tx); logln!("🐁 luchie starting…"); diff --git a/src/lib.rs b/src/lib.rs new file mode 100755 index 0000000..821bdeb --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,18 @@ +#![no_std] + +pub mod cirque; +pub mod logger; + +#[cfg(test)] +mod tests { + #[test] + fn pass() { + assert!(0 == 0); + } + + #[test] + #[should_panic] + fn fail() { + assert!(1 == 0); + } +} diff --git a/src/log.rs b/src/logger.rs index ccc9ebc..453e268 100644 --- a/src/log.rs +++ b/src/logger.rs @@ -8,7 +8,7 @@ use cortex_m::interrupt::{self, Mutex}; #[macro_export] macro_rules! log { ($($args:tt)+) => { - $crate::log::log_args(core::format_args!($($args)+)) + $crate::logger::log_args(core::format_args!($($args)+)) } } |