Skip to content

Commit 1ba8951

Browse files
committed
[TerkinData] Build and run using PlatformIO, for POSIX / native builds
Following recent improvements, this patch dissolves previous Makefile- based build tooling also for native platform targets. The functional Makefile-based entrypoints are still there, but now they will divert to `pio run -t exec` right away. make csv make json make urlencoded
1 parent d30aa00 commit 1ba8951

File tree

4 files changed

+76
-80
lines changed

4 files changed

+76
-80
lines changed
Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,55 @@
1-
.DEFAULT_GOAL := build
1+
.DEFAULT_GOAL := all
22

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+
# =============
714

815
export PLATFORMIO_WORKSPACE_DIR := $(PWD)/.pio
916
export BUILD_DIR := $(PWD)/.build
1017

1118

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+
1231
# ==================================================
1332
# Build all examples for all PlatformIO environments
1433
# ==================================================
1534

16-
setup-virtualenv:
17-
@test -e $(python) || python3 -m venv $(venvpath)
18-
$(pip) --quiet install platformio
19-
2035
build: setup-virtualenv
2136
PLATFORMIO_SRC_DIR=csv $(pio) run # --verbose
2237
PLATFORMIO_SRC_DIR=json $(pio) run # --verbose
2338
PLATFORMIO_SRC_DIR=urlencoded $(pio) run # --verbose
2439

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-
4940

5041
# =========================================
5142
# Build and run individual examples (POSIX)
5243
# =========================================
5344

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

libraries/TerkinData/examples/compile

Lines changed: 0 additions & 31 deletions
This file was deleted.

libraries/TerkinData/examples/platformio.ini

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,45 @@
2020

2121
[common]
2222
lib_deps =
23-
SPI
23+
# TODO: `MemoryFree` is currently a strong dependency of `Terrine` - make it an optional one.
2424
apechinsky/MemoryFree@^0.3
2525
# TODO: Update to ArduinoJson 6
2626
bblanchon/ArduinoJson@^5
27-
mikem/RadioHead@^1.113
28-
#paulstoffregen/Time@^1.6
2927
lib_extra_dirs =
3028
${PROJECT_DIR}/../../../libraries
3129

3230
build_flags =
3331

3432

33+
[env:native]
34+
# About: Build and invoke example programs on your workstation (native / POSIX).
35+
# Synopsis: PLATFORMIO_SRC_DIR=csv pio run --environment native --target exec
36+
# Remark: Run `pio pkg update` when invoking `exec` target fails.
37+
# Documentation:
38+
# - https://docs.platformio.org/en/latest/platforms/native.html
39+
# - https://docs.platformio.org/en/latest/platforms/creating_platform.html#build-script-main-py
40+
platform = native
41+
42+
lib_compat_mode = off
43+
lib_deps =
44+
# TODO: Update to ArduinoJson 6
45+
bblanchon/ArduinoJson@^5
46+
TerkinData
47+
Terrine
48+
lib_extra_dirs =
49+
${PROJECT_DIR}/../../../libraries
50+
build_flags =
51+
-std=gnu++11
52+
# FIXME: Why is that needed? What overwrites it?
53+
-I ${platformio.libdeps_dir}/${this.__env__}/ArduinoJson
54+
-DHAVE_ARDUINO_JSON
55+
# -g -lstdc++
56+
# -Os -fno-exceptions -ffunction-sections -fdata-sections -fpermissive
57+
# -Wno-builtin-macro-redefined -Wno-unused-function -fdiagnostics-color
58+
# -Wall
59+
# -Wextra
60+
61+
3562
[env:avr328]
3663
platform = atmelavr
3764
board = pro8MHzatmega328
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$(eval venvpath := $(PWD)/.venv)
2+
$(eval python := $(venvpath)/bin/python)
3+
$(eval pip := $(venvpath)/bin/pip)
4+
$(eval pio := $(venvpath)/bin/pio)
5+
6+
setup-virtualenv:
7+
@test -e $(python) || python3 -m venv $(venvpath)
8+
$(pip) --quiet install platformio
9+
10+
upload: setup-virtualenv
11+
$(pio) run --target upload --upload-port=${MCU_PORT}

0 commit comments

Comments
 (0)