manifest: filter duplicates when merging west-commands

If the user imports a manifest, and specifies its west-commands, like
this:

    - name: zephyr
      west-commands: scripts/west-commands.yml

where zephyr/west.yml also specifies a west-commands, then they get
warnings when the manifest is parsed, like this:

    WARNING: ignoring project zephyr extension command "completion"; command "completion" is already defined as extension command
    WARNING: ignoring project zephyr extension command "boards"; command "boards" is already defined as extension command
    WARNING: ignoring project zephyr extension command "build"; command "build" is already defined as extension command
    WARNING: ignoring project zephyr extension command "sign"; command "sign" is already defined as extension command
    WARNING: ignoring project zephyr extension command "flash"; command "flash" is already defined as extension command
    WARNING: ignoring project zephyr extension command "debug"; command "debug" is already defined as extension command
    WARNING: ignoring project zephyr extension command "debugserver"; command "debugserver" is already defined as extension command
    WARNING: ignoring project zephyr extension command "attach"; command "attach" is already defined as extension command

Filter duplicates when merging west commands during manifest parsing
to avoid this outcome.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-02-21 11:59:55 -08:00 committed by Marti Bolivar
parent aded97277e
commit 8ed75547ed
1 changed files with 6 additions and 1 deletions

View File

@ -1018,8 +1018,13 @@ class Manifest:
# Merge two west_commands attributes. Try to keep the result a
# str if possible, but upgrade it to a list if both wc1 and
# wc2 are truthy.
#
# Filter out duplicates to make sure that if the user imports
# a manifest and redundantly specifies its west-commands,
# we don't get the same entries twice.
if wc1 and wc2:
return _ensure_list(wc1) + _ensure_list(wc2)
wc1 = _ensure_list(wc1)
return wc1 + [wc for wc in _ensure_list(wc2) if wc not in wc1]
else:
return wc1 or wc2