From d0fb8d2f30c43ce415c68094d454a5d3f0ef0201 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 25 Aug 2025 12:11:39 +0200 Subject: [PATCH 1/4] lib_build: support display --- build_as_lib.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build_as_lib.py b/build_as_lib.py index da4337c0..43e06fdd 100644 --- a/build_as_lib.py +++ b/build_as_lib.py @@ -6,11 +6,13 @@ menv=env # type: ignore src_filter = [ '+<*.cpp>', '+', - '+' + '+', '+', '+', ] +use_display = False + # add build and include dirs according to CPPDEFINES for item in menv.get("CPPDEFINES", []): @@ -38,12 +40,25 @@ for item in menv.get("CPPDEFINES", []): menv.Append(BUILD_FLAGS=["-I src/helpers/rp2040"]) src_filter.append("+") + # DISPLAY HANDLING + elif isinstance(item, tuple) and item[0] == "DISPLAY_CLASS": + display_class = item[1] + use_display = True + src_filter.append(f"+") + if (display_class == "ST7789Display") : + src_filter.append(f"+") + src_filter.append(f"+") + # VARIANTS HANDLING elif isinstance(item, tuple) and item[0] == "MC_VARIANT": variant_name = item[1] menv.Append(BUILD_FLAGS=[f"-I variants/{variant_name}"]) src_filter.append(f"+<../variants/{variant_name}>") +if use_display : + menv.Append(CPPPATH=[realpath("src/helpers/ui")]) + menv.Append(BUILD_FLAGS=["-I src/helpers/ui"]) + menv.Replace(SRC_FILTER=src_filter) #print (menv.Dump()) From 033706adcfbb89e138d35e1fb9fbdb4011eecdcd Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 25 Aug 2025 16:21:23 +0200 Subject: [PATCH 2/4] lib_build: fix ST7789 so we don't have to add helpers/ui in INC_DIRS --- build_as_lib.py | 8 +------- src/helpers/ui/ST7789Display.h | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/build_as_lib.py b/build_as_lib.py index 43e06fdd..59091556 100644 --- a/build_as_lib.py +++ b/build_as_lib.py @@ -9,10 +9,9 @@ src_filter = [ '+', '+', '+', + '+', ] -use_display = False - # add build and include dirs according to CPPDEFINES for item in menv.get("CPPDEFINES", []): @@ -43,7 +42,6 @@ for item in menv.get("CPPDEFINES", []): # DISPLAY HANDLING elif isinstance(item, tuple) and item[0] == "DISPLAY_CLASS": display_class = item[1] - use_display = True src_filter.append(f"+") if (display_class == "ST7789Display") : src_filter.append(f"+") @@ -55,10 +53,6 @@ for item in menv.get("CPPDEFINES", []): menv.Append(BUILD_FLAGS=[f"-I variants/{variant_name}"]) src_filter.append(f"+<../variants/{variant_name}>") -if use_display : - menv.Append(CPPPATH=[realpath("src/helpers/ui")]) - menv.Append(BUILD_FLAGS=["-I src/helpers/ui"]) - menv.Replace(SRC_FILTER=src_filter) #print (menv.Dump()) diff --git a/src/helpers/ui/ST7789Display.h b/src/helpers/ui/ST7789Display.h index 8056de81..0f06da4c 100644 --- a/src/helpers/ui/ST7789Display.h +++ b/src/helpers/ui/ST7789Display.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include "ST7789Spi.h" class ST7789Display : public DisplayDriver { ST7789Spi display; From 15249bb8d5edde15ada5710cb4b6bd34711e3cc6 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 25 Aug 2025 17:50:48 +0200 Subject: [PATCH 3/4] lib_build: include example code in build --- build_as_lib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build_as_lib.py b/build_as_lib.py index 59091556..910c58fe 100644 --- a/build_as_lib.py +++ b/build_as_lib.py @@ -52,6 +52,11 @@ for item in menv.get("CPPDEFINES", []): variant_name = item[1] menv.Append(BUILD_FLAGS=[f"-I variants/{variant_name}"]) src_filter.append(f"+<../variants/{variant_name}>") + + # INCLUDE EXAMPLE CODE IN BUILD (to provide your own support files without touching the tree) + elif isinstance(item, tuple) and item[0] == "BUILD_EXAMPLE": + example_name = item[1] + src_filter.append(f"+<../examples/{example_name}>") menv.Replace(SRC_FILTER=src_filter) From df18dfb48105fd71efd4ee26525aec6af46f5cc5 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 25 Aug 2025 18:34:50 +0200 Subject: [PATCH 4/4] lib_build: exclude file from example --- build_as_lib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build_as_lib.py b/build_as_lib.py index 910c58fe..4e8eea57 100644 --- a/build_as_lib.py +++ b/build_as_lib.py @@ -58,6 +58,11 @@ for item in menv.get("CPPDEFINES", []): example_name = item[1] src_filter.append(f"+<../examples/{example_name}>") + # EXCLUDE A SOURCE FILE FROM AN EXAMPLE (must be placed after example name or boom) + elif isinstance(item, tuple) and item[0] == "EXCLUDE_FROM_EXAMPLE": + exclude_name = item[1] + src_filter.append(f"-<../examples/{example_name}/{exclude_name}>") + menv.Replace(SRC_FILTER=src_filter) #print (menv.Dump())