Skip to content

Commit

Permalink
tools/autobuild/build-downloads.py: Verify standard features.
Browse files Browse the repository at this point in the history
Defines the list of standard features and ensures that each board.json
only uses those ones. This list can be extended, but needs to be a
deliberate decision.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <[email protected]>
  • Loading branch information
jimmo authored and dpgeorge committed Sep 29, 2023
1 parent cf32c2f commit 88ecc78
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tools/autobuild/build-downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@
import os
import sys

VALID_FEATURES = {
# Connectivity
"BLE",
"CAN",
"Ethernet",
"LoRa",
"USB",
"USB-C",
"WiFi",
# MCU features
"Dual-core",
"External Flash",
"External RAM",
# Form factor
"Feather",
# Connectors / sockets
"JST-PH",
"JST-SH",
"mikroBUS",
"microSD",
"SDCard",
# Sensors
"Environment Sensor",
"IMU",
# Other
"Audio Codec",
"Battery Charging",
"Camera",
"DAC",
"Display",
"Microphone",
"PoE",
"RGB LED",
"Secure Element",
}


def main(repo_path, output_path):
boards_index = []
Expand All @@ -19,6 +55,16 @@ def main(repo_path, output_path):
with open(board_json, "r") as f:
blob = json.load(f)

features = set(blob.get("features", []))
if not features.issubset(VALID_FEATURES):
print(
board_json,
"unknown features:",
features.difference(VALID_FEATURES),
file=sys.stderr,
)
sys.exit(1)

# Use "id" if specified, otherwise default to board dir (e.g. "PYBV11").
# We allow boards to override ID for the historical build names.
blob["id"] = blob.get("id", os.path.basename(board_dir))
Expand Down

0 comments on commit 88ecc78

Please sign in to comment.