From f001c087ec87e1a6cfc3a711e05ad0d8abd236a0 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 5 May 2015 15:47:21 +0100 Subject: [PATCH] Allow to specify libraries which are compatible with build environment using use_libs option in platformio.ini --- HISTORY.rst | 19 +++++++++++++------ docs/projectconf.rst | 13 +++++++++++++ platformio/__init__.py | 2 +- platformio/builder/main.py | 1 + platformio/builder/tools/platformio.py | 12 +++++++++--- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2cf461a3..b5063b09 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,11 +11,17 @@ Release History (`issue #174 `_) * Added global ``-f, --force`` option which will force to accept any confirmation prompts (`issue #152 `_) -* Added library dependencies using ``install_libs`` option in - `platformio.ini `__ +* Allowed to add library dependencies for build environment using + `install_libs `_ + option in ``platformio.ini`` (`issue #134 `_) -* Allowed to add more boards to existing - `platformio.ini `__ +* Allowed to specify libraries which are compatible with build environment using + `use_libs `_ + option in ``platformio.ini`` + (`issue #148 `_) +* Allowed to add more boards to PlatformIO project with + `platformio init --board `__ + command (`issue #167 `_) * Allowed to choose which library to update (`issue #168 `_) @@ -45,8 +51,9 @@ Release History 1.6.3 version (`issue #156 `_) * Upgraded `Energia Framework `__ to 0101E0015 version (`issue #146 `_) -* Upgraded `Arduino Framework with Teensy Core `_ to - 1.22 version (`issue #162 `_, +* Upgraded `Arduino Framework with Teensy Core `_ + to 1.22 version + (`issue #162 `_, `issue #170 `_) * Fixed exceptions with PlatformIO auto-updates when Internet connection isn't active diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 5242e3aa..698a8762 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -325,6 +325,19 @@ Example: [env:depends_on_some_libs] install_libs = 1,13,19 +``use_libs`` +^^^^^^^^^^^^ + +Specify libraries which should be used by ``Library Dependency Finder`` with +the highest priority. + +Example: + +.. code-block:: ini + + [env:libs_with_highest_priority] + use_libs = OneWire_ID1 + ``ignore_libs`` ^^^^^^^^^^^^^^^ diff --git a/platformio/__init__.py b/platformio/__init__.py index 9e004963..1d3f6c57 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 0, "0.dev3") +VERSION = (2, 0, "0.dev4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index a68aceb9..45ec63d6 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -37,6 +37,7 @@ commonvars.AddVariables( ("BUILD_FLAGS",), ("SRCBUILD_FLAGS",), ("IGNORE_LIBS",), + ("USE_LIBS",), # board options ("BOARD",), diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index a45b526d..b70cc2c0 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -131,9 +131,11 @@ def BuildLibrary(env, variant_dir, library_dir, ignore_files=None): def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 - INCLUDES_RE = re.compile(r"^\s*#include\s+(\<|\")([^\>\"\']+)(?:\>|\")", - re.M) + INCLUDES_RE = re.compile( + r"^\s*#include\s+(\<|\")([^\>\"\']+)(?:\>|\")", re.M) LIBSOURCE_DIRS = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", [])] + USE_LIBS = [l.strip() for l in env.get("USE_LIBS", "").split(",") + if l.strip()] # start internal prototypes @@ -174,7 +176,10 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 if not isdir(lsd_dir): continue - for ld in listdir(lsd_dir): + for ld in USE_LIBS + listdir(lsd_dir): + if not isdir(join(lsd_dir, ld)): + continue + inc_path = normpath(join(lsd_dir, ld, self.name)) try: lib_dir = inc_path[:inc_path.index( @@ -205,6 +210,7 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 "libs": set(), "ordered": set() } + state = _process_src_dir(state, env.subst(src_dir)) result = []