Skip to content

Commit

Permalink
Maintenance: Build improvements all over the place
Browse files Browse the repository at this point in the history
- Fix broken PlatformIO examples
- Sort PlatformIO dependencies
- Silence: Use `pip --quiet install platformio` everywhere
- Remove deprecated `monitor_speed` setting from PlatformIO settings
  • Loading branch information
amotl committed May 28, 2023
1 parent 7394445 commit b008b6a
Show file tree
Hide file tree
Showing 34 changed files with 205 additions and 194 deletions.
7 changes: 3 additions & 4 deletions gateway-rfm69-beradio/platformio.ini
Expand Up @@ -11,14 +11,13 @@
[platformio]
src_dir = .

[common]
[env]
lib_deps =
lowpowerlab/RFM69@^1.5
lowpowerlab/SPIFlash@^101
https://github.com/hiveeyes/embencode
lowpowerlab/RFM69@^1.5.2

[env:atmega328p]
platform = atmelavr
board = pro8MHzatmega328
framework = arduino
lib_deps =
${common.lib_deps}
9 changes: 4 additions & 5 deletions gateway-rfm69-csv-sdcard/platformio.ini
Expand Up @@ -11,15 +11,14 @@
[platformio]
src_dir = .

[common]
[env]
lib_deps =
https://github.com/hiveeyes/embencode
arduino-libraries/Bridge@^1.7.0
lowpowerlab/RFM69@^1.5.2
lowpowerlab/RFM69@^1.5
lowpowerlab/SPIFlash@^101
https://github.com/hiveeyes/embencode

[env:atmega328p]
platform = atmelavr
board = pro8MHzatmega328
framework = arduino
lib_deps =
${common.lib_deps}
7 changes: 3 additions & 4 deletions gateway-rfm69-csv-uart/platformio.ini
Expand Up @@ -11,13 +11,12 @@
[platformio]
src_dir = .

[common]
[env]
lib_deps =
lowpowerlab/RFM69@^1.5.2
lowpowerlab/RFM69@^1.5
lowpowerlab/SPIFlash@^101

[env:atmega328p]
platform = atmelavr
board = uno
framework = arduino
lib_deps =
${common.lib_deps}
8 changes: 4 additions & 4 deletions generic/platformio.ini
Expand Up @@ -16,10 +16,10 @@ platform = atmelavr@^2
board = pro8MHzatmega328
framework = arduino
lib_deps =
../libraries/Terrine
https://github.com/hiveeyes/StandardCplusplus#next
apechinsky/MemoryFree@^0.3
mikem/RadioHead@^1.120
https://github.com/hiveeyes/StandardCplusplus#next
../libraries/Terrine
build_flags =
-fdiagnostics-color
# -pedantic
Expand All @@ -31,13 +31,13 @@ extra_scripts = platformio_options.py
# Libraries needed by different `node` variants.
lib_deps =
${env.lib_deps}
../libraries/BERadio
https://github.com/hiveeyes/embencode#next
bogde/HX711@0.7.4
lowpowerlab/LowPower_LowPowerLab@^2
markruys/DHT@^1
milesburton/DallasTemperature@^3
paulstoffregen/OneWire@^2
https://github.com/hiveeyes/embencode#next
../libraries/BERadio

[env:node-rh69]
board = pro8MHzatmega328
Expand Down
17 changes: 16 additions & 1 deletion libraries/TerkinData/README.rst
Expand Up @@ -185,6 +185,8 @@ Usage

.. highlight:: bash

Build for embedded targets
==========================
::

# Get source code.
Expand All @@ -194,9 +196,22 @@ Usage
# Build examples for all embedded platforms.
make

# Build and run examples on host platform.
Build individual programs::

PLATFORMIO_SRC_DIR=csv pio run --environment=avr328

Build and run on POSIX
======================
Rebuild and run all examples::

make run

Run individual example::

make csv
make json
make urlencoded


********
Examples
Expand Down
56 changes: 45 additions & 11 deletions libraries/TerkinData/examples/Makefile
@@ -1,32 +1,66 @@
.DEFAULT_GOAL := build

