tools/autobuild/build-downloads.py: Verify standard features.

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 <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2023-09-28 15:26:23 +10:00 committed by Damien George
parent cf32c2feb5
commit 88ecc78eb3

View File

@ -5,6 +5,42 @@ import json
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 = []
@ -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))