Skip to content

Commit

Permalink
pw_presubmit: Handle str for ninja_targets
Browse files Browse the repository at this point in the history
If GnGenNinja gets a str for ninja_targets wrap it in a tuple rather
than interpreting it as a list of individual characters.

Bug: b/253021172
Change-Id: Ibc093d1a98d548a13be95ea229e663bb6d02be12
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126193
Reviewed-by: Erik Gilling <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Rob Mohr <[email protected]>
  • Loading branch information
mohrr authored and CQ Bot Account committed Jan 5, 2023
1 parent 44f053c commit 0aadffb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pw_presubmit/py/pw_presubmit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def __init__(
Dict[str, Any]
] = None,
ninja_contexts: Sequence[_CtxMgrOrLambda] = (),
ninja_targets: Union[Sequence[str], Sequence[Sequence[str]]] = (),
ninja_targets: Union[str, Sequence[str], Sequence[Sequence[str]]] = (),
**kwargs,
):
"""Initializes a GnGenNinja object.
Expand All @@ -520,16 +520,18 @@ def __init__(
gn_args: Dict of GN args.
ninja_contexts: List of context managers to apply around ninja
calls.
ninja_targets: List of Ninja targets, or list of list of ninja
targets. If a list of a list, ninja will be called multiple
times with the same build directory.
ninja_targets: Single ninja target, list of Ninja targets, or list
of list of ninja targets. If a list of a list, ninja will be
called multiple times with the same build directory.
**kwargs: Passed on to superclass.
"""
super().__init__(self._substeps(), *args, **kwargs)
self.packages: Sequence[str] = packages
self.gn_args: Dict[str, Any] = gn_args or {}
self.ninja_contexts: Tuple[_CtxMgrOrLambda, ...] = tuple(ninja_contexts)

if isinstance(ninja_targets, str):
ninja_targets = (ninja_targets,)
ninja_targets = list(ninja_targets)
all_strings = all(isinstance(x, str) for x in ninja_targets)
any_strings = any(isinstance(x, str) for x in ninja_targets)
Expand Down

0 comments on commit 0aadffb

Please sign in to comment.