diff --git a/HISTORY.rst b/HISTORY.rst index 6c313133..ef4e815d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -39,6 +39,7 @@ PlatformIO Core 6 * Fixed an issue when the `build_unflags `__ operation ignores a flag value (`issue #4309 `_) * Fixed an issue when the `build_unflags `__ option was not applied to the ``ASPPFLAGS`` scope * Fixed an issue on Windows OS when flags were wrapped to the temporary file while generating the `Compilation database "compile_commands.json" `__ +* Fixed an issue with the `LDF `__ when recursively scanning dependencies in the ``chain`` mode 6.0.2 (2022-06-01) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 3a0072c2..75a977a0 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -318,19 +318,12 @@ class LibBuilderBase: ) def get_search_files(self): - items = [ + return [ os.path.join(self.src_dir, item) - for item in self.env.MatchSourceFiles(self.src_dir, self.src_filter) - ] - include_dir = self.include_dir - if include_dir: - items.extend( - [ - os.path.join(include_dir, item) - for item in self.env.MatchSourceFiles(include_dir) - ] + for item in self.env.MatchSourceFiles( + self.src_dir, self.src_filter, piotool.SRC_BUILD_EXT ) - return items + ] def _get_found_includes( # pylint: disable=too-many-branches self, search_files=None @@ -366,24 +359,28 @@ class LibBuilderBase: tuple(include_dirs), depth=self.CCONDITIONAL_SCANNER_DEPTH, ) - # mark candidates already processed via Conditional Scanner - self._processed_files.extend( - [ - c.get_abspath() - for c in candidates - if c.get_abspath() not in self._processed_files - ] - ) + except Exception as e: # pylint: disable=broad-except if self.verbose and "+" in self.lib_ldf_mode: sys.stderr.write( "Warning! Classic Pre Processor is used for `%s`, " "advanced has failed with `%s`\n" % (path, e) ) - candidates = LibBuilderBase.CLASSIC_SCANNER( - self.env.File(path), self.env, tuple(include_dirs) + candidates = self.env.File(path).get_implicit_deps( + self.env, + LibBuilderBase.CLASSIC_SCANNER, + lambda _: tuple(include_dirs), ) + # mark candidates already processed + self._processed_files.extend( + [ + c.get_abspath() + for c in candidates + if c.get_abspath() not in self._processed_files + ] + ) + # print(path, [c.get_abspath() for c in candidates]) for item in candidates: if item not in result: @@ -415,11 +412,12 @@ class LibBuilderBase: lib_inc_map = {} for inc in self._get_found_includes(search_files): + inc_path = inc.get_abspath() for lb in self.env.GetLibBuilders(): - if inc.get_abspath() in lb: + if inc_path in lb: if lb not in lib_inc_map: lib_inc_map[lb] = [] - lib_inc_map[lb].append(inc.get_abspath()) + lib_inc_map[lb].append(inc_path) break for lb, lb_search_files in lib_inc_map.items(): @@ -878,16 +876,6 @@ class ProjectAsLibBuilder(LibBuilderBase): def src_dir(self): return self.env.subst("$PROJECT_SRC_DIR") - def get_include_dirs(self): - include_dirs = [] - project_include_dir = self.env.subst("$PROJECT_INCLUDE_DIR") - if os.path.isdir(project_include_dir): - include_dirs.append(project_include_dir) - for include_dir in super().get_include_dirs(): - if include_dir not in include_dirs: - include_dirs.append(include_dir) - return include_dirs - def get_search_files(self): items = [] build_type = self.env.GetBuildType() diff --git a/tests/commands/test_test.py b/tests/commands/test_test.py index 2a6c7c56..9d7c1dd5 100644 --- a/tests/commands/test_test.py +++ b/tests/commands/test_test.py @@ -309,10 +309,15 @@ platform = native """ ) test_dir = project_dir.mkdir("test") - test_dir.join("test_main.c").write( + test_dir.join("test_main.h").write( """ #include #include + """ + ) + test_dir.join("test_main.c").write( + """ +#include "test_main.h" void setUp(){ printf("setUp called");