remove cmake run-rust-unit-tests custom target
What changed, and why it matters
This change is purely about how the project runs its internal Rust unit tests and regenerates protobuf files. It removes a CMake custom target called 'rust-test' and instead makes the Makefile's 'run-rust-unit-tests' target run cargo directly, while adding a separate 'generate-protobufs' target. There is no change to the firmware code that runs on the device, no bug fix, and no security patch.
No security action required. Treat as a normal build-system maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the build system: it deletes the CMake rust-test custom target from src/CMakeLists.txt, updates Makefile so run-rust-unit-tests invokes cargo test directly (after generating protobufs), and adds generate-protobufs as an explicit Makefile target. Documentation in AGENTS.md is updated to remind developers to regenerate protobufs when .proto files change. No source code, cryptography, protocol parsing, or hardware interaction logic is modified.
Changed components
Makefilesrc/CMakeLists.txtAGENTS.mdInspect captured patch +11 / −28
diff --git a/AGENTS.md b/AGENTS.md
index a355001..bfec916 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -51,13 +51,16 @@ an explicit shell as the command, e.g. `./scripts/dev_exec.sh bash -lc 'cat vers
`cargo test --manifest-path src/rust/Cargo.toml [ -p <crate> ] --all-features -- --test-threads 1`.
- For checks, use
`cargo check --manifest-path src/rust/Cargo.toml [ -p <crate> ] --all-features`.
+ - If you modify `messages/*.proto`, run `make generate-protobufs` before direct Rust `cargo`
+ commands. Plain `cargo test`/`cargo check` does not regenerate the protobuf outputs.
## Coding Style & Naming Conventions
`.clang-format` (Chromium base, 4-space indent, Linux braces) and `.clang-tidy` govern C/C++. Use
`snake_case` for symbols, `PascalCase` for types, and `ALL_CAPS` for macros. Python utilities follow
`.pylintrc` rules (100-column limit, explicit imports). Rust crates rely on `rustfmt.toml` and the
pinned toolchain in `rust-toolchain.toml`; keep module paths aligned with `src/rust` and regenerate
-bindings (`cbindgen`, protobuf) when interfaces change.
+bindings (`cbindgen`, protobuf) when interfaces change. When changing protobuf interfaces, run
+`make generate-protobufs`.
* For C code changes, run `./scripts/dev_exec.sh ./scripts/format` to format the code.
* For Python changes, run `./scripts/dev_exec.sh ./scripts/format-python` to format the code.
diff --git a/Makefile b/Makefile
index 9dfd75c..aff4f81 100644
--- a/Makefile
+++ b/Makefile
@@ -107,8 +107,13 @@ unit-test: | build-build
# Must compile C tests before running them
run-unit-tests: | build-build
CTEST_OUTPUT_ON_FAILURE=1 $(MAKE) -C build-build test
-run-rust-unit-tests: | build-build-noasan
- ${MAKE} -C build-build-noasan rust-test
+generate-protobufs: | build-build-noasan
+ $(MAKE) -C build-build-noasan generate-protobufs
+# Only one test thread because of unsafe concurrent access to `SafeData`,
+# `mock_sd()` and `mock_memory()`. Using mutexes instead leads to mutex
+# poisoning and very messy output in case of a unit test failure.
+run-rust-unit-tests: generate-protobufs
+ cargo test --manifest-path src/rust/Cargo.toml --all-features -- --test-threads 1
run-rust-clippy: | build-build-noasan
${MAKE} -C build-build-noasan rust-clippy
# Must run tests before creating coverage report
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 69c825d..ac99bc6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -247,31 +247,6 @@ add_custom_target(rust-cbindgen
# Test rust crates that contain business logic. Avoid testing crates that depend on hardware.
if(NOT CMAKE_CROSSCOMPILING)
- # Since we build with all features we need to use a separate build directory.
- # Otherwise we invalidate the result from the normal compilation that uses a
- # different set of features.
- add_custom_target(rust-test
- COMMAND
- ${CMAKE_COMMAND} -E env
- CMAKE_SYSROOT=${CMAKE_SYSROOT}
- CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
- # only one test thread because of unsafe concurrent access to `SafeData`, `mock_sd()` and `mock_memory()`. Using mutexes instead leads to mutex poisoning and very messy output in case of a unit test failure.
- ${CARGO}
- test
- $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:-v>
- --all-features
- --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/rust/Cargo.toml
- --target-dir ${RUST_BINARY_DIR}/all-features
- --
- $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--no-capture>
- --test-threads 1
- WORKING_DIRECTORY
- ${CMAKE_CURRENT_SOURCE_DIR}/rust
- DEPENDS
- ${CMAKE_CURRENT_BINARY_DIR}/rust/rust.h
- )
- add_dependencies(rust-test generate-protobufs)
-
add_custom_target(rust-clippy
COMMAND
${CMAKE_COMMAND} -E env
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.