diff --git a/HISTORY.rst b/HISTORY.rst index 30df34be..e0bf1ad0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,7 +12,8 @@ PlatformIO Core 5 ~~~~~~~~~~~~~~~~~~ - Allowed to override a default library builder via a new ``builder`` field in a ``build`` group of `library.json `__ manifest (`issue #3957 `_) -- Handle "test" folder as a part of CLion project (`issue #4005 `_) +- Handle the "test" folder as a part of CLion project (`issue #4005 `_) +- Improved handling of a library root based on "Conan" or "CMake" build systems (`issue #3887 `_) - 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 `_) - Fixed an issue with draft values of C++ language standards that broke static analysis via Cppcheck (`issue #3944 `_) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 9b6d9642..eb92f352 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -184,11 +184,11 @@ class LibBuilderBase(object): @property def include_dir(self): - if not all( - os.path.isdir(os.path.join(self.path, d)) for d in ("include", "src") - ): - return None - return os.path.join(self.path, "include") + return ( + os.path.join(self.path, "include") + if os.path.isdir(os.path.join(self.path, "include")) + else None + ) @property def src_dir(self): @@ -501,6 +501,14 @@ class ArduinoLibBuilder(LibBuilderBase): return {} return ManifestParserFactory.new_from_file(manifest_path).as_dict() + @property + def include_dir(self): + if not all( + os.path.isdir(os.path.join(self.path, d)) for d in ("include", "src") + ): + return None + return os.path.join(self.path, "include") + def get_include_dirs(self): include_dirs = LibBuilderBase.get_include_dirs(self) if os.path.isdir(os.path.join(self.path, "src")): diff --git a/platformio/package/manager/library.py b/platformio/package/manager/library.py index 03960306..95f2db3f 100644 --- a/platformio/package/manager/library.py +++ b/platformio/package/manager/library.py @@ -61,6 +61,12 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc @staticmethod def find_library_root(path): for root, dirs, files in os.walk(path): + # check if Conan-based library + if os.path.isfile(os.path.join(root, "conanfile.py")): + return root + # check if CMake-based library + if os.path.isfile(os.path.join(root, "CMakeLists.txt")): + return root if not files and len(dirs) == 1: continue for fname in files: