Deprecate `lib_force option, please use lib_deps` instead

This commit is contained in:
Ivan Kravets
2016-09-17 16:32:16 +03:00
parent 7dc378bba7
commit e50327bccc
9 changed files with 36 additions and 49 deletions

View File

@ -11,6 +11,7 @@ PlatformIO 3.0
* Improved Project Generator when custom ``--project-option`` is passed to * Improved Project Generator when custom ``--project-option`` is passed to
`platformio init <http://docs.platformio.org/en/stable/userguide/cmd_init.html>`__ `platformio init <http://docs.platformio.org/en/stable/userguide/cmd_init.html>`__
command command
* Deprecated ``lib_force`` option, please use `lib_deps <http://docs.platformio.org/en/stable/projectconf.html#lib-deps>`__ instead
* Fixed SSL Server-Name-Indication for Python < 2.7.9 * Fixed SSL Server-Name-Indication for Python < 2.7.9
* Return valid exit code from ``plaformio test`` command * Return valid exit code from ``plaformio test`` command

View File

@ -32,7 +32,6 @@ Library Dependency Finder has controls that can be set up in :ref:`projectconf`:
* :ref:`projectconf_lib_deps` * :ref:`projectconf_lib_deps`
* :ref:`projectconf_lib_extra_dirs` * :ref:`projectconf_lib_extra_dirs`
* :ref:`projectconf_lib_force`
* :ref:`projectconf_lib_ignore` * :ref:`projectconf_lib_ignore`
* :ref:`projectconf_lib_compat_mode` * :ref:`projectconf_lib_compat_mode`
* :ref:`projectconf_lib_ldf_mode` * :ref:`projectconf_lib_ldf_mode`

View File

@ -707,9 +707,11 @@ Multiple dependencies are allowed (multi-lines or separated with comma+space ",
.. code-block:: ini .. code-block:: ini
; one line definition (comma + space)
[env:myenv] [env:myenv]
lib_deps = LIBRARY_1, LIBRARY_2, LIBRARY_N lib_deps = LIBRARY_1, LIBRARY_2, LIBRARY_N
; multi-line definition
[env:myenv2] [env:myenv2]
lib_deps = lib_deps =
LIBRARY_1 LIBRARY_1
@ -732,30 +734,6 @@ Example:
https://github.com/gioblu/PJON.git@v2.0 https://github.com/gioblu/PJON.git@v2.0
https://github.com/me-no-dev/ESPAsyncTCP.git https://github.com/me-no-dev/ESPAsyncTCP.git
.. _projectconf_lib_force:
``lib_force``
^^^^^^^^^^^^^
.. seealso::
Please make sure to read :ref:`ldf` guide first.
Force Library Dependency Finder to depend on the specified library if it even
is not included in the project source code. Also, this library will be
processed in the first order.
The correct value for this option is library name (not folder name). In the
most cases, library name is pre-defined in manifest file
(:ref:`library_config`, ``library.properties``, ``module.json``). The multiple
library names are allowed, split them with comma+space ", ".
Example:
.. code-block:: ini
[env:myenv]
lib_force = OneWire, SPI
.. _projectconf_lib_ignore: .. _projectconf_lib_ignore:
``lib_ignore`` ``lib_ignore``

View File

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

View File

@ -46,8 +46,8 @@ commonvars.AddVariables(
# library options # library options
("LIB_LDF_MODE",), ("LIB_LDF_MODE",),
("LIB_COMPAT_MODE",), ("LIB_COMPAT_MODE",),
("LIB_DEPS",),
("LIB_IGNORE",), ("LIB_IGNORE",),
("LIB_FORCE",),
("LIB_EXTRA_DIRS",), ("LIB_EXTRA_DIRS",),
# board options # board options
@ -121,10 +121,10 @@ for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT",
env[var] = environ.get(k) env[var] = environ.get(k)
# Parse comma separated items # Parse comma separated items
for opt in ("LIB_IGNORE", "LIB_FORCE", "LIB_EXTRA_DIRS"): for opt in ("LIB_DEPS", "LIB_IGNORE", "LIB_EXTRA_DIRS"):
if opt not in env: if opt not in env:
continue continue
env[opt] = [l.strip() for l in env[opt].split(",") if l.strip()] env[opt] = [l.strip() for l in env[opt].split(", ") if l.strip()]
env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", []))
env.LoadPioPlatform(commonvars) env.LoadPioPlatform(commonvars)

View File

@ -331,9 +331,12 @@ class ProjectAsLibBuilder(LibBuilderBase):
pass pass
def search_deps_recursive(self, lib_builders, search_paths=None): def search_deps_recursive(self, lib_builders, search_paths=None):
for lib_name in self.env.get("LIB_FORCE", []): for dep in self.env.get("LIB_DEPS", []):
for token in ("@", "="):
if token in dep:
dep, _ = dep.split(token, 1)
for lb in lib_builders: for lb in lib_builders:
if lb.name == lib_name: if lb.name == dep:
if lb not in self.depbuilders: if lb not in self.depbuilders:
self.depend_recursive(lb, lib_builders) self.depend_recursive(lb, lib_builders)
break break

View File

@ -128,7 +128,7 @@ class EnvironmentProcessor(object):
REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"} REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"}
RENAMED_OPTIONS = {"lib_use": "lib_force"} RENAMED_OPTIONS = {"lib_use": "lib_deps", "lib_force": "lib_deps"}
RENAMED_PLATFORMS = {"espressif": "espressif8266"} RENAMED_PLATFORMS = {"espressif": "espressif8266"}
@ -152,18 +152,15 @@ class EnvironmentProcessor(object):
terminal_width, _ = click.get_terminal_size() terminal_width, _ = click.get_terminal_size()
start_time = time() start_time = time()
process_opts = [] # multi-line values to one line
for k, v in self.options.items(): for k, v in self.options.items():
if "\n" in v: if "\n" in v:
process_opts.append((k, ", ".join( self.options[k] = self.options[k].strip().replace("\n", ", ")
[s.strip() for s in v.split("\n") if s.strip()])))
else:
process_opts.append((k, v))
click.echo("[%s] Processing %s (%s)" % click.echo("[%s] Processing %s (%s)" % (
(datetime.now().strftime("%c"), click.style( datetime.now().strftime("%c"), click.style(
self.name, fg="cyan", bold=True), self.name, fg="cyan", bold=True),
", ".join(["%s: %s" % opts for opts in process_opts]))) ", ".join(["%s: %s" % (k, v) for k, v in self.options.items()])))
click.secho("-" * terminal_width, bold=True) click.secho("-" * terminal_width, bold=True)
if self.silent: if self.silent:
click.echo("Please wait...") click.echo("Please wait...")
@ -248,9 +245,7 @@ class EnvironmentProcessor(object):
], self.verbose) ], self.verbose)
if "lib_deps" in self.options: if "lib_deps" in self.options:
_autoinstall_libdeps(self.cmd_ctx, [ _autoinstall_libdeps(self.cmd_ctx, [
d.strip() d.strip() for d in self.options['lib_deps'].split(", ")
for d in self.options['lib_deps'].split(
"\n" if "\n" in self.options['lib_deps'] else ", ")
if d.strip() if d.strip()
], self.verbose) ], self.verbose)
@ -271,7 +266,11 @@ def _autoinstall_libdeps(ctx, libraries, verbose=False):
ctx.obj = LibraryManager(storage_dir) ctx.obj = LibraryManager(storage_dir)
if verbose: if verbose:
click.echo("Library Storage: " + storage_dir) click.echo("Library Storage: " + storage_dir)
ctx.invoke(cmd_lib_install, libraries=libraries, silent=not verbose) for lib in libraries:
try:
ctx.invoke(cmd_lib_install, libraries=[lib], silent=not verbose)
except exception.LibNotFound as e:
click.secho("Warning! %s" % e, fg="yellow")
def _clean_pioenvs_dir(pioenvs_dir): def _clean_pioenvs_dir(pioenvs_dir):

