|
1 | | -.DEFAULT_GOAL := build |
| 1 | +.DEFAULT_GOAL := all |
2 | 2 |
|
3 | | -$(eval venvpath := $(PWD)/.venv) |
4 | | -$(eval python := $(venvpath)/bin/python) |
5 | | -$(eval pip := $(venvpath)/bin/pip) |
6 | | -$(eval pio := $(venvpath)/bin/pio) |
| 3 | + |
| 4 | +# ============= |
| 5 | +# Prerequisites |
| 6 | +# ============= |
| 7 | + |
| 8 | +include util.mk |
| 9 | + |
| 10 | + |
| 11 | +# ============= |
| 12 | +# Configuration |
| 13 | +# ============= |
7 | 14 |
|
8 | 15 | export PLATFORMIO_WORKSPACE_DIR := $(PWD)/.pio |
9 | 16 | export BUILD_DIR := $(PWD)/.build |
10 | 17 |
|
11 | 18 |
|
| 19 | +# ================= |
| 20 | +# Workhorse targets |
| 21 | +# ================= |
| 22 | + |
| 23 | +# Main entrypoint targets. |
| 24 | +all: run build |
| 25 | +run: posix-run |
| 26 | + |
| 27 | +# Run all POSIX program examples. |
| 28 | +posix-run: csv json urlencoded |
| 29 | + |
| 30 | + |
12 | 31 | # ================================================== |
13 | 32 | # Build all examples for all PlatformIO environments |
14 | 33 | # ================================================== |
15 | 34 |
|
16 | | -setup-virtualenv: |
17 | | - @test -e $(python) || python3 -m venv $(venvpath) |
18 | | - $(pip) --quiet install platformio |
19 | | - |
20 | 35 | build: setup-virtualenv |
21 | 36 | PLATFORMIO_SRC_DIR=csv $(pio) run # --verbose |
22 | 37 | PLATFORMIO_SRC_DIR=json $(pio) run # --verbose |
23 | 38 | PLATFORMIO_SRC_DIR=urlencoded $(pio) run # --verbose |
24 | 39 |
|
25 | | -upload: setup-virtualenv |
26 | | - $(pio) run --target upload --upload-port=${MCU_PORT} |
27 | | - |
28 | | - |
29 | | -# ================================== |
30 | | -# Build and run all examples (POSIX) |
31 | | -# ================================== |
32 | | - |
33 | | -posix-build: |
34 | | - ./compile csv/csv_basic.cpp |
35 | | - ./compile json/json_basic.cpp |
36 | | - ./compile urlencoded/urlencoded_basic.cpp |
37 | | - @echo |
38 | | - |
39 | | -posix-run: posix-build |
40 | | - ${BUILD_DIR}/csv_basic |
41 | | - @echo |
42 | | - ${BUILD_DIR}/json_basic |
43 | | - @echo |
44 | | - ${BUILD_DIR}/urlencoded_basic |
45 | | - @echo |
46 | | - |
47 | | -run: posix-run |
48 | | - |
49 | 40 |
|
50 | 41 | # ========================================= |
51 | 42 | # Build and run individual examples (POSIX) |
52 | 43 | # ========================================= |
53 | 44 |
|
54 | | -$(BUILD_DIR)/csv_basic: |
55 | | - ./compile csv/csv_basic.cpp |
56 | | -$(BUILD_DIR)/json_basic: |
57 | | - ./compile json/json_basic.cpp |
58 | | -$(BUILD_DIR)/urlencoded_basic: |
59 | | - ./compile urlencoded/urlencoded_basic.cpp |
60 | | - |
61 | | -csv: $(BUILD_DIR)/csv_basic |
62 | | - $(BUILD_DIR)/csv_basic |
63 | | -json: $(BUILD_DIR)/json_basic |
64 | | - $(BUILD_DIR)/json_basic |
65 | | -urlencoded: $(BUILD_DIR)/urlencoded_basic |
66 | | - $(BUILD_DIR)/urlencoded_basic |
| 45 | +.PHONY: csv |
| 46 | +csv: |
| 47 | + PLATFORMIO_SRC_DIR=csv pio run -e native -t exec |
| 48 | + |
| 49 | +.PHONY: json |
| 50 | +json: |
| 51 | + PLATFORMIO_SRC_DIR=json pio run -e native -t exec |
| 52 | + |
| 53 | +.PHONY: urlencoded |
| 54 | +urlencoded: |
| 55 | + PLATFORMIO_SRC_DIR=urlencoded pio run -e native -t exec |
0 commit comments