Repository navigation
Expand file tree
/
Copy pathfeature-check.mk
More file actions
71 lines (60 loc) · 3.6 KB
/
Copy pathfeature-check.mk
File metadata and controls
71 lines (60 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Feature coverage with cargo-hack (https://github.com/taiki-e/cargo-hack).
#
# Every feature of every library crate is compiled on its own on top of
# --no-default-features, plus the --all-features build. cargo-hack reads the
# features from Cargo, so a newly added feature is covered without editing
# this file. Only constraints live here: features a target cannot build,
# feature conflicts, and crates checked more thoroughly than one at a time.
#
# --no-dev-deps lets cargo-hack drop dev-dependencies for the run (they would
# otherwise unify features into every build). It edits the manifests while it
# runs and restores them afterwards; do not commit while it is running.
#
# Install: cargo install cargo-hack --locked
#
# Included at the end of the Makefile so `help` stays the default goal.
.PHONY: feature-check feature-check-host feature-check-embedded feature-check-wasm
HACK := cargo hack check --no-dev-deps
# Host: each feature alone. Crates with constraints are checked separately below.
HACK_HOST_PACKAGES := \
-p aimdb-build-info -p aimdb-cdr -p aimdb-data-contracts -p aimdb-core \
-p aimdb-client -p aimdb-embassy-adapter -p aimdb-uds-connector -p aimdb-sync \
-p aimdb-persistence -p aimdb-persistence-sqlite -p aimdb-mqtt-connector \
-p aimdb-zenoh-connector -p aimdb-websocket-connector -p aimdb-cli -p aimdb-mcp
# Connector crates whose `log`/`tracing`/`defmt` code sits behind `connector`
# or `std`: each feature alone never compiles that code, so build every pair.
HACK_PAIRWISE_PACKAGES := -p aimdb-serial-connector -p aimdb-tcp-connector
# no_std crates, checked on the MCU target.
HACK_EMBEDDED_PACKAGES := \
-p aimdb-build-info -p aimdb-cdr -p aimdb-data-contracts -p aimdb-core \
-p aimdb-serial-connector -p aimdb-embassy-adapter -p aimdb-tcp-connector \
-p aimdb-mqtt-connector -p aimdb-zenoh-connector -p aimdb-knx-connector
# Features that need std, a host OS, or run as host-only test harnesses.
# `default` is listed because several crates default to `std`.
HACK_EMBEDDED_EXCLUDE := default std build test-utils lock serde_json \
tokio tokio-runtime rumqttc tokio-native-tls tokio-rustls critical-section-std-impl \
transport-tls transport-quic transport-ws auth-usrpwd \
_test-tokio _test-tokio-broker _test-tls-broker _test-backend-parity \
_test-embassy-broker _test-embassy-loopback
hack-empty :=
hack-comma := ,
hack-csv = $(subst $(hack-empty) $(hack-empty),$(hack-comma),$(strip $(1)))
## Compile every feature of every library crate (host, MCU, wasm)
feature-check: feature-check-host feature-check-embedded feature-check-wasm
feature-check-host:
@printf "$(GREEN)Checking each feature on the host...$(NC)\n"
$(HACK) --each-feature $(HACK_HOST_PACKAGES)
@printf "$(YELLOW) → Connector crates: every pair of features$(NC)\n"
$(HACK) --feature-powerset --depth 2 $(HACK_PAIRWISE_PACKAGES)
@printf "$(YELLOW) → aimdb-knx-connector: every pair of features$(NC)\n"
$(HACK) --feature-powerset --depth 2 -p aimdb-knx-connector
@printf "$(YELLOW) → aimdb-tokio-adapter: std-only, so --no-default-features is a compile_error!$(NC)\n"
$(HACK) --each-feature --exclude-no-default-features -p aimdb-tokio-adapter
feature-check-embedded:
@printf "$(GREEN)Checking each no_std feature on thumbv7em-none-eabihf...$(NC)\n"
$(HACK) --each-feature --exclude-all-features --exclude-features $(call hack-csv,$(HACK_EMBEDDED_EXCLUDE)) \
--target thumbv7em-none-eabihf --target-dir $(EMBEDDED_CHECK_TARGET_DIR) \
$(HACK_EMBEDDED_PACKAGES)
feature-check-wasm:
@printf "$(GREEN)Checking each feature on wasm32-unknown-unknown...$(NC)\n"
$(HACK) --each-feature --target wasm32-unknown-unknown -p aimdb-wasm-adapter