chore: build and test shenanigans

This commit is contained in:
cscherr 2025-07-09 15:12:10 +02:00
parent b3ca9eeabf
commit e2bc777410
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
6 changed files with 34 additions and 11 deletions

View file

@ -1,15 +1,10 @@
[build]
# target = "thumbv6m-none-eabi"
[test]
target = "x86_64-unknown-linux-gnu"
[target.thumbv6m-none-eabi]
runner = 'probe-rs run --chip STM32L053R8'
[alias]
target = "thumbv6m-none-eabi"
arun = "run --target thumbv6m-none-eabi"
atest = "test --target x86_64-unknown-linux-gnu"
cflash = "flash --chip STM32L053R8"
[env]

View file

@ -15,6 +15,10 @@ defmt = { version = "1.0.1" }
defmt-rtt = { version = "1.0.0" }
panic-probe = { version = "0.3", features = ["print-defmt"] }
[features]
default = ["buildscript"]
buildscript = []
[profile.release]
debug = "full" # those are not on the board

View file

@ -1,5 +1,8 @@
fn main() {
println!("cargo::rerun-if-changed=Cargo.toml");
println!("cargo::rustc-link-arg=-Tlink.x");
println!("cargo::rustc-link-arg=-Tdefmt.x");
#[cfg(feature = "buildscript")]
{
println!("cargo::rerun-if-changed=Cargo.toml");
println!("cargo::rustc-link-arg=-Tlink.x");
println!("cargo::rustc-link-arg=-Tdefmt.x");
}
}

View file

@ -1,9 +1,23 @@
use crate::Crc;
struct CrcDev;
impl Crc for CrcDev {
type Input = [u8];
type Checksum = [u8; Self::CHECKSUM_LEN];
const CHECKSUM_LEN: usize = 4;
fn process(data: &Self::Input) -> Self::Checksum {
todo!()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
let data = [0, 1, 2, 3, 4, 5, 6];
assert_eq!(CrcDev::process(&data), [1, 2, 3, 4])
}
}

View file

@ -1,3 +1,5 @@
#![no_std]
mod crc_32;
pub use crc_32::*;

5
scripts/test_crc.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
# I'm using a bash script because if i set the target in .cargo/config.toml
# i can't build for x86_64 anymore, which means I can't run the unit tests.
TARGET="x86_64-unknown-linux-gnu"
cargo test --target $TARGET -p crc --no-default-features