View File

@ -158,7 +158,9 @@ class APIRequestError(PlatformioException):
class LibNotFound(PlatformioException): class LibNotFound(PlatformioException):
MESSAGE = "Library `{0}` has not been found in the registry" MESSAGE = "Library `{0}` has not been found in PlatformIO Registry.\n"\
"You can ignore this message, if `{0}` is a built-in library "\
"(included in framework, SDK). E.g., SPI, Wire, etc."
class NotGlobalLibDir(PlatformioException): class NotGlobalLibDir(PlatformioException):

View File

@ -203,7 +203,7 @@ class LibraryManager(BasePkgManager):
name, dl_data['url'].replace("http://", "https://") name, dl_data['url'].replace("http://", "https://")
if app.get_setting("enable_ssl") else dl_data['url'], requirements) if app.get_setting("enable_ssl") else dl_data['url'], requirements)
def install(self, # pylint: disable=too-many-arguments def install(self, # pylint: disable=too-many-arguments, too-many-locals
name, name,
requirements=None, requirements=None,
silent=False, silent=False,
@ -232,8 +232,13 @@ class LibraryManager(BasePkgManager):
if any([s in filters.get("version", "") for s in ("\\", "/")]): if any([s in filters.get("version", "") for s in ("\\", "/")]):
self.install("{name}={version}".format(**filters)) self.install("{name}={version}".format(**filters))
else: else:
lib_info = self.search_for_library(filters, silent, try:
interactive) lib_info = self.search_for_library(filters, silent,
interactive)
except exception.LibNotFound as e:
click.secho("Warning! %s" % e, fg="yellow")
continue
if filters.get("version"): if filters.get("version"):
self.install( self.install(
lib_info['id'], lib_info['id'],