Implement "lib_extra_dirs" option for project environment // Resolve #537

This commit is contained in:
Ivan Kravets
2016-07-15 23:51:33 +03:00
parent 9838aef6b8
commit 02e883b55c
6 changed files with 55 additions and 16 deletions

View File

@ -17,6 +17,9 @@ PlatformIO 3.0
C Preprocessor conditional macros, `library deep search <http://docs.platformio.org/en/latest/projectconf.html#lib-deep-search>`__, support for the 3rd party C Preprocessor conditional macros, `library deep search <http://docs.platformio.org/en/latest/projectconf.html#lib-deep-search>`__, support for the 3rd party
manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``) manifests (Arduino IDE ``library.properties``, ARM mbed ``module.json``)
(`issue #432 <https://github.com/platformio/platformio/issues/432>`_) (`issue #432 <https://github.com/platformio/platformio/issues/432>`_)
* New `lib_extra_dirs <http://docs.platformio.org/en/latest/projectconf.html#lib-extra-dirs>`__ option for project environment.
Multiple custom library locations!
(`issue #537 <https://github.com/platformio/platformio/issues/537>`_)
* Handle extra build flags and build script from * Handle extra build flags and build script from
`library.json <http://docs.platformio.org/en/latest/librarymanager/config.html>`__ `library.json <http://docs.platformio.org/en/latest/librarymanager/config.html>`__
(`issue #289 <https://github.com/platformio/platformio/issues/289>`_) (`issue #289 <https://github.com/platformio/platformio/issues/289>`_)

View File

@ -107,6 +107,10 @@ Allows to set :ref:`projectconf` option :ref:`projectconf_src_filter`.
Allows to set :ref:`projectconf` option :ref:`projectconf_extra_script`. 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 Uploading
--------- ---------

View File

@ -681,6 +681,30 @@ For example, there are 2 libraries:
Secondly, it will parse all sources from "Bar" library and this operation Secondly, it will parse all sources from "Bar" library and this operation
continues until all dependent libraries will not be parsed. 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: .. _projectconf_examples:

View File

@ -14,7 +14,7 @@
import sys import sys
VERSION = (3, 0, "0.dev6") VERSION = (3, 0, "0.dev7")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -34,16 +34,19 @@ commonvars.AddVariables(
("PIOENV",), ("PIOENV",),
("PIOTEST",), ("PIOTEST",),
("PLATFORM",), ("PLATFORM",),
# options
("FRAMEWORK",), ("FRAMEWORK",),
# build options
("BUILD_FLAGS",), ("BUILD_FLAGS",),
("SRC_BUILD_FLAGS",), ("SRC_BUILD_FLAGS",),
("BUILD_UNFLAGS",), ("BUILD_UNFLAGS",),
("SRC_FILTER",), ("SRC_FILTER",),
# library options
("LIB_DEEP_SEARCH",), ("LIB_DEEP_SEARCH",),
("LIB_IGNORE",), ("LIB_IGNORE",),
("LIB_FORCE",), ("LIB_FORCE",),
("LIB_EXTRA_DIRS",),
# board options # board options
("BOARD",), ("BOARD",),
@ -101,21 +104,20 @@ for k in commonvars.keys():
if k in env: if k in env:
env[k] = base64.b64decode(env[k]) 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 # Handle custom variables from system environment
for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT", 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 k = "PLATFORMIO_%s" % var
if environ.get(k): if environ.get(k):
env[var] = 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.SConscriptChdir(0)
env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite")) env.SConsignFile(join("$PIOENVS_DIR", ".sconsign.dblite"))

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# pylint: disable=no-member # pylint: disable=no-member, no-self-use, unused-argument
from __future__ import absolute_import from __future__ import absolute_import
@ -130,7 +130,7 @@ class LibBuilderBase(object):
def is_framework_compatible(self, framework): def is_framework_compatible(self, framework):
return True return True
def load_manifest(self): # pylint: disable=no-self-use def load_manifest(self):
return {} return {}
def get_path_dirs(self, use_build_dir=False): 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): def GetLibBuilders(env):
items = [] items = []
libs_dirs = []
env_frameworks = [ env_frameworks = [
f.lower().strip() for f in env.get("FRAMEWORK", "").split(",")] 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 libs_dir in libs_dirs:
for item in sorted(os.listdir(libs_dir)): for item in sorted(os.listdir(libs_dir)):
if item == "__cores__" or not isdir(join(libs_dir, item)): if item == "__cores__" or not isdir(join(libs_dir, item)):