mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
idf.py: use underlying flash targets
This commit is contained in:
parent
38b3fbfbfb
commit
7ddd39ec7d
@ -8,17 +8,10 @@ import click
|
||||
from idf_py_actions.constants import GENERATORS, SUPPORTED_TARGETS
|
||||
from idf_py_actions.errors import FatalError
|
||||
from idf_py_actions.global_options import global_options
|
||||
from idf_py_actions.tools import ensure_build_directory, idf_version, merge_action_lists, realpath, run_tool
|
||||
from idf_py_actions.tools import ensure_build_directory, idf_version, merge_action_lists, realpath, run_target
|
||||
|
||||
|
||||
def action_extensions(base_actions, project_path):
|
||||
def run_target(target_name, args):
|
||||
generator_cmd = GENERATORS[args.generator]["command"]
|
||||
|
||||
if args.verbose:
|
||||
generator_cmd += [GENERATORS[args.generator]["verbose_flag"]]
|
||||
|
||||
run_tool(generator_cmd[0], generator_cmd + [target_name], args.build_dir)
|
||||
|
||||
def build_target(target_name, ctx, args):
|
||||
"""
|
||||
|
@ -4,7 +4,7 @@ import sys
|
||||
|
||||
from idf_py_actions.errors import FatalError
|
||||
from idf_py_actions.global_options import global_options
|
||||
from idf_py_actions.tools import ensure_build_directory, run_tool
|
||||
from idf_py_actions.tools import ensure_build_directory, run_tool, run_target
|
||||
|
||||
PYTHON = sys.executable
|
||||
|
||||
@ -99,18 +99,11 @@ def action_extensions(base_actions, project_path):
|
||||
"""
|
||||
Run esptool to flash the entire project, from an argfile generated by the build system
|
||||
"""
|
||||
flasher_args_path = {
|
||||
# action -> name of flasher args file generated by build system
|
||||
"bootloader-flash": "flash_bootloader_args",
|
||||
"partition_table-flash": "flash_partition_table_args",
|
||||
"app-flash": "flash_app_args",
|
||||
"flash": "flash_project_args",
|
||||
"encrypted-app-flash": "flash_encrypted_app_args",
|
||||
"encrypted-flash": "flash_encrypted_project_args",
|
||||
}[action]
|
||||
esptool_args = _get_esptool_args(args)
|
||||
esptool_args += ["write_flash", "@" + flasher_args_path]
|
||||
run_tool("esptool.py", esptool_args, args.build_dir)
|
||||
if args.port is None:
|
||||
args.port = _get_default_serial_port()
|
||||
|
||||
run_target(action, args, {"ESPPORT": args.port,
|
||||
"ESPBAUD": str(args.baud)})
|
||||
|
||||
def erase_flash(action, ctx, args):
|
||||
esptool_args = _get_esptool_args(args)
|
||||
|
@ -63,7 +63,7 @@ def idf_version():
|
||||
return version
|
||||
|
||||
|
||||
def run_tool(tool_name, args, cwd):
|
||||
def run_tool(tool_name, args, cwd, env=dict()):
|
||||
def quote_arg(arg):
|
||||
" Quote 'arg' if necessary "
|
||||
if " " in arg and not (arg.startswith('"') or arg.startswith("'")):
|
||||
@ -73,13 +73,26 @@ def run_tool(tool_name, args, cwd):
|
||||
display_args = " ".join(quote_arg(arg) for arg in args)
|
||||
print("Running %s in directory %s" % (tool_name, quote_arg(cwd)))
|
||||
print('Executing "%s"...' % str(display_args))
|
||||
|
||||
env_copy = dict(os.environ)
|
||||
env_copy.update(env)
|
||||
|
||||
try:
|
||||
# Note: we explicitly pass in os.environ here, as we may have set IDF_PATH there during startup
|
||||
subprocess.check_call(args, env=os.environ, cwd=cwd)
|
||||
subprocess.check_call(args, env=env_copy, cwd=cwd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise FatalError("%s failed with exit code %d" % (tool_name, e.returncode))
|
||||
|
||||
|
||||
def run_target(target_name, args, env=dict()):
|
||||
generator_cmd = GENERATORS[args.generator]["command"]
|
||||
|
||||
if args.verbose:
|
||||
generator_cmd += [GENERATORS[args.generator]["verbose_flag"]]
|
||||
|
||||
run_tool(generator_cmd[0], generator_cmd + [target_name], args.build_dir, env)
|
||||
|
||||
|
||||
def _strip_quotes(value, regexp=re.compile(r"^\"(.*)\"$|^'(.*)'$|^(.*)$")):
|
||||
"""
|
||||
Strip quotes like CMake does during parsing cache entries
|
||||
|
Loading…
x
Reference in New Issue
Block a user