Skip to content

Commit 960376c

Browse files
committed
Simplify implementation of clean handling.
1 parent 1aec7ab commit 960376c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Apple/__main__.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,24 @@ def all_host_triples(platform: str) -> list[str]:
175175

176176
def clean(context: argparse.Namespace, target: str | None = None) -> None:
177177
"""The implementation of the "clean" command."""
178+
if target is None:
179+
target = context.host
180+
178181
# If we're explicitly targeting the build, there's no platform or
179182
# distribution artefacts. If we're cleaning tests, we keep all built
180183
# artefacts. Otherwise, the built artefacts must be dirty, so we remove
181184
# them.
182-
if target is None:
183-
target = context.host
184-
185-
paths = []
185+
if target not in {"build", "test"}:
186+
paths = ["dist", context.platform] + list(HOSTS[context.platform])
187+
else:
188+
paths = []
186189

187190
if target in {"all", "build"}:
188191
paths.append("build")
189192

190-
if target in {"all", "hosts", "package"}:
191-
paths.append("dist")
192-
paths.extend(list(HOSTS[context.platform]))
193-
paths.append(context.platform)
194-
if target != "package":
195-
paths.extend(all_host_triples(context.platform))
196-
elif target not in {"build", "test"}:
193+
if target in {"all", "hosts"}:
194+
paths.extend(all_host_triples(context.platform))
195+
elif target not in {"build", "test", "package"}:
197196
paths.append(target)
198197

199198
if target in {"all", "hosts", "test"}:

0 commit comments

Comments
 (0)