-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
146 lines (109 loc) · 4.27 KB
/
justfile
File metadata and controls
146 lines (109 loc) · 4.27 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Rustyfarian Power — development tasks
#
# The workspace defaults to the xtensa-esp32s3-espidf target via
# .cargo/config.toml, so host-side recipes pass --target explicitly to
# override it and disable the esp-idf feature.
#
# Run `just setup-toolchain` and `just setup-cargo-config` for first-time setup.
host_target := `scripts/host-target.sh`
host_flags := "--no-default-features --target " + host_target
doc_flags := "--no-default-features --target " + host_target + " --no-deps"
esp32s3_target := "xtensa-esp32s3-espidf"
esp32_target := "xtensa-esp32-espidf"
# list available recipes (default)
_default:
@just --list
# --- Build & Check --------------------------------------------------------
# check platform-independent code (no ESP toolchain required)
check:
cargo check {{ host_flags }}
# check all code including ESP-IDF hardware implementations (requires espup)
check-all:
cargo check
# check battery-monitor for the ESP32 target (Adafruit Feather V2, requires espup)
check-esp32:
MCU=esp32 cargo check -p battery-monitor --target {{ esp32_target }}
# verify device-side rustdoc snippets type-check for the ESP32 target (requires espup)
# run this whenever touching rust,ignore doc snippets or esp-idf-gated code
check-docs-esp32:
MCU=esp32 cargo check -p battery-monitor --target {{ esp32_target }} --features esp-idf
# build platform-independent code (no ESP toolchain required)
build:
cargo build {{ host_flags }}
# build all code including ESP-IDF hardware implementations (requires espup)
build-all:
cargo build
# --- Examples -------------------------------------------------------------
# build a named example without flashing — chip inferred from idf_{chip}_{name} prefix
build-example example:
scripts/build-example.sh "{{ example }}"
# build and flash a named example — chip inferred from idf_{chip}_{name} prefix
flash example:
scripts/flash.sh "{{ example }}"
# build, flash, and open serial monitor — the human workflow
run example: (flash example)
espflash monitor
# open serial monitor on the connected device
monitor:
espflash monitor
# erase the connected device's flash completely (use before reflashing on boot failures)
[confirm]
erase-flash:
espflash erase-flash
# --- Code Quality ---------------------------------------------------------
# run clippy on platform-independent code
clippy:
cargo clippy {{ host_flags }} -- -D warnings
# run clippy on all code including ESP-IDF (requires espup)
clippy-all:
cargo clippy -- -D warnings
# run host-side unit tests (no ESP toolchain required)
test:
cargo test {{ host_flags }}
# run host-side tests with stdout/stderr visible
test-verbose:
cargo test {{ host_flags }} -- --nocapture
# run a single named test
test-one name:
cargo test {{ host_flags }} {{ name }}
# format all code
fmt:
cargo fmt
# check formatting without modifying files
fmt-check:
cargo fmt -- --check
# --- Documentation --------------------------------------------------------
# build rustdoc for platform-independent code
doc:
cargo doc {{ doc_flags }}
# build and open docs in browser
doc-open:
cargo doc {{ doc_flags }} --open
# --- Maintenance ----------------------------------------------------------
# check dependency licenses, advisories, and bans
deny:
cargo deny check
# update dependencies
update:
cargo update
# clean build artifacts
clean:
cargo clean
# --- Composite ------------------------------------------------------------
# full pre-commit verification: format, check, lint, test (modifies files — local use only)
pre-commit: fmt check clippy test
# non-modifying full verification: fails on any anomaly
verify:
@cargo fmt -- --check || (printf '\nFormatting issues found — run `just pre-commit` to auto-fix.\n' >&2 && exit 1)
cargo check {{ host_flags }}
cargo clippy {{ host_flags }} -- -D warnings
cargo test {{ host_flags }}
# CI-equivalent verification (non-modifying): format check, deny, check, lint, test
ci: fmt-check deny check clippy test
# --- Setup ----------------------------------------------------------------
# copy the cargo config template for first-time setup
setup-cargo-config:
cp .cargo/config.toml.dist .cargo/config.toml
# install the ESP-IDF toolchain via espup
setup-toolchain:
espup install