From e288499db986975d801e086b160ae2412022ce1d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 28 Jun 2015 20:16:43 +0300 Subject: [PATCH] Rename "install_libs" env option to "lib_install" --- HISTORY.rst | 2 +- docs/projectconf.rst | 6 +++--- platformio/__main__.py | 2 +- platformio/commands/run.py | 40 ++++++++++++++++++++++---------------- platformio/maintenance.py | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5f4ae07b..723f67b0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -105,7 +105,7 @@ Release History (`issue #192 `_) * Control verbosity of `platformio run `_ command via ``-v/--verbose`` option * Add library dependencies for build environment using - `install_libs `_ + `lib_install `_ option in ``platformio.ini`` (`issue #134 `_) * Specify libraries which are compatible with build environment using diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 8364ef2c..74d584f4 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -341,8 +341,8 @@ exclude ``.git`` and ``svn`` repository folders and exclude ``examples`` folder. This option can be set by global environment variable :ref:`envvar_PLATFORMIO_SRC_FILTER`. -``install_libs`` -^^^^^^^^^^^^^^^^ +``lib_install`` +^^^^^^^^^^^^^^^ Specify dependent libraries which should be installed before environment process. The only library IDs are allowed. Multiple libraries can be passed @@ -355,7 +355,7 @@ Example: .. code-block:: ini [env:depends_on_some_libs] - install_libs = 1,13,19 + lib_install = 1,13,19 ``lib_use`` ^^^^^^^^^^^ diff --git a/platformio/__main__.py b/platformio/__main__.py index 2df8de4d..9721e794 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -41,7 +41,7 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904 def _handle_obsolate_command(name): if name in ("install", "list", "search", "show", "uninstall"): click.secho( - "Warning! `platformio %s` command is obsoleted and will be " + "Warning! `platformio %s` command is deprecated and will be " "removed in the next release! Please use " "`platformio platforms %s` instead." % (name, name), fg="yellow" diff --git a/platformio/commands/run.py b/platformio/commands/run.py index b4eee914..e5a3fcbe 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -74,16 +74,17 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 class EnvironmentProcessor(object): RENAMED_OPTIONS = { - "LDF_CYCLIC": "LIB_DFCYCLIC", + "INSTALL_LIBS": "LIB_INSTALL", "IGNORE_LIBS": "LIB_IGNORE", - "USE_LIBS": "LIB_USE" + "USE_LIBS": "LIB_USE", + "LDF_CYCLIC": "LIB_DFCYCLIC" } def __init__(self, cmd_ctx, name, options, # pylint: disable=R0913 targets, upload_port, verbose): self.cmd_ctx = cmd_ctx self.name = name - self.options = options + self.options = self._validate_options(options) self.targets = targets self.upload_port = upload_port self.verbose_level = int(verbose) @@ -114,24 +115,29 @@ class EnvironmentProcessor(object): return not is_error + def _validate_options(self, options): + result = {} + for k, v in options.items(): + _k = k.upper() + # process obsolete options + if _k in self.RENAMED_OPTIONS: + click.secho( + "Warning! `%s` option is deprecated and will be " + "removed in the next release! Please use " + "`%s` instead." % ( + k, self.RENAMED_OPTIONS[_k].lower()), + fg="yellow" + ) + k = self.RENAMED_OPTIONS[_k].lower() + result[k] = v + return result + def _get_build_variables(self): variables = ["PIOENV=" + self.name] if self.upload_port: variables.append("UPLOAD_PORT=%s" % self.upload_port) for k, v in self.options.items(): k = k.upper() - - # process obsolete options - if k in self.RENAMED_OPTIONS: - click.secho( - "Warning! `%s` option is obsoleted and will be " - "removed in the next release! Please use " - "`%s` instead." % ( - k.lower(), self.RENAMED_OPTIONS[k].lower()), - fg="yellow" - ) - k = self.RENAMED_OPTIONS[k] - if k == "TARGETS" or (k == "UPLOAD_PORT" and self.upload_port): continue variables.append("%s=%s" % (k, v)) @@ -157,8 +163,8 @@ class EnvironmentProcessor(object): # install platform and libs dependencies _autoinstall_platform(self.cmd_ctx, platform) - if "install_libs" in self.options: - _autoinstall_libs(self.cmd_ctx, self.options['install_libs']) + if "lib_install" in self.options: + _autoinstall_libs(self.cmd_ctx, self.options['lib_install']) p = PlatformFactory.newPlatform(platform) return p.run(build_vars, build_targets, self.verbose_level) diff --git a/platformio/maintenance.py b/platformio/maintenance.py index e225aa4f..b2089384 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -86,7 +86,7 @@ class Upgrader(object): def _upgrade_to_0_9_0(self, ctx): # pylint: disable=R0201 prev_platforms = [] - # remove platform's folder (obsoleted package structure) + # remove platform's folder (obsolete package structure) for name in PlatformFactory.get_platforms().keys(): pdir = join(get_home_dir(), name) if not isdir(pdir):