From e50327bccc3d26b7804cf1e49530437add510441 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 17 Sep 2016 16:32:16 +0300 Subject: [PATCH] Deprecate ``lib_force`` option, please use `lib_deps` instead --- HISTORY.rst | 1 + docs/librarymanager/ldf.rst | 1 - docs/projectconf.rst | 26 ++------------------------ platformio/__init__.py | 2 +- platformio/builder/main.py | 6 +++--- platformio/builder/tools/piolib.py | 7 +++++-- platformio/commands/run.py | 27 +++++++++++++-------------- platformio/exception.py | 4 +++- platformio/managers/lib.py | 11 ++++++++--- 9 files changed, 36 insertions(+), 49 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 67c4dd35..f722dea9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,7 @@ PlatformIO 3.0 * Improved Project Generator when custom ``--project-option`` is passed to `platformio init `__ command +* Deprecated ``lib_force`` option, please use `lib_deps `__ instead * Fixed SSL Server-Name-Indication for Python < 2.7.9 * Return valid exit code from ``plaformio test`` command diff --git a/docs/librarymanager/ldf.rst b/docs/librarymanager/ldf.rst index ed56dc39..5399009f 100644 --- a/docs/librarymanager/ldf.rst +++ b/docs/librarymanager/ldf.rst @@ -32,7 +32,6 @@ Library Dependency Finder has controls that can be set up in :ref:`projectconf`: * :ref:`projectconf_lib_deps` * :ref:`projectconf_lib_extra_dirs` - * :ref:`projectconf_lib_force` * :ref:`projectconf_lib_ignore` * :ref:`projectconf_lib_compat_mode` * :ref:`projectconf_lib_ldf_mode` diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 832c2571..7c31c9f5 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -707,9 +707,11 @@ Multiple dependencies are allowed (multi-lines or separated with comma+space ", .. code-block:: ini + ; one line definition (comma + space) [env:myenv] lib_deps = LIBRARY_1, LIBRARY_2, LIBRARY_N + ; multi-line definition [env:myenv2] lib_deps = LIBRARY_1 @@ -732,30 +734,6 @@ Example: https://github.com/gioblu/PJON.git@v2.0 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: ``lib_ignore`` diff --git a/platformio/__init__.py b/platformio/__init__.py index 32c14c03..5cd7d774 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 1, "0a2") +VERSION = (3, 1, "0a3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 2da97908..d5361da1 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -46,8 +46,8 @@ commonvars.AddVariables( # library options ("LIB_LDF_MODE",), ("LIB_COMPAT_MODE",), + ("LIB_DEPS",), ("LIB_IGNORE",), - ("LIB_FORCE",), ("LIB_EXTRA_DIRS",), # board options @@ -121,10 +121,10 @@ for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT", env[var] = environ.get(k) # 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: 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.LoadPioPlatform(commonvars) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 989b1897..7283509f 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -331,9 +331,12 @@ class ProjectAsLibBuilder(LibBuilderBase): pass 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: - if lb.name == lib_name: + if lb.name == dep: if lb not in self.depbuilders: self.depend_recursive(lb, lib_builders) break diff --git a/platformio/commands/run.py b/platformio/commands/run.py index fedf0225..a07e63b8 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -128,7 +128,7 @@ class EnvironmentProcessor(object): 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"} @@ -152,18 +152,15 @@ class EnvironmentProcessor(object): terminal_width, _ = click.get_terminal_size() start_time = time() - process_opts = [] + # multi-line values to one line for k, v in self.options.items(): if "\n" in v: - process_opts.append((k, ", ".join( - [s.strip() for s in v.split("\n") if s.strip()]))) - else: - process_opts.append((k, v)) + self.options[k] = self.options[k].strip().replace("\n", ", ") - click.echo("[%s] Processing %s (%s)" % - (datetime.now().strftime("%c"), click.style( - self.name, fg="cyan", bold=True), - ", ".join(["%s: %s" % opts for opts in process_opts]))) + click.echo("[%s] Processing %s (%s)" % ( + datetime.now().strftime("%c"), click.style( + self.name, fg="cyan", bold=True), + ", ".join(["%s: %s" % (k, v) for k, v in self.options.items()]))) click.secho("-" * terminal_width, bold=True) if self.silent: click.echo("Please wait...") @@ -248,9 +245,7 @@ class EnvironmentProcessor(object): ], self.verbose) if "lib_deps" in self.options: _autoinstall_libdeps(self.cmd_ctx, [ - d.strip() - for d in self.options['lib_deps'].split( - "\n" if "\n" in self.options['lib_deps'] else ", ") + d.strip() for d in self.options['lib_deps'].split(", ") if d.strip() ], self.verbose) @@ -271,7 +266,11 @@ def _autoinstall_libdeps(ctx, libraries, verbose=False): ctx.obj = LibraryManager(storage_dir) if verbose: 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): diff --git a/platformio/exception.py b/platformio/exception.py index 62b96b40..478fb515 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -158,7 +158,9 @@ class APIRequestError(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): diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index 986dd7c3..c4bedced 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -203,7 +203,7 @@ class LibraryManager(BasePkgManager): name, dl_data['url'].replace("http://", "https://") 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, requirements=None, silent=False, @@ -232,8 +232,13 @@ class LibraryManager(BasePkgManager): if any([s in filters.get("version", "") for s in ("\\", "/")]): self.install("{name}={version}".format(**filters)) else: - lib_info = self.search_for_library(filters, silent, - interactive) + try: + 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"): self.install( lib_info['id'],