.DEFAULT_GOAL := help
CARGO_ESP ?= cargo +esp
ESP_ENV := . $${HOME}/export-esp.sh 2>/dev/null;
BOLD := \033[1m
CYAN := \033[36m
GREEN := \033[32m
MAGENTA := \033[35m
RESET := \033[0m
.PHONY: help test test-crc test-defmt test-minimal lint check \
build doc coverage verify clean
test:
cargo test --all-features
test-crc:
cargo test --features crc
test-defmt:
cargo test --features defmt
test-minimal:
cargo test --no-default-features
lint:
cargo clippy --all-features -- -D warnings
check:
@printf "$(BOLD)Checking driver (thumbv7em-none-eabihf)...$(RESET)\n"
cargo check --target thumbv7em-none-eabihf
@printf "$(BOLD)Checking driver (riscv32imc-unknown-none-elf)...$(RESET)\n"
cargo check --target riscv32imc-unknown-none-elf
@printf "$(BOLD)Checking driver (xtensa-esp32s3-none-elf)...$(RESET)\n"
@$(ESP_ENV) $(CARGO_ESP) check --target xtensa-esp32s3-none-elf -Zbuild-std=core
build:
cargo build --all-features
verify: test lint check
@printf "\n$(BOLD)$(GREEN)════════════════════════════════════════$(RESET)\n"
@printf "$(BOLD)$(GREEN) All verification passed.$(RESET)\n"
@printf "$(BOLD)$(GREEN)════════════════════════════════════════$(RESET)\n\n"
doc:
cargo doc --all-features --open
coverage:
@mkdir -p coverage
cargo llvm-cov --all-features --lcov --output-path coverage/lcov.info
cargo llvm-cov --all-features --html --output-dir coverage/html
@printf "\n$(BOLD)Coverage report:$(RESET)\n"
@printf " lcov: coverage/lcov.info\n"
@printf " HTML: coverage/html/html/index.html\n\n"
clean:
cargo clean
help:
@awk 'BEGIN { \
FS = ":.*##"; \
printf "\n$(BOLD)tmag5273 Build System$(RESET)\n\n"; \
printf "$(CYAN)Usage:$(RESET) make <target>\n\n" \
} \
/^##@/ { \
if (section != "") printf "\n"; \
section = substr($$0, 5); \
printf "$(BOLD)$(MAGENTA)%s$(RESET)\n", section \
} \
/^[a-zA-Z][a-zA-Z0-9_-]*:.*##/ { \
printf " $(CYAN)%-30s$(RESET) %s\n", $$1, $$2 \
}' $(MAKEFILE_LIST)
@printf "\n"