idf_tools.py: fix downloading for tools which have "on_request" options for some platforms.
'install' and 'download' options can be used for 'required' or 'all' tools
@@ -1065,7 +1065,10 @@ def action_download(args):
tool_for_platform = tool_obj.copy_for_platform(platform)
tools_info_for_platform[name] = tool_for_platform
- if 'all' in tools_spec:
+ if not tools_spec or 'required' in tools_spec:
+ tools_spec = [k for k, v in tools_info_for_platform.items() if v.get_install_type() == IDFTool.INSTALL_ALWAYS]
+ info('Downloading tools for {}: {}'.format(platform, ', '.join(tools_spec)))
+ elif 'all' in tools_spec:
tools_spec = [k for k, v in tools_info_for_platform.items() if v.get_install_type() != IDFTool.INSTALL_NEVER]
info('Downloading tools for {}: {}'.format(platform, ', '.join(tools_spec)))
@@ -1084,7 +1087,9 @@ def action_download(args):
raise SystemExit(1)
if tool_version is None:
tool_version = tool_obj.get_recommended_version()
- assert tool_version is not None
+ if tool_version is None:
+ fatal('tool {} not found for {} platform'.format(tool_name, platform))
+ raise SystemExit(1)
tool_spec = '{}@{}'.format(tool_name, tool_version)
info('Downloading {}'.format(tool_spec))
@@ -1096,7 +1101,7 @@ def action_download(args):
def action_install(args):
tools_info = load_tools_info()
tools_spec = args.tools
- if not tools_spec:
+ if not tools_spec or 'required' in tools_spec:
tools_spec = [k for k, v in tools_info.items() if v.get_install_type() == IDFTool.INSTALL_ALWAYS]
info('Installing tools: {}'.format(', '.join(tools_spec)))
elif 'all' in tools_spec:
@@ -1254,14 +1259,18 @@ def main(argv):
'will be used instead. If this flag is given, the version in PATH ' +
'will be used.', action='store_true')
install = subparsers.add_parser('install', help='Download and install tools into the tools directory')
- install.add_argument('tools', nargs='*', help='Tools to install. ' +
- 'To install a specific version use tool_name@version syntax.' +
+ install.add_argument('tools', metavar='TOOL', nargs='*', default=['required'],
+ help='Tools to install. ' +
+ 'To install a specific version use <tool_name>@<version> syntax. ' +
+ 'Use empty or \'required\' to install required tools, not optional ones. ' +
'Use \'all\' to install all tools, including the optional ones.')
download = subparsers.add_parser('download', help='Download the tools into the dist directory')
download.add_argument('--platform', help='Platform to download the tools for')
- download.add_argument('tools', nargs='+', help='Tools to download. ' +
- 'To download a specific version use tool_name@version syntax.' +
+ download.add_argument('tools', metavar='TOOL', nargs='*', default=['required'],
+ help='Tools to download. ' +
+ 'To download a specific version use <tool_name>@<version> syntax. ' +
+ 'Use empty or \'required\' to download required tools, not optional ones. ' +
'Use \'all\' to download all tools, including the optional ones.')
if IDF_MAINTAINER:
