diff --git a/HISTORY.rst b/HISTORY.rst index d6fbe399..981c883e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,9 @@ PlatformIO 3.0 C Preprocessor conditional macros, `library deep search `__, support for the 3rd party manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``) (`issue #432 `_) +* New `lib_extra_dirs `__ option for project environment. + Multiple custom library locations! + (`issue #537 `_) * Handle extra build flags and build script from `library.json `__ (`issue #289 `_) diff --git a/docs/envvars.rst b/docs/envvars.rst index d0165b05..40d93b83 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -107,6 +107,10 @@ Allows to set :ref:`projectconf` option :ref:`projectconf_src_filter`. Allows to set :ref:`projectconf` option :ref:`projectconf_extra_script`. +.. envvar:: PLATFORMIO_LIB_EXTRA_DIRS + +Allows to set :ref:`projectconf` option :ref:`projectconf_lib_extra_dirs`. + Uploading --------- diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 5d5b9596..0c905b2f 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -681,6 +681,30 @@ For example, there are 2 libraries: Secondly, it will parse all sources from "Bar" library and this operation continues until all dependent libraries will not be parsed. +.. _projectconf_lib_extra_dirs: + +``lib_extra_dirs`` +^^^^^^^^^^^^^^^^^^ + +A list with extra directories where ``Library Dependency Finder (LDF)`` will +look for dependencies. Multiple paths are allowed. Please separate them using +comma ``,`` symbol. + +This option can be set by global environment variable +:envvar:`PLATFORMIO_LIB_EXTRA_DIRS`. + +.. warning:: + This is a not direct path to library with source code. It should be the path + to directory that contains libraries grouped by folders. For example, + ``/extra/lib/path/`` but not ``/extra/lib/path/MyLibrary``. + +Example: + +.. code-block:: ini + + [env:custom_lib_dirs] + lib_extra_dirs = /path/to/private/dir1,/path/to/private/dir2 + ----------- .. _projectconf_examples: diff --git a/platformio/__init__.py b/platformio/__init__.py index d770fc9b..28a1507b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev6") +VERSION = (3, 0, "0.dev7") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 0fdcc752..822421ec 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -34,16 +34,19 @@ commonvars.AddVariables( ("PIOENV",), ("PIOTEST",), ("PLATFORM",), - - # options ("FRAMEWORK",), + + # build options ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",), + + # library options ("LIB_DEEP_SEARCH",), ("LIB_IGNORE",), ("LIB_FORCE",), + ("LIB_EXTRA_DIRS",), # board options ("BOARD",), @@ -101,21 +104,20 @@ for k in commonvars.keys(): if k in env: env[k] = base64.b64decode(env[k]) -env.LoadDevPlatform(commonvars) - -# Parse library names -for opt in ("LIB_IGNORE", "LIB_FORCE"): - if opt not in env: - continue - env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] - # Handle custom variables from system environment for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT", - "UPLOAD_PORT", "UPLOAD_FLAGS"): + "UPLOAD_PORT", "UPLOAD_FLAGS", "LIB_EXTRA_DIRS"): k = "PLATFORMIO_%s" % var if environ.get(k): env[var] = environ.get(k) +# Parse comma separated items +for opt in ("LIB_IGNORE", "LIB_FORCE", "LIB_EXTRA_DIRS"): + if opt not in env: + continue + env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] + +env.LoadDevPlatform(commonvars) env.SConscriptChdir(0) env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite")) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 5c1389ce..6a06f985 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=no-member +# pylint: disable=no-member, no-self-use, unused-argument from __future__ import absolute_import @@ -130,7 +130,7 @@ class LibBuilderBase(object): def is_framework_compatible(self, framework): return True - def load_manifest(self): # pylint: disable=no-self-use + def load_manifest(self): return {} def get_path_dirs(self, use_build_dir=False): @@ -326,10 +326,16 @@ def find_and_build_deps(env, lib_builders, scanner, def GetLibBuilders(env): items = [] + libs_dirs = [] env_frameworks = [ f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")] - libs_dirs = [env.subst(d) for d in env.get("LIBSOURCE_DIRS", []) - if isdir(env.subst(d))] + + for key in ("LIB_EXTRA_DIRS", "LIBSOURCE_DIRS"): + for d in env.get(key, []): + d = env.subst(d) + if isdir(d): + libs_dirs.append(d) + for libs_dir in libs_dirs: for item in sorted(os.listdir(libs_dir)): if item == "__cores__" or not isdir(join(libs_dir, item)):