Skip to content

Commit 2977c64

Browse files
committed
Make the clean target more selective.
1 parent 2be147e commit 2977c64

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

Apple/__main__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,27 @@ def all_host_triples(platform: str) -> list[str]:
173173
return triples
174174

175175

176-
def clean(context: argparse.Namespace, target: str = "all") -> None:
176+
def clean(context: argparse.Namespace, target: str | None = None) -> None:
177177
"""The implementation of the "clean" command."""
178178
# If we're explicitly targeting the build, there's no platform or
179179
# distribution artefacts. If we're cleaning tests, we keep all built
180180
# artefacts. Otherwise, the built artefacts must be dirty, so we remove
181181
# them.
182-
if target not in {"build", "test"}:
183-
paths = ["dist", context.platform] + list(HOSTS[context.platform])
184-
else:
185-
paths = []
182+
if target is None:
183+
target = context.host
184+
185+
paths = []
186186

187187
if target in {"all", "build"}:
188188
paths.append("build")
189189

190-
if target in {"all", "hosts"}:
191-
paths.extend(all_host_triples(context.platform))
192-
elif target not in {"build", "test", "package"}:
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"}:
193197
paths.append(target)
194198

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

0 commit comments

Comments
 (0)