|
26 | 26 | # Don't clone projects from ZMK's manifest that aren't needed for discovering keyboards |
27 | 27 | _PROJECT_BLOCKLIST = [ |
28 | 28 | "lvgl", |
| 29 | + "nanopb", |
29 | 30 | "zephyr", |
30 | 31 | "zmk-studio-messages", |
31 | 32 | ] |
| 33 | +_GROUP_BLOCKLIST = [ |
| 34 | + "hal", |
| 35 | +] |
32 | 36 |
|
33 | 37 |
|
34 | 38 | def is_repo(path: Path) -> bool: |
@@ -226,7 +230,7 @@ def ensure_west_ready(self) -> None: |
226 | 230 |
|
227 | 231 | config_path = self.path / _WEST_STAGING_PATH / _WEST_CONFIG_PATH |
228 | 232 | if config_path.exists(): |
229 | | - self._update_project_filter() |
| 233 | + self._update_filters() |
230 | 234 | else: |
231 | 235 | self._init_west_app() |
232 | 236 |
|
@@ -284,6 +288,19 @@ def set_zmk_version(self, revision: str) -> None: |
284 | 288 | except KeyError: |
285 | 289 | pass |
286 | 290 |
|
| 291 | + def get_west_config(self, name: str) -> str: |
| 292 | + """Get the value of a West configuration setting""" |
| 293 | + try: |
| 294 | + return self._run_west( |
| 295 | + "config", "--local", name, capture_output=True |
| 296 | + ).removesuffix("\n") |
| 297 | + except subprocess.CalledProcessError: |
| 298 | + return "" |
| 299 | + |
| 300 | + def set_west_config(self, name: str, value: str) -> None: |
| 301 | + """Set the value of a West configuration setting""" |
| 302 | + self._run_west("config", "--local", name, "--", value) |
| 303 | + |
287 | 304 | @overload |
288 | 305 | def _run_west(self, *args: str, capture_output: Literal[False] = False) -> None: ... |
289 | 306 |
|
@@ -343,23 +360,22 @@ def _init_west_app(self): |
343 | 360 | print("Initializing west application. This may take a while...") |
344 | 361 | self._run_west("init", "-l", _CONFIG_DIR_NAME) |
345 | 362 |
|
346 | | - self._update_project_filter() |
| 363 | + self._update_filters() |
347 | 364 | self._run_west("update") |
348 | 365 |
|
349 | | - def _get_project_filter(self): |
350 | | - try: |
351 | | - return self._run_west( |
352 | | - "config", "--local", "manifest.project-filter", capture_output=True |
353 | | - ).strip() |
354 | | - except subprocess.CalledProcessError: |
355 | | - return "" |
| 366 | + def _update_filters(self): |
| 367 | + current_group_filter = self.get_west_config("manifest.group-filter") |
| 368 | + current_project_filter = self.get_west_config("manifest.project-filter") |
356 | 369 |
|
357 | | - def _update_project_filter(self): |
358 | | - current_filter = self._get_project_filter() |
| 370 | + new_group_filter = _blocklist_to_filter(_GROUP_BLOCKLIST) |
| 371 | + new_project_filter = _blocklist_to_filter(_PROJECT_BLOCKLIST) |
359 | 372 |
|
360 | | - new_filter = ",".join("-" + project for project in _PROJECT_BLOCKLIST) |
| 373 | + if current_group_filter != new_group_filter: |
| 374 | + self.set_west_config("manifest.group-filter", new_group_filter) |
361 | 375 |
|
362 | | - if current_filter != new_filter: |
363 | | - self._run_west( |
364 | | - "config", "--local", "manifest.project-filter", "--", new_filter |
365 | | - ) |
| 376 | + if current_project_filter != new_project_filter: |
| 377 | + self.set_west_config("manifest.project-filter", new_project_filter) |
| 378 | + |
| 379 | + |
| 380 | +def _blocklist_to_filter(blocklist: list[str]) -> str: |
| 381 | + return ",".join("-" + item for item in blocklist) |
0 commit comments