build: run unit tests locally
This commit is contained in:
parent
9a6491c393
commit
933106b7ea
5 changed files with 63 additions and 16 deletions
49
Cargo.toml
49
Cargo.toml
|
|
@ -3,13 +3,36 @@ edition = "2024"
|
||||||
name = "esp32-c_its-companion"
|
name = "esp32-c_its-companion"
|
||||||
rust-version = "1.88"
|
rust-version = "1.88"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
default-run = "esp32-c_its-companion"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "esp32-c_its-companion"
|
name = "esp32-c_its-companion"
|
||||||
path = "./src/main.rs"
|
path = "./src/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "test"
|
||||||
|
path = "./src/test.rs"
|
||||||
|
required-features = ["std"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["spat"]
|
default = ["esp", "spat"]
|
||||||
|
|
||||||
|
# build for ESP (needed to build test for `host-tuple`)
|
||||||
|
esp = [
|
||||||
|
"dep:esp-hal",
|
||||||
|
"dep:esp-rtos",
|
||||||
|
"dep:esp-bootloader-esp-idf",
|
||||||
|
"dep:embassy-executor",
|
||||||
|
"dep:embassy-time",
|
||||||
|
"dep:embedded-io",
|
||||||
|
"dep:embedded-io-async",
|
||||||
|
"dep:esp-alloc",
|
||||||
|
"dep:esp-backtrace",
|
||||||
|
"dep:esp-println",
|
||||||
|
"dep:esp-radio",
|
||||||
|
"dep:embassy_gps",
|
||||||
|
]
|
||||||
|
std = ["c-its-parser/std"]
|
||||||
|
|
||||||
# echo CAM data on serial
|
# echo CAM data on serial
|
||||||
cam = ["c-its-parser/cam"]
|
cam = ["c-its-parser/cam"]
|
||||||
|
|
@ -20,9 +43,9 @@ spat = ["c-its-parser/spatem", "c-its-parser/mapem"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
esp-hal = { version = "~1.1.0", features = ["esp32c5", "log-04", "unstable"] }
|
esp-hal = { version = "~1.1.0", optional = true, features = ["esp32c5", "log-04", "unstable"] }
|
||||||
|
|
||||||
esp-rtos = { version = "0.3.0", features = [
|
esp-rtos = { version = "0.3.0", optional = true, features = [
|
||||||
"embassy",
|
"embassy",
|
||||||
"esp-alloc",
|
"esp-alloc",
|
||||||
"esp-radio",
|
"esp-radio",
|
||||||
|
|
@ -30,22 +53,22 @@ esp-rtos = { version = "0.3.0", features = [
|
||||||
"log-04",
|
"log-04",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
esp-bootloader-esp-idf = { version = "0.5.0", features = ["esp32c5", "log-04"] }
|
esp-bootloader-esp-idf = { version = "0.5.0", optional = true, features = ["esp32c5", "log-04"] }
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
|
|
||||||
critical-section = "1.2.0"
|
critical-section = "1.2.0"
|
||||||
embassy-executor = { version = "0.10.0", features = ["log"] }
|
embassy-executor = { version = "0.10.0", optional = true, features = ["log"] }
|
||||||
embassy-time = { version = "0.5.0", features = ["log"] }
|
embassy-time = { version = "0.5.0", optional = true, features = ["log"] }
|
||||||
embedded-io = "0.7.1"
|
embedded-io = { version = "0.7.1", optional = true }
|
||||||
embedded-io-async = "0.7.0"
|
embedded-io-async = { version = "0.7.0", optional = true }
|
||||||
esp-alloc = "0.10.0"
|
esp-alloc = { version = "0.10.0", optional = true }
|
||||||
esp-backtrace = { version = "0.19.0", features = [
|
esp-backtrace = { version = "0.19.0", optional = true, features = [
|
||||||
"esp32c5",
|
"esp32c5",
|
||||||
"panic-handler",
|
"panic-handler",
|
||||||
"println",
|
"println",
|
||||||
] }
|
] }
|
||||||
esp-println = { version = "0.17.0", features = ["esp32c5", "log-04"] }
|
esp-println = { version = "0.17.0", optional = true, features = ["esp32c5", "log-04"] }
|
||||||
esp-radio = { version = "0.18.0", features = [
|
esp-radio = { version = "0.18.0", optional = true, features = [
|
||||||
"esp-alloc",
|
"esp-alloc",
|
||||||
"esp32c5",
|
"esp32c5",
|
||||||
"log-04",
|
"log-04",
|
||||||
|
|
@ -54,7 +77,7 @@ esp-radio = { version = "0.18.0", features = [
|
||||||
"sniffer",
|
"sniffer",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
embassy_gps = { version = "0.1.0", default-features = false, features = ["esp", "log-04"], git = "https://github.com/jbeyerstedt/embassy_gps.git", branch = "feat/rework-gpsfix" }
|
embassy_gps = { version = "0.1.0", optional = true, default-features = false, features = ["esp", "log-04"], git = "https://github.com/jbeyerstedt/embassy_gps.git", branch = "feat/rework-gpsfix" }
|
||||||
c-its-parser = { version = "2.2.2", default-features = false, features = [
|
c-its-parser = { version = "2.2.2", default-features = false, features = [
|
||||||
"time",
|
"time",
|
||||||
"geo",
|
"geo",
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,10 @@ Connect your ESP32-C5 and run:
|
||||||
```
|
```
|
||||||
cargo run --release
|
cargo run --release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Run Unit Tests on Host
|
||||||
|
The unit tests in this project are meant to be run on the host:
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo test --target host-tuple --bin test --no-default-features -F std,spat
|
||||||
|
```
|
||||||
|
|
|
||||||
12
build.rs
12
build.rs
|
|
@ -1,7 +1,13 @@
|
||||||
|
use std::env;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
linker_be_nice();
|
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
|
|
||||||
println!("cargo:rustc-link-arg=-Tlinkall.x");
|
if target_arch == "riscv32" {
|
||||||
|
linker_be_nice();
|
||||||
|
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
|
||||||
|
println!("cargo:rustc-link-arg=-Tlinkall.x");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn linker_be_nice() {
|
fn linker_be_nice() {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
use c_its_parser::standards::mapem_2_2_1::mapem_pdu_descriptions;
|
use c_its_parser::standards::mapem_2_2_1::mapem_pdu_descriptions;
|
||||||
use c_its_parser::standards::spatem_2_2_1::spatem_pdu_descriptions;
|
use c_its_parser::standards::spatem_2_2_1::spatem_pdu_descriptions;
|
||||||
use chrono::Datelike;
|
use chrono::Datelike;
|
||||||
|
#[cfg(target_arch = "riscv32")]
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
|
||||||
pub fn handle_mapem(etsi: &mapem_pdu_descriptions::MAPEM) {
|
pub fn handle_mapem(etsi: &mapem_pdu_descriptions::MAPEM) {
|
||||||
|
|
|
||||||
10
src/test.rs
Normal file
10
src/test.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#![cfg(not(target_arch = "riscv32"))]
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
mod applogic;
|
||||||
|
mod cache;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// dummy only
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue