Skip to content

Commit b297531

Browse files
authored
Migrate 'make git-submodule' to CLI command (#19479)
1 parent 3a5a4c7 commit b297531

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

Makefile

+1-6
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,7 @@ lib/%:
430430

431431
.PHONY: git-submodule
432432
git-submodule:
433-
[ -e lib/ugfx ] && rm -rf lib/ugfx || true
434-
[ -e lib/pico-sdk ] && rm -rf lib/pico-sdk || true
435-
[ -e lib/chibios-contrib/ext/mcux-sdk ] && rm -rf lib/chibios-contrib/ext/mcux-sdk || true
436-
[ -e lib/lvgl ] && rm -rf lib/lvgl || true
437-
git submodule sync --recursive
438-
git submodule update --init --recursive --progress
433+
$(QMK_BIN) git-submodule
439434

440435
.PHONY: git-submodules
441436
git-submodules: git-submodule

builddefs/message.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ MSG_CLEANING = Cleaning project:
6565
MSG_CREATING_LIBRARY = Creating library:
6666
MSG_GENERATING = Generating:
6767
MSG_SUBMODULE_DIRTY = $(WARN_COLOR)WARNING:$(NO_COLOR) Some git submodules are out of date or modified.\n\
68-
Please consider running $(BOLD)make git-submodule$(NO_COLOR).\n\n
68+
Please consider running $(BOLD)qmk git-submodule$(NO_COLOR).\n\n
6969
MSG_NO_CMP = $(ERROR_COLOR)Error:$(NO_COLOR)$(BOLD) cmp command not found, please install diffutils\n$(NO_COLOR)
7070

7171
define GENERATE_MSG_MAKE_KB

lib/python/qmk/cli/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
'qmk.cli.generate.rgb_breathe_table',
6262
'qmk.cli.generate.rules_mk',
6363
'qmk.cli.generate.version_h',
64+
'qmk.cli.git.submodule',
6465
'qmk.cli.hello',
6566
'qmk.cli.import.kbfirmware',
6667
'qmk.cli.import.keyboard',

lib/python/qmk/cli/git/__init__.py

Whitespace-only changes.

lib/python/qmk/cli/git/submodule.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import shutil
2+
from qmk.path import normpath
3+
4+
from milc import cli
5+
6+
REMOVE_DIRS = [
7+
'lib/ugfx',
8+
'lib/pico-sdk',
9+
'lib/chibios-contrib/ext/mcux-sdk',
10+
'lib/lvgl',
11+
]
12+
13+
14+
@cli.subcommand('Git Submodule actions.')
15+
def git_submodule(cli):
16+
for folder in REMOVE_DIRS:
17+
if normpath(folder).is_dir():
18+
print(f"Removing '{folder}'")
19+
shutil.rmtree(folder)
20+
21+
cli.run(['git', 'submodule', 'sync', '--recursive'], capture_output=False)
22+
cli.run(['git', 'submodule', 'update', '--init', '--recursive', '--progress'], capture_output=False)

0 commit comments

Comments
 (0)