-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (76 loc) · 3.84 KB
/
Copy pathMakefile
File metadata and controls
89 lines (76 loc) · 3.84 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
# RaceBoxMicroBleClient — Root Makefile
#
# Native tests (no hardware):
# make Run all 87 unit tests
# make test Same
# make clean Remove compiled test binaries + Unity cache
#
# Build & flash .ino examples (arduino-cli required):
# make build SKETCH=LibTest Compile
# make flash SKETCH=LibTest PORT=COM3 Compile + upload
# make monitor PORT=COM3 Serial monitor (115200 baud)
# make setup-board Install ESP32 core (once)
#
# arduino-cli: https://arduino.github.io/arduino-cli/latest/installation/
# On Windows, force Git Bash (sh.exe) so bash-style commands work.
ifeq ($(OS),Windows_NT)
SHELL := sh
endif
# ── Config ────────────────────────────────────────────────────────────────────
ARDUINO_CLI ?= arduino-cli
FQBN ?= esp32:esp32:ttgo-lora32
PORT ?= /dev/ttyUSB0
BAUD ?= 115200
SKETCH ?= LibTest
SKETCH_DIR := examples/$(SKETCH)
SKETCH_FILE := $(SKETCH_DIR)/$(SKETCH).ino
BUILD_DIR := /tmp/arduino-build-$(SKETCH)
.PHONY: all test clean build flash monitor setup-board _check-sketch help
# ── Default: run unit tests ───────────────────────────────────────────────────
all: test
test:
$(MAKE) -C test
clean:
$(MAKE) -C test clean
# ── Board setup (run once after installing arduino-cli) ───────────────────────
setup-board:
$(ARDUINO_CLI) core update-index
$(ARDUINO_CLI) core install esp32:esp32
$(ARDUINO_CLI) lib install "ESP32 BLE Arduino"
# ── Compile a sketch ──────────────────────────────────────────────────────────
build: _check-sketch
$(ARDUINO_CLI) compile \
--fqbn $(FQBN) \
--libraries . \
--build-path $(BUILD_DIR) \
$(SKETCH_FILE)
# ── Compile + upload ──────────────────────────────────────────────────────────
flash: _check-sketch
$(ARDUINO_CLI) compile \
--fqbn $(FQBN) \
--libraries . \
--build-path $(BUILD_DIR) \
--upload \
--port $(PORT) \
$(SKETCH_FILE)
# ── Serial monitor ────────────────────────────────────────────────────────────
monitor:
$(ARDUINO_CLI) monitor --port $(PORT) --config baudrate=$(BAUD)
# ── Internal guard (pure make — no shell needed) ──────────────────────────────
_check-sketch:
$(if $(wildcard $(SKETCH_FILE)),,$(error Sketch not found: $(SKETCH_FILE). Available: $(notdir $(wildcard examples/*/*))))
# ── Help ──────────────────────────────────────────────────────────────────────
help:
@echo "RaceBoxMicroBleClient"
@echo ""
@echo "Native tests (no hardware):"
@echo " make Run all 87 unit tests"
@echo " make clean Remove compiled binaries"
@echo ""
@echo "Build and flash (arduino-cli required):"
@echo " make setup-board Install ESP32 core + deps (once)"
@echo " make build SKETCH=LibTest Compile a sketch"
@echo " make flash SKETCH=LibTest PORT=COM3 Compile + upload"
@echo " make monitor PORT=COM3 Serial monitor"
@echo ""
@echo "Default FQBN: $(FQBN) (override with FQBN=...)"