From b6f783674be2b47ab2edfad6c017dd4ba30a1cc8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 26 Sep 2021 15:27:41 +0300 Subject: [PATCH] Allowed to override a default library builder via a new ``builder`` field in a ``build`` group of `library.json` // Resolve #3957 --- HISTORY.rst | 1 + docs | 2 +- platformio/builder/tools/piolib.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 90089cb4..c4371ce5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,7 @@ PlatformIO Core 5 5.2.1 (2021-??-??) ~~~~~~~~~~~~~~~~~~ +- Allowed to override a default library builder via a new ``builder`` field in a ``build`` group of `library.json `__ manifest (`issue #3957 `_) - Fixed a "KeyError: Invalid board option 'build.cpu'" when using a precompiled library with a board that does not have a CPU field in the manifest (`issue #4056 `_) - Fixed a "FileExist" error when the `platformio ci `__ command is used in pair with the ``--keep-build-dir`` option (`issue #4011 `_) diff --git a/docs b/docs index 395b056f..c9c5b9cd 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 395b056f8e6ee5cbb7e622465622e7b08431868f +Subproject commit c9c5b9cd5f18b17be71225df1bf5b487660e58e1 diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 902cf653..9b6d9642 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -59,6 +59,16 @@ class LibBuilderFactory(object): clsname = "%sLibBuilder" % used_frameworks[0].title() obj = getattr(sys.modules[__name__], clsname)(env, path, verbose=verbose) + + # Handle PlatformIOLibBuilder.manifest.build.builder + # pylint: disable=protected-access + if isinstance(obj, PlatformIOLibBuilder) and obj._manifest.get("build", {}).get( + "builder" + ): + obj = getattr( + sys.modules[__name__], obj._manifest.get("build", {}).get("builder") + )(env, path, verbose=verbose) + assert isinstance(obj, LibBuilderBase) return obj