Skip to content

Commit 39fa367

Browse files
committed
Use an alias to compile for Flipper Zero instead of build.target
Hard-coding `python3` in the runner means it doesn't work on Windows because only `python` is provided. Conversely, Debian / Ubuntu don't provide `python` by default. So it is more reliable to use `cargo` itself as the runner. However, doing so means we need to be able to compile for the host inside the `crates/` subdirectory. It is currently not possible to revert Cargo config options to their default, so the only way to compile for both host and Flipper Zero is to set the target additively. We achieve this by defining an alias `cargo test-flipper` that developers can use instead.
1 parent 1c316d9 commit 39fa367

File tree

4 files changed

+31
-49
lines changed

4 files changed

+31
-49
lines changed

.github/workflows/_build_and_test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
- name: Rustup
2020
run: rustup +nightly target add thumbv7em-none-eabihf
2121
- name: Build
22-
run: cargo +nightly build --release --verbose
22+
run: cargo +nightly build-flipper --release --verbose
2323
- name: Build examples
24-
run: cargo +nightly build --examples --release --verbose
24+
run: cargo +nightly build-flipper --examples --release --verbose
2525
- name: Run tests
2626
run: |
27-
cargo +nightly test --release --verbose 2>&1 | tee stderr.txt
27+
cargo +nightly test-flipper --release --verbose 2>&1 | tee stderr.txt
2828
- name: Check that tests failed for the expected reason
2929
run: |
3030
cat stderr.txt | grep -q "Error: unable to find Flipper Zero"

crates/.cargo/config.toml

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
[alias]
2+
check-flipper = "check --target thumbv7em-none-eabihf"
3+
build-flipper = "build --target thumbv7em-none-eabihf"
4+
test-flipper = "test --target thumbv7em-none-eabihf"
5+
16
[target.thumbv7em-none-eabihf]
2-
runner = "python3 ../cargo-runner.py"
7+
runner = [
8+
"cargo",
9+
"run",
10+
"--manifest-path",
11+
"../../tools/Cargo.toml",
12+
"--quiet",
13+
"--release",
14+
"--bin",
15+
"run-fap",
16+
"--",
17+
]
318
rustflags = [
419
# CPU is Cortex-M4 (STM32WB55)
520
"-C", "target-cpu=cortex-m4",
@@ -19,6 +34,3 @@ rustflags = [
1934
# Required to link with `lld`
2035
"-Z", "no-unique-section-names=yes",
2136
]
22-
23-
[build]
24-
target = "thumbv7em-none-eabihf"

crates/cargo-runner.py

-42
This file was deleted.

crates/sys/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
33
#![no_std]
44

5+
// Features that identify thumbv7em-none-eabihf.
6+
// Until target_abi is stable, this also permits thumbv7em-none-eabi.
7+
#[cfg(not(all(
8+
target_arch = "arm",
9+
target_feature = "thumb2",
10+
target_feature = "v7",
11+
target_feature = "dsp",
12+
target_os = "none",
13+
//target_abi = "eabihf",
14+
)))]
15+
core::compile_error!("This crate requires `--target thumbv7em-none-eabihf`");
16+
517
pub mod furi;
618
mod inlines;
719

0 commit comments

Comments
 (0)