The implementation of the "clean" command.
(context: argparse.Namespace, target: str | None = None)
| 174 | |
| 175 | |
| 176 | def clean(context: argparse.Namespace, target: str | None = None) -> None: |
| 177 | """The implementation of the "clean" command.""" |
| 178 | if target is None: |
| 179 | target = context.host |
| 180 | |
| 181 | # If we're explicitly targeting the build, there's no platform or |
| 182 | # distribution artefacts. If we're cleaning tests, we keep all built |
| 183 | # artefacts. Otherwise, the built artefacts must be dirty, so we remove |
| 184 | # them. |
| 185 | if target not in {"build", "test"}: |
| 186 | paths = ["dist", context.platform] + list(HOSTS[context.platform]) |
| 187 | else: |
| 188 | paths = [] |
| 189 | |
| 190 | if target in {"all", "build"}: |
| 191 | paths.append("build") |
| 192 | |
| 193 | if target in {"all", "hosts"}: |
| 194 | paths.extend(all_host_triples(context.platform)) |
| 195 | elif target not in {"build", "test", "package"}: |
| 196 | paths.append(target) |
| 197 | |
| 198 | if target in {"all", "hosts", "test"}: |
| 199 | paths.extend([ |
| 200 | path.name |
| 201 | for path in CROSS_BUILD_DIR.glob(f"{context.platform}-testbed.*") |
| 202 | ]) |
| 203 | |
| 204 | for path in paths: |
| 205 | delete_path(path) |
| 206 | |
| 207 | |
| 208 | def build_python_path() -> Path: |
no test coverage detected
searching dependent graphs…