From dce5a39b10d50e402813b17c578c05dbfe79e55b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 13 Sep 2021 14:48:48 +0300 Subject: [PATCH] Process "precompiled" and "ldflags" properties of the "library.properties" manifest // Resolve #3994 --- HISTORY.rst | 1 + platformio/builder/tools/piolib.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index b2c73dac..cc554130 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -33,6 +33,7 @@ PlatformIO Core 5 * **Build System** + - Process "precompiled" and "ldflags" properties of the "library.properties" manifest (`issue #3994 `_) - Upgraded build engine to the SCons 4.2 (`release notes `__) - Fixed an issue with broken binary file extension when a custom ``PROGNAME`` contains dot symbols (`issue #3906 `_) - Fixed an issue when PlatformIO archives a library that does not contain C/C++ source files (`issue #4019 `_) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 755900da..425cbc01 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -547,6 +547,21 @@ class ArduinoLibBuilder(LibBuilderBase): def is_platforms_compatible(self, platforms): return util.items_in_list(platforms, self._manifest.get("platforms") or ["*"]) + @property + def build_flags(self): + ldflags = [ + LibBuilderBase.build_flags.fget(self), # pylint: disable=no-member + self._manifest.get("ldflags"), + ] + if self._manifest.get("precompiled") in ("true", "full"): + # add to LDPATH {build.mcu} folder + board_config = self.env.BoardConfig() + self.env.PrependUnique( + LIBPATH=os.path.join(self.src_dir, board_config.get("build.cpu")) + ) + ldflags = [flag for flag in ldflags if flag] # remove empty + return " ".join(ldflags) if ldflags else None + class MbedLibBuilder(LibBuilderBase): def load_manifest(self):