Skip to content

Commit 2f757a6

Browse files
committed
fix: Update West project blocklists
Added the "nanopb" project and "hal" group to the blocklists so those projects don't get cloned. This prevents unnecessarily cloning modules/lib/nanopb on ZMK v0.3 (which is fairly small) and modules/hal/stm32 on ZMK main (which is 800+ MB).
1 parent d1bf5b6 commit 2f757a6

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

zmk/repo.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
# Don't clone projects from ZMK's manifest that aren't needed for discovering keyboards
2727
_PROJECT_BLOCKLIST = [
2828
"lvgl",
29+
"nanopb",
2930
"zephyr",
3031
"zmk-studio-messages",
3132
]
33+
_GROUP_BLOCKLIST = [
34+
"hal",
35+
]
3236

3337

3438
def is_repo(path: Path) -> bool:
@@ -226,7 +230,7 @@ def ensure_west_ready(self) -> None:
226230

227231
config_path = self.path / _WEST_STAGING_PATH / _WEST_CONFIG_PATH
228232
if config_path.exists():
229-
self._update_project_filter()
233+
self._update_filters()
230234
else:
231235
self._init_west_app()
232236

@@ -284,6 +288,19 @@ def set_zmk_version(self, revision: str) -> None:
284288
except KeyError:
285289
pass
286290

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+
287304
@overload
288305
def _run_west(self, *args: str, capture_output: Literal[False] = False) -> None: ...
289306

@@ -343,23 +360,22 @@ def _init_west_app(self):
343360
print("Initializing west application. This may take a while...")
344361
self._run_west("init", "-l", _CONFIG_DIR_NAME)
345362

346-
self._update_project_filter()
363+
self._update_filters()
347364
self._run_west("update")
348365

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")
356369

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)
359372

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)
361375

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

Comments
 (0)