-
Notifications
You must be signed in to change notification settings - Fork 40
/
Makefile
58 lines (48 loc) · 1.73 KB
/
Makefile
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
# Extract board names from platformio.ini
PLATFORMIO_INI := platformio.ini
BOARDS := $(shell grep -oP '(?<=\[env:)[^\]]+' $(PLATFORMIO_INI) | grep -v '_dbg')
DEBUG_BOARDS := $(shell grep -oP '(?<=\[env:)[^\]]+' $(PLATFORMIO_INI) | grep '_dbg')
UPDATER_BOARDS := $(shell grep -oP '(?<=\[env:)[^\]]+' $(PLATFORMIO_INI) | grep -v '_dbg' | sed 's/^/updater_/')
# Default target
.PHONY: default
default: esp32
.PHONY: release
release: $(BOARDS)
.PHONY: updater
updater: $(UPDATER_BOARDS)
.PHONY: debug
debug: $(DEBUG_BOARDS)
# Target to build all boards in release, updater and debug modes
.PHONY: all
all: release updater debug
# Alias
esp%:
@echo "Building $@"
pio run --environment $@
updater_esp%:
@echo "Building $@"
pio run -d updater --environment $@
# Help target to display available build targets
.PHONY: help
help:
@echo "Makefile targets:"
@echo " make - Default build (ESP32 in release mode)"
@echo " make deps - Install software dependencies (PlatformIO)"
@echo " make all - Build all boards in both release and debug modes"
@$(foreach board,$(BOARDS),echo " make $(board) - Build $(board) in release mode";)
@$(foreach board,$(UPDATER_BOARDS),echo " make $(board) - Build updater for $(board) in release mode";)
@$(foreach board,$(DEBUG_BOARDS),echo " make $(board) - Build $(board) in debug mode";)
@echo "Available boards:"
@echo " $(BOARDS)"
@echo " updater_$(BOARDS)"
@echo " $(DEBUG_BOARDS)"
# Utility target to clean build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
@-rm -rf release debug .pio/build updater/.pio/build
# Install dependencies
.PHONY: deps
deps:
@echo "Installing dependencies..."
pip install --upgrade platformio esptool