forked from platformio/platformio-core
Add "--save" flag to "platformio lib install" command // Resolve #1028
This commit is contained in:
@ -18,7 +18,8 @@ PlatformIO 4.0
|
||||
|
||||
* **Library Management**
|
||||
|
||||
- Install all project dependencies declared via `lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option using `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command (`issue #2147 <https://github.com/platformio/platformio-core/issues/2147>`_)
|
||||
- Save libraries passed to `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command into the project dependency list (`lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__) with a new ``--save`` flag (`issue #1028 <https://github.com/platformio/platformio-core/issues/1028>`_)
|
||||
- Install all project dependencies declared via `lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option using a simple `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command (`issue #2147 <https://github.com/platformio/platformio-core/issues/2147>`_)
|
||||
- Use isolated library dependency storage per project build environment (`issue #1696 <https://github.com/platformio/platformio-core/issues/1696>`_)
|
||||
- Override default source and include directories for a library via `library.json <http://docs.platformio.org/page/librarymanager/config.html>`__ manifest using ``includeDir`` and ``srcDir`` fields
|
||||
- Use workspace ``.pio/libdeps`` folder for project dependencies instead of ``.piolibdeps``
|
||||
|
2
docs
2
docs
Submodule docs updated: 51593ac34b...2ed6a490e5
@ -33,6 +33,8 @@ try:
|
||||
except ImportError:
|
||||
from urllib import quote
|
||||
|
||||
CTX_META_INPUT_DIRS_KEY = __name__ + ".input_dirs"
|
||||
CTX_META_PROJECT_ENVIRONMENTS_KEY = __name__ + ".project_environments"
|
||||
CTX_META_STORAGE_DIRS_KEY = __name__ + ".storage_dirs"
|
||||
CTX_META_STORAGE_LIBDEPS_KEY = __name__ + ".storage_lib_deps"
|
||||
|
||||
@ -87,6 +89,8 @@ def cli(ctx, **options):
|
||||
join(util.get_home_dir(), "lib"),
|
||||
ctx.invoked_subcommand)
|
||||
|
||||
ctx.meta[CTX_META_PROJECT_ENVIRONMENTS_KEY] = options['environment']
|
||||
ctx.meta[CTX_META_INPUT_DIRS_KEY] = storage_dirs
|
||||
ctx.meta[CTX_META_STORAGE_DIRS_KEY] = []
|
||||
ctx.meta[CTX_META_STORAGE_LIBDEPS_KEY] = {}
|
||||
for storage_dir in storage_dirs:
|
||||
@ -110,11 +114,10 @@ def cli(ctx, **options):
|
||||
|
||||
@cli.command("install", short_help="Install library")
|
||||
@click.argument("libraries", required=False, nargs=-1, metavar="[LIBRARY...]")
|
||||
# @click.option(
|
||||
# "--save",
|
||||
# is_flag=True,
|
||||
# help="Save installed libraries into the project's platformio.ini "
|
||||
# "library dependencies")
|
||||
@click.option(
|
||||
"--save",
|
||||
is_flag=True,
|
||||
help="Save installed libraries into the `platformio.ini` dependency list")
|
||||
@click.option(
|
||||
"-s", "--silent", is_flag=True, help="Suppress progress reporting")
|
||||
@click.option(
|
||||
@ -127,9 +130,29 @@ def cli(ctx, **options):
|
||||
is_flag=True,
|
||||
help="Reinstall/redownload library if exists")
|
||||
@click.pass_context
|
||||
def lib_install(ctx, libraries, silent, interactive, force):
|
||||
storage_libdeps = ctx.meta[CTX_META_STORAGE_LIBDEPS_KEY]
|
||||
def lib_install( # pylint: disable=too-many-arguments
|
||||
ctx, libraries, save, silent, interactive, force):
|
||||
storage_dirs = ctx.meta[CTX_META_STORAGE_DIRS_KEY]
|
||||
input_dirs = ctx.meta.get(CTX_META_INPUT_DIRS_KEY, [])
|
||||
storage_libdeps = ctx.meta.get(CTX_META_STORAGE_LIBDEPS_KEY, [])
|
||||
|
||||
if save and libraries:
|
||||
project_environments = ctx.meta[CTX_META_PROJECT_ENVIRONMENTS_KEY]
|
||||
for input_dir in input_dirs:
|
||||
config = ProjectConfig.get_instance(
|
||||
join(input_dir, "platformio.ini"))
|
||||
config.validate(project_environments)
|
||||
for env in config.envs():
|
||||
if project_environments and env not in project_environments:
|
||||
continue
|
||||
config.expand_interpolations = False
|
||||
lib_deps = (config.getlist(
|
||||
"env:" + env, "lib_deps") if config.has_option(
|
||||
"env:" + env, "lib_deps") else [])
|
||||
lib_deps.extend(l for l in libraries if l not in lib_deps)
|
||||
config.set("env:" + env, "lib_deps", lib_deps)
|
||||
config.save()
|
||||
|
||||
for storage_dir in storage_dirs:
|
||||
if not silent and (libraries or storage_dir in storage_libdeps):
|
||||
print_storage_header(storage_dirs, storage_dir)
|
||||
|
@ -230,6 +230,8 @@ class ProjectConfig(object):
|
||||
def set(self, section, option, value):
|
||||
if isinstance(value, (list, tuple)):
|
||||
value = "\n".join(value)
|
||||
if value:
|
||||
value = "\n" + value # start from a new line
|
||||
self._parser.set(section, option, value)
|
||||
|
||||
def get(self, section, option):
|
||||
|
@ -391,7 +391,7 @@ def backup_reports(items):
|
||||
|
||||
for params in items:
|
||||
# skip static options
|
||||
for key in params.keys():
|
||||
for key in list(params.keys()):
|
||||
if key in ("v", "tid", "cid", "cd1", "cd2", "sr", "an"):
|
||||
del params[key]
|
||||
|
||||
|
Reference in New Issue
Block a user