74 lines
1.9 KiB
Makefile
74 lines
1.9 KiB
Makefile
override SHELL := /bin/sh
|
|
override MAKEFLAGS += --no-print-directory
|
|
|
|
.DEFAULT_GOAL := help
|
|
.DELETE_ON_ERROR:
|
|
|
|
override CARGO := cargo
|
|
override PYTHON := python3
|
|
override CARGO_FLAGS := --locked --offline
|
|
|
|
override BOARDS := geprc-f722-v2 kakute-f7-mini-v3
|
|
override BOARD_PACKAGES := $(addprefix kaptan-,$(BOARDS))
|
|
override BOARD_PACKAGE_ARGS := $(addprefix -p ,$(BOARD_PACKAGES))
|
|
override HOST_EXCLUDES := $(addprefix --exclude ,$(BOARD_PACKAGES))
|
|
|
|
override PRIMARY_GOAL := $(firstword $(MAKECMDGOALS))
|
|
|
|
run:
|
|
@exec python3 ../scripts/make-argv.py exec run $(CARGO)
|
|
|
|
ifeq ($(PRIMARY_GOAL),run)
|
|
|
|
.PHONY: run
|
|
|
|
# Application arguments may also look like Make goals. The run recipe recovers
|
|
# their exact boundaries from the original invocation.
|
|
.DEFAULT:
|
|
@:
|
|
|
|
else
|
|
|
|
.PHONY: help run fmt clippy test docs pre-commit check clean
|
|
|
|
help:
|
|
@printf '%s\n' 'Usage: make firmware -- <cargo arguments...>' '' \
|
|
'Example: make firmware -- test --workspace --locked --offline' '' \
|
|
'Workspace targets:' \
|
|
' fmt Check Rust formatting' \
|
|
' clippy Run host and embedded Clippy checks' \
|
|
' test Run Rust and firmware script tests' \
|
|
' docs Build Rust API documentation with warnings denied' \
|
|
' pre-commit Run fmt, clippy, test, and docs' \
|
|
' check Alias for pre-commit' \
|
|
' clean Remove Cargo build artifacts'
|
|
|
|
fmt:
|
|
$(CARGO) fmt --all --check
|
|
|
|
clippy:
|
|
$(CARGO) clippy --workspace --all-targets $(HOST_EXCLUDES) \
|
|
$(CARGO_FLAGS) -- -D warnings
|
|
$(CARGO) clippy -p platform-stm32f7 --all-targets \
|
|
$(CARGO_FLAGS) -- -D warnings
|
|
$(CARGO) clippy $(BOARD_PACKAGE_ARGS) --target thumbv7em-none-eabihf \
|
|
$(CARGO_FLAGS) -- -D warnings
|
|
|
|
test:
|
|
$(CARGO) test --workspace $(CARGO_FLAGS)
|
|
$(PYTHON) -m unittest \
|
|
scripts/test-analyze-fw.py scripts/test-summarize-test-coverage.py
|
|
|
|
docs:
|
|
RUSTDOCFLAGS='-D warnings' $(CARGO) doc --workspace --no-deps \
|
|
$(HOST_EXCLUDES) $(CARGO_FLAGS)
|
|
|
|
pre-commit: fmt clippy test docs
|
|
|
|
check: pre-commit
|
|
|
|
clean:
|
|
$(CARGO) clean
|
|
|
|
endif
|