mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 21:54:33 +02:00
Merge branch 'feature/idfpy_add_help_subcommand' into 'master'
idf.py: Add help and build-system-targets subcommands Closes IDF-1884 See merge request espressif/esp-idf!9615
This commit is contained in:
13
tools/idf.py
13
tools/idf.py
@@ -517,6 +517,10 @@ def init_cli(verbose_output=None):
|
|||||||
ctx = click.get_current_context()
|
ctx = click.get_current_context()
|
||||||
global_args = PropertyDict(kwargs)
|
global_args = PropertyDict(kwargs)
|
||||||
|
|
||||||
|
def _help_and_exit():
|
||||||
|
print(ctx.get_help())
|
||||||
|
ctx.exit()
|
||||||
|
|
||||||
# Show warning if some tasks are present several times in the list
|
# Show warning if some tasks are present several times in the list
|
||||||
dupplicated_tasks = sorted(
|
dupplicated_tasks = sorted(
|
||||||
[item for item, count in Counter(task.name for task in tasks).items() if count > 1])
|
[item for item, count in Counter(task.name for task in tasks).items() if count > 1])
|
||||||
@@ -527,9 +531,13 @@ def init_cli(verbose_output=None):
|
|||||||
("s %s are" % dupes if len(dupplicated_tasks) > 1 else " %s is" % dupes) +
|
("s %s are" % dupes if len(dupplicated_tasks) > 1 else " %s is" % dupes) +
|
||||||
"Only first occurence will be executed.")
|
"Only first occurence will be executed.")
|
||||||
|
|
||||||
|
for task in tasks:
|
||||||
|
# Show help and exit if help is in the list of commands
|
||||||
|
if task.name == 'help':
|
||||||
|
_help_and_exit()
|
||||||
|
|
||||||
# Set propagated global options.
|
# Set propagated global options.
|
||||||
# These options may be set on one subcommand, but available in the list of global arguments
|
# These options may be set on one subcommand, but available in the list of global arguments
|
||||||
for task in tasks:
|
|
||||||
for key in list(task.action_args):
|
for key in list(task.action_args):
|
||||||
option = next((o for o in ctx.command.params if o.name == key), None)
|
option = next((o for o in ctx.command.params if o.name == key), None)
|
||||||
|
|
||||||
@@ -557,8 +565,7 @@ def init_cli(verbose_output=None):
|
|||||||
|
|
||||||
# Always show help when command is not provided
|
# Always show help when command is not provided
|
||||||
if not tasks:
|
if not tasks:
|
||||||
print(ctx.get_help())
|
_help_and_exit()
|
||||||
ctx.exit()
|
|
||||||
|
|
||||||
# Build full list of tasks to and deal with dependencies and order dependencies
|
# Build full list of tasks to and deal with dependencies and order dependencies
|
||||||
tasks_to_run = OrderedDict()
|
tasks_to_run = OrderedDict()
|
||||||
|
@@ -13,7 +13,6 @@ from idf_py_actions.tools import ensure_build_directory, idf_version, merge_acti
|
|||||||
|
|
||||||
|
|
||||||
def action_extensions(base_actions, project_path):
|
def action_extensions(base_actions, project_path):
|
||||||
|
|
||||||
def build_target(target_name, ctx, args):
|
def build_target(target_name, ctx, args):
|
||||||
"""
|
"""
|
||||||
Execute the target build system to build target 'target_name'
|
Execute the target build system to build target 'target_name'
|
||||||
@@ -24,6 +23,10 @@ def action_extensions(base_actions, project_path):
|
|||||||
ensure_build_directory(args, ctx.info_name)
|
ensure_build_directory(args, ctx.info_name)
|
||||||
run_target(target_name, args)
|
run_target(target_name, args)
|
||||||
|
|
||||||
|
def list_build_system_targets(target_name, ctx, args):
|
||||||
|
"""Shows list of targets known to build sytem (make/ninja)"""
|
||||||
|
build_target('help', ctx, args)
|
||||||
|
|
||||||
def menuconfig(target_name, ctx, args, style):
|
def menuconfig(target_name, ctx, args, style):
|
||||||
"""
|
"""
|
||||||
Menuconfig target is build_target extended with the style argument for setting the value for the environment
|
Menuconfig target is build_target extended with the style argument for setting the value for the environment
|
||||||
@@ -138,7 +141,9 @@ def action_extensions(base_actions, project_path):
|
|||||||
|
|
||||||
def set_target(action, ctx, args, idf_target):
|
def set_target(action, ctx, args, idf_target):
|
||||||
if (not args["preview"] and idf_target in PREVIEW_TARGETS):
|
if (not args["preview"] and idf_target in PREVIEW_TARGETS):
|
||||||
raise FatalError("%s is still in preview. You have to append '--preview' option after idf.py to use any preview feature." % idf_target)
|
raise FatalError(
|
||||||
|
"%s is still in preview. You have to append '--preview' option after idf.py to use any preview feature."
|
||||||
|
% idf_target)
|
||||||
args.define_cache_entry.append("IDF_TARGET=" + idf_target)
|
args.define_cache_entry.append("IDF_TARGET=" + idf_target)
|
||||||
sdkconfig_path = os.path.join(args.project_dir, 'sdkconfig')
|
sdkconfig_path = os.path.join(args.project_dir, 'sdkconfig')
|
||||||
sdkconfig_old = sdkconfig_path + ".old"
|
sdkconfig_old = sdkconfig_path + ".old"
|
||||||
@@ -370,10 +375,14 @@ def action_extensions(base_actions, project_path):
|
|||||||
"help": "Read otadata partition.",
|
"help": "Read otadata partition.",
|
||||||
"options": global_options,
|
"options": global_options,
|
||||||
},
|
},
|
||||||
|
"build-system-targets": {
|
||||||
|
"callback": list_build_system_targets,
|
||||||
|
"help": "Print list of build system targets.",
|
||||||
|
},
|
||||||
"fallback": {
|
"fallback": {
|
||||||
"callback": fallback_target,
|
"callback": fallback_target,
|
||||||
"help": "Handle for targets not known for idf.py.",
|
"help": "Handle for targets not known for idf.py.",
|
||||||
"hidden": True
|
"hidden": True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user