cmake: flash: three runners.yaml fixes

There are two problems with the way runners.yaml is being created:

1. The dictionary which contains the arguments for each runner is
   using the runner's name converted to a C identifier instead of the
   runner's name itself. That causes west flash to fail when the two
   are different, e.g. for 'misc-flasher' (runner name), which is
   different than 'misc_flasher' (runner name as C identifier)

2. We need to make sure that the dictionary key maps to an empty list
   if there are no arguments, which normally doesn't happen since the
   runner usually at least takes the path of the file to flash or debug.
   It does happen in the case of misc-flasher, though, since the whole
   point of that runner is that it's an escape hatch for people with
   out of tree scripts that nevertheless want 'west flash' integration
   for things like sanitycheck device testing.

3. A copy/paste error is setting the debug runner to the flash runner.

Fix them all.

Fixes: #23004
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-02-21 09:37:40 -08:00 committed by Johan Hedberg
commit e4479e2fec

View file

@ -27,7 +27,7 @@ flash-runner: ${BOARD_FLASH_RUNNER}
string(APPEND yaml_contents "\ string(APPEND yaml_contents "\
# Default debug runner if --runner is not given. # Default debug runner if --runner is not given.
debug-runner: ${BOARD_FLASH_RUNNER} debug-runner: ${BOARD_DEBUG_RUNNER}
") ")
endif() endif()
@ -69,14 +69,21 @@ args:
foreach(runner ${runners}) foreach(runner ${runners})
string(MAKE_C_IDENTIFIER ${runner} runner_id) string(MAKE_C_IDENTIFIER ${runner} runner_id)
string(APPEND yaml_contents "\ string(APPEND yaml_contents "\
${runner_id}: ${runner}:")
")
get_property(args GLOBAL PROPERTY "BOARD_RUNNER_ARGS_${runner_id}") get_property(args GLOBAL PROPERTY "BOARD_RUNNER_ARGS_${runner_id}")
foreach(arg ${args}) if(args)
string(APPEND yaml_contents "\ # Usually, the runner has arguments. Append them to runners.yaml,
- ${arg} # one per line.
string(APPEND yaml_contents "\n")
foreach(arg ${args})
string(APPEND yaml_contents "\
- ${arg}
") ")
endforeach() endforeach()
else()
# If the runner doesn't need any arguments, just use an empty list.
string(APPEND yaml_contents " []\n")
endif()
endforeach() endforeach()
# Write the final contents and set its location in the cache. # Write the final contents and set its location in the cache.