$(eval venvpath := $(PWD)/.venv)
$(eval python := $(venvpath)/bin/python)
$(eval pip := $(venvpath)/bin/pip)
$(eval pio := $(venvpath)/bin/pio)

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


# ==================================================
# Build all examples for all PlatformIO environments
# ==================================================

setup-virtualenv:
@test -e $(python) || python3 -m venv $(venvpath)
$(pip) --quiet install platformio

build: setup-virtualenv
cd json; $(pio) run --project-conf=../platformio.ini # --verbose
cd csv; $(pio) run --project-conf=../platformio.ini # --verbose
cd urlencoded; $(pio) run --project-conf=../platformio.ini # --verbose
PLATFORMIO_SRC_DIR=csv $(pio) run # --verbose
PLATFORMIO_SRC_DIR=json $(pio) run # --verbose
PLATFORMIO_SRC_DIR=urlencoded $(pio) run # --verbose

upload: setup-virtualenv
$(pio) run --target upload --upload-port=${MCU_PORT}

run:
mkdir -p build

# ==================================
# Build and run all examples (POSIX)
# ==================================

posix-build:
./compile csv/csv_basic.cpp
./compile json/json_basic.cpp
./compile urlencoded/urlencoded_basic.cpp
@echo

./build/csv_basic
posix-run: posix-build
${BUILD_DIR}/csv_basic
@echo
./build/json_basic
${BUILD_DIR}/json_basic
@echo
./build/urlencoded_basic
${BUILD_DIR}/urlencoded_basic
@echo

setup-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=python3 $(venvpath)
$(pip) install platformio
run: posix-run


# =========================================
# Build and run individual examples (POSIX)
# =========================================

$(BUILD_DIR)/csv_basic:
./compile csv/csv_basic.cpp
$(BUILD_DIR)/json_basic:
./compile json/json_basic.cpp
$(BUILD_DIR)/urlencoded_basic:
./compile urlencoded/urlencoded_basic.cpp

csv: $(BUILD_DIR)/csv_basic
$(BUILD_DIR)/csv_basic
json: $(BUILD_DIR)/json_basic
$(BUILD_DIR)/json_basic
urlencoded: $(BUILD_DIR)/urlencoded_basic
$(BUILD_DIR)/urlencoded_basic
11 changes: 8 additions & 3 deletions libraries/TerkinData/examples/compile
Expand Up @@ -2,18 +2,23 @@
# Build example programs against glibc.
# Usage: ./compile csv_basic.cpp

BUILD_DIR="${BUILD_DIR:-.build}"
mkdir -p ${BUILD_DIR}

INPUT=$1
OUTPUT=build/$(basename $INPUT ".cpp")
OUTPUT=${BUILD_DIR}/$(basename $INPUT ".cpp")

LIB_DIR="../.."
TERRINE="${LIB_DIR}/Terrine"
TERKINDATA="${LIB_DIR}/TerkinData"
ARDUINOJSON="${LIB_DIR}/ArduinoJson"
# TODO: Acquire `ArduinoJson` independently of the `avr328` environment.
ARDUINOJSON="${PLATFORMIO_WORKSPACE_DIR}/libdeps/avr328/ArduinoJson"
INCLUDE="-I$TERRINE -I$TERKINDATA -I$ARDUINOJSON"

#CPP=g++
#CPP=/usr/local/bin/g++-12
CPP=clang
#CPP=/opt/local/bin/g++-mp-5
#CPP=/usr/local/Cellar/llvm/16.0.1/bin/clang

# ./sim/compat.h
CPP_FLAGS="-x c++ -lstdc++ -std=gnu++11 -Os -fno-exceptions -ffunction-sections -fdata-sections -fpermissive"
Expand Down
69 changes: 34 additions & 35 deletions libraries/TerkinData/examples/platformio.ini
@@ -1,25 +1,34 @@
; PlatformIO Project Configuration File
; PlatformIO project configuration file for Hiveeyes Arduino Firmwares
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
; https://docs.platformio.org/en/latest/projectconf/


[platformio]
src_dir = .

# Please invoke by setting `src_dir` dynamically. Example:
# PLATFORMIO_SRC_DIR=json pio run --environment=samd-m4

