From 442d75a326b7ef4736618f1546c396fe874af88c Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 3 Dec 2024 11:35:09 +0100 Subject: [PATCH] bricks: Use own manifest file. Not all hubs will need all modules. --- bricks/_common/arm_none_eabi.mk | 4 +--- bricks/_common/manifest.py | 5 ++--- bricks/_common/modules/.gitignore | 1 - bricks/cityhub/manifest.py | 1 + bricks/debug/manifest.py | 1 + bricks/essentialhub/manifest.py | 2 ++ bricks/ev3/manifest.py | 1 + bricks/nxt/manifest.py | 1 + bricks/primehub/manifest.py | 12 ++++++++++++ bricks/{_common => primehub}/modules/_hub_extra.py | 0 bricks/technichub/manifest.py | 2 ++ 11 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 bricks/cityhub/manifest.py create mode 100644 bricks/debug/manifest.py create mode 100644 bricks/essentialhub/manifest.py create mode 100644 bricks/ev3/manifest.py create mode 100644 bricks/nxt/manifest.py create mode 100644 bricks/primehub/manifest.py rename bricks/{_common => primehub}/modules/_hub_extra.py (100%) create mode 100644 bricks/technichub/manifest.py diff --git a/bricks/_common/arm_none_eabi.mk b/bricks/_common/arm_none_eabi.mk index c7d624183..19a5550b7 100644 --- a/bricks/_common/arm_none_eabi.mk +++ b/bricks/_common/arm_none_eabi.mk @@ -78,9 +78,7 @@ include $(PBTOP)/micropython/py/mkenv.mk # Include common frozen modules. ifeq ($(PB_FROZEN_MODULES),1) -ifneq ("$(wildcard $(PBTOP)/bricks/_common/modules/*.py)","") -FROZEN_MANIFEST ?= ../_common/manifest.py -endif +FROZEN_MANIFEST ?= manifest.py endif # qstr definitions (must come before including py.mk) diff --git a/bricks/_common/manifest.py b/bricks/_common/manifest.py index 84670e398..8d3423713 100644 --- a/bricks/_common/manifest.py +++ b/bricks/_common/manifest.py @@ -4,6 +4,5 @@ if any(modules): for m in modules: - path, file = m.parts - print(f"Including {m.stem} as a module.") - freeze_as_mpy(path, file) + print(f"Including {m.name} as a module.") + freeze_as_mpy(str(m.parent), m.name) diff --git a/bricks/_common/modules/.gitignore b/bricks/_common/modules/.gitignore index aed42152a..4e5d1d755 100644 --- a/bricks/_common/modules/.gitignore +++ b/bricks/_common/modules/.gitignore @@ -1,3 +1,2 @@ *.py -!_hub_extra.py !_builtin_port_view.py diff --git a/bricks/cityhub/manifest.py b/bricks/cityhub/manifest.py new file mode 100644 index 000000000..d901ff875 --- /dev/null +++ b/bricks/cityhub/manifest.py @@ -0,0 +1 @@ +include("../_common/manifest.py") diff --git a/bricks/debug/manifest.py b/bricks/debug/manifest.py new file mode 100644 index 000000000..d901ff875 --- /dev/null +++ b/bricks/debug/manifest.py @@ -0,0 +1 @@ +include("../_common/manifest.py") diff --git a/bricks/essentialhub/manifest.py b/bricks/essentialhub/manifest.py new file mode 100644 index 000000000..80492930f --- /dev/null +++ b/bricks/essentialhub/manifest.py @@ -0,0 +1,2 @@ +# including same modules as primehub +include("../primehub/manifest.py") diff --git a/bricks/ev3/manifest.py b/bricks/ev3/manifest.py new file mode 100644 index 000000000..d901ff875 --- /dev/null +++ b/bricks/ev3/manifest.py @@ -0,0 +1 @@ +include("../_common/manifest.py") diff --git a/bricks/nxt/manifest.py b/bricks/nxt/manifest.py new file mode 100644 index 000000000..d901ff875 --- /dev/null +++ b/bricks/nxt/manifest.py @@ -0,0 +1 @@ +include("../_common/manifest.py") diff --git a/bricks/primehub/manifest.py b/bricks/primehub/manifest.py new file mode 100644 index 000000000..8dfc83754 --- /dev/null +++ b/bricks/primehub/manifest.py @@ -0,0 +1,12 @@ +import pathlib + +# Common modules +include("../_common/manifest.py") + +# PrimeHub additions, like IMU. +primehub_modules = list(pathlib.Path("../primehub/modules").glob("*.py")) + +if any(primehub_modules): + for m in primehub_modules: + print(f"Including {m.name} as a module.") + freeze_as_mpy(str(m.parent), m.name) diff --git a/bricks/_common/modules/_hub_extra.py b/bricks/primehub/modules/_hub_extra.py similarity index 100% rename from bricks/_common/modules/_hub_extra.py rename to bricks/primehub/modules/_hub_extra.py diff --git a/bricks/technichub/manifest.py b/bricks/technichub/manifest.py new file mode 100644 index 000000000..80492930f --- /dev/null +++ b/bricks/technichub/manifest.py @@ -0,0 +1,2 @@ +# including same modules as primehub +include("../primehub/manifest.py")