Improve platform auto-installing (especially for @SmartAthill)

This commit is contained in:
Ivan Kravets
2015-07-16 22:19:09 +03:00
parent e20f6abef4
commit de1cce41b0
2 changed files with 27 additions and 7 deletions

View File

@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
VERSION = (2, 2, "1a0")
VERSION = (2, 2, "1a1")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -163,7 +163,7 @@ class EnvironmentProcessor(object):
telemetry.on_run_environment(self.options, build_targets)
# install platform and libs dependencies
_autoinstall_platform(self.cmd_ctx, platform)
_autoinstall_platform(self.cmd_ctx, platform, build_targets)
if "lib_install" in self.options:
_autoinstall_libs(self.cmd_ctx, self.options['lib_install'])
@ -171,14 +171,34 @@ class EnvironmentProcessor(object):
return p.run(build_vars, build_targets, self.verbose_level)
def _autoinstall_platform(ctx, platform):
def _autoinstall_platform(ctx, platform, targets):
installed_platforms = PlatformFactory.get_platforms(
installed=True).keys()
if (platform not in installed_platforms and (
not app.get_setting("enable_prompts") or
cmd_options = {}
p = PlatformFactory.newPlatform(platform)
if "uploadlazy" in targets:
upload_tools = p.pkg_aliases_to_names(["uploader"])
# platform without uploaders
if not upload_tools and platform in installed_platforms:
return
# uploaders are already installed
if set(upload_tools) <= set(p.get_installed_packages()):
return
cmd_options['skip_default_package'] = True
if upload_tools:
cmd_options['with_package'] = ["uploader"]
elif (set(p.pkg_aliases_to_names(["toolchain"])) <=
set(p.get_installed_packages())):
return
if (not app.get_setting("enable_prompts") or
click.confirm("The platform '%s' has not been installed yet. "
"Would you like to install it now?" % platform))):
ctx.invoke(cmd_platforms_install, platforms=[platform])
"Would you like to install it now?" % platform)):
ctx.invoke(cmd_platforms_install, platforms=[platform], **cmd_options)
def _autoinstall_libs(ctx, libids_list):