Run library extra script only at a build process // Resolve #3915

This commit is contained in:
Ivan Kravets
2022-02-03 15:33:03 +02:00
parent f4c692eed2
commit e5fca99b52
2 changed files with 13 additions and 11 deletions

View File

@ -15,6 +15,7 @@ PlatformIO Core 5
- Improved checking of available Internet connection for IPv6-only workstations (`pull #4151 <https://github.com/platformio/platformio-core/pull/4151>`_)
- Better detecting of default PlatformIO project directory on Linux OS (`pull #4158 <https://github.com/platformio/platformio-core/pull/4158>`_)
- Respect disabling debugging server from "platformio.ini" passing an empty value to the `debug_server <https://docs.platformio.org/en/latest/projectconf/section_env_debug.html#debug-server>`__ option
- Run library extra script only at a build process (`issue #3915 <https://github.com/platformio/platformio-core/issues/3915>`_)
5.2.4 (2021-12-15)
~~~~~~~~~~~~~~~~~~

View File

@ -285,15 +285,8 @@ class LibBuilderBase(object):
return {}
def process_extra_options(self):
with fs.cd(self.path):
self.env.ProcessFlags(self.build_flags)
if self.extra_script:
self.env.SConscriptChdir(1)
self.env.SConscript(
os.path.abspath(self.extra_script),
exports={"env": self.env, "pio_lib_builder": self},
)
self.env.ProcessUnFlags(self.build_unflags)
self.env.ProcessFlags(self.build_flags)
self.env.ProcessUnFlags(self.build_unflags)
def process_dependencies(self):
if not self.dependencies:
@ -447,7 +440,15 @@ class LibBuilderBase(object):
for lb, lb_search_files in lib_inc_map.items():
self.depend_recursive(lb, lb_search_files)
def build(self):
def build(self): # pylint: disable=too-many-branches
if self.extra_script and not self._is_built:
with fs.cd(self.path):
self.env.SConscriptChdir(1)
self.env.SConscript(
os.path.abspath(self.extra_script),
exports={"env": self.env, "pio_lib_builder": self},
)
libs = []
for lb in self._depbuilders:
libs.extend(lb.build())
@ -460,8 +461,8 @@ class LibBuilderBase(object):
if self._is_built:
return libs
self._is_built = True
self._is_built = True
self.env.PrependUnique(CPPPATH=self.get_include_dirs())
if self.lib_ldf_mode == "off":