Skip to content

Commit

Permalink
Allow to specify libraries which are compatible with build environmen…
Browse files Browse the repository at this point in the history
…t using use_libs option in platformio.ini
  • Loading branch information
ivankravets committed May 5, 2015
1 parent 125c7b2 commit f001c08
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
19 changes: 13 additions & 6 deletions HISTORY.rst
Expand Up @@ -11,11 +11,17 @@ Release History
(`issue #174 <https://github.com/platformio/platformio/issues/174>`_)
* Added global ``-f, --force`` option which will force to accept any
confirmation prompts (`issue #152 <https://github.com/platformio/platformio/issues/152>`_)
* Added library dependencies using ``install_libs`` option in
`platformio.ini <http://docs.platformio.org/en/latest/projectconf.html#install-libs>`__
* Allowed to add library dependencies for build environment using
`install_libs <http://docs.platformio.org/en/latest/projectconf.html#install-libs>`_
option in ``platformio.ini``
(`issue #134 <https://github.com/platformio/platformio/issues/134>`_)
* Allowed to add more boards to existing
`platformio.ini <http://docs.platformio.org/en/latest/projectconf.html>`__
* Allowed to specify libraries which are compatible with build environment using
`use_libs <http://docs.platformio.org/en/latest/projectconf.html#use-libs>`_
option in ``platformio.ini``
(`issue #148 <https://github.com/platformio/platformio/issues/148>`_)
* Allowed to add more boards to PlatformIO project with
`platformio init --board <http://docs.platformio.org/en/latest/userguide/cmd_init.html#cmdoption--board>`__
command
(`issue #167 <https://github.com/platformio/platformio/issues/167>`_)
* Allowed to choose which library to update
(`issue #168 <https://github.com/platformio/platformio/issues/168>`_)
Expand Down Expand Up @@ -45,8 +51,9 @@ Release History
1.6.3 version (`issue #156 <https://github.com/platformio/platformio/issues/156>`_)
* Upgraded `Energia Framework <http://docs.platformio.org/en/latest/frameworks/energia.html>`__ to
0101E0015 version (`issue #146 <https://github.com/platformio/platformio/issues/146>`_)
* Upgraded `Arduino Framework with Teensy Core <http://docs.platformio.org/en/latest/frameworks/arduino.html>`_ to
1.22 version (`issue #162 <https://github.com/platformio/platformio/issues/162>`_,
* Upgraded `Arduino Framework with Teensy Core <http://docs.platformio.org/en/latest/frameworks/arduino.html>`_
to 1.22 version
(`issue #162 <https://github.com/platformio/platformio/issues/162>`_,
`issue #170 <https://github.com/platformio/platformio/issues/170>`_)
* Fixed exceptions with PlatformIO auto-updates when Internet connection isn't
active
Expand Down
13 changes: 13 additions & 0 deletions docs/projectconf.rst
Expand Up @@ -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``
^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion platformio/__init__.py
@@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.

VERSION = (2, 0, "0.dev3")
VERSION = (2, 0, "0.dev4")
__version__ = ".".join([str(s) for s in VERSION])

__title__ = "platformio"
Expand Down
1 change: 1 addition & 0 deletions platformio/builder/main.py
Expand Up @@ -37,6 +37,7 @@
("BUILD_FLAGS",),
("SRCBUILD_FLAGS",),
("IGNORE_LIBS",),
("USE_LIBS",),

# board options
("BOARD",),
Expand Down
12 changes: 9 additions & 3 deletions platformio/builder/tools/platformio.py
Expand Up @@ -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

Expand Down Expand Up @@ -174,7 +176,10 @@ def _find_in_system(self):
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(
Expand Down Expand Up @@ -205,6 +210,7 @@ def _get_dep_libs(src_dir):
"libs": set(),
"ordered": set()
}

state = _process_src_dir(state, env.subst(src_dir))

result = []
Expand Down

0 comments on commit f001c08

Please sign in to comment.