# `src_dir` has been deactivated.
# src_dir = .


[common]
lib_deps =
SPI
#paulstoffregen/Time@^1.6
apechinsky/MemoryFree@^0.3
# TODO: Update to ArduinoJson 6
bblanchon/ArduinoJson@^5
mikem/RadioHead@^1.113
#paulstoffregen/Time@^1.6
#https://github.com/hiveeyes/StandardCplusplus
lib_extra_dirs =
../../../../libraries
${PROJECT_DIR}/../../../libraries

build_flags =

Expand All @@ -34,26 +43,24 @@ lib_deps =
mike-matera/ArduinoSTL@^1.1.0
lib_extra_dirs =
${common.lib_extra_dirs}

build_flags =
${common.build_flags}
-I ../.pio/libdeps/avr328/ArduinoSTL/src
-I ${platformio.libdeps_dir}/${this.__env__}/ArduinoSTL/src
-I ${platformio.libdeps_dir}/${this.__env__}/MemoryFree


[env:esp8266]
platform = espressif8266
platform = espressif8266@^2
board = nodemcuv2
framework = arduino

lib_deps =
${common.lib_deps}
lib_extra_dirs =
${common.lib_extra_dirs}
lib_ignore =
StandardCplusplus

build_flags =
${common.build_flags}
-I ${platformio.libdeps_dir}/${this.__env__}/MemoryFree


[env:esp32]
Expand All @@ -65,29 +72,25 @@ lib_deps =
${common.lib_deps}
lib_extra_dirs =
${common.lib_extra_dirs}
lib_ignore =
StandardCplusplus

build_flags =
${common.build_flags}
-D SERIAL_PORT_HARDWARE=Serial


[env:esp32s2]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-v4.2
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git
board = featheresp32-s2
#board = metroesp32-s2
board_build.mcu = esp32s2
framework = arduino
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

; change microcontroller
board_build.mcu = esp32s2

lib_deps =
${common.lib_deps}
lib_extra_dirs =
${common.lib_extra_dirs}
lib_ignore =
StandardCplusplus

build_flags =
${common.build_flags}
-D SERIAL_PORT_HARDWARE=Serial
Expand All @@ -98,38 +101,34 @@ platform = atmelsam
board = adafruit_feather_m0
framework = arduino

; change microcontroller
board_build.mcu = samd21g18a

lib_deps =
${common.lib_deps}
adafruit/Adafruit Zero DMA Library @ ^1.0.8
adafruit/Adafruit Zero DMA Library @ ^1.1.1
lib_extra_dirs =
${common.lib_extra_dirs}
lib_ignore =
StandardCplusplus

; change microcontroller
board_build.mcu = samd21g18a

build_flags =
${common.build_flags}
-I "../.pio/libdeps/samd-m0/Adafruit Zero DMA Library"
-I "${platformio.libdeps_dir}/${this.__env__}/Adafruit Zero DMA Library"
-I "${platformio.libdeps_dir}/${this.__env__}/MemoryFree"


[env:samd-m4]
platform = atmelsam
board = adafruit_feather_m4_can
framework = arduino

; change microcontroller
board_build.mcu = same51j19a

lib_deps =
${common.lib_deps}
adafruit/Adafruit Zero DMA Library @ ^1.0.8
adafruit/Adafruit Zero DMA Library @ ^1.1.1
lib_extra_dirs =
${common.lib_extra_dirs}
lib_ignore =
StandardCplusplus

; change microcontroller
board_build.mcu = same51j19a

build_flags =
${common.build_flags}
-I "../.pio/libdeps/samd-m4/Adafruit Zero DMA Library"
-I "${platformio.libdeps_dir}/${this.__env__}/Adafruit Zero DMA Library"
-I "${platformio.libdeps_dir}/${this.__env__}/MemoryFree"
2 changes: 1 addition & 1 deletion node-esp32-generic/Makefile
Expand Up @@ -12,4 +12,4 @@ upload: setup-virtualenv

setup-virtualenv:
@test -e $(python) || python3 -m venv $(venvpath)
$(pip) install platformio
$(pip) --quiet install platformio

0 comments on commit b008b6a

Please sign in to comment.