summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-01-02 22:11:57 +0000
committerGitHub <noreply@github.com>2023-01-03 09:11:57 +1100
commitb297531dbf645a28fd5a67e546a9ff27d49e1b1e (patch)
treed16cd659a2cde4d5c665f147c30ab4a9c86ae4cd
parent3a5a4c708f4817919d9fe7396ceb2b8e57d2e68e (diff)
Migrate 'make git-submodule' to CLI command (#19479)
-rw-r--r--Makefile7
-rw-r--r--builddefs/message.mk2
-rw-r--r--lib/python/qmk/cli/__init__.py1
-rw-r--r--lib/python/qmk/cli/git/__init__.py0
-rw-r--r--lib/python/qmk/cli/git/submodule.py22
5 files changed, 25 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 1585ae7c23..48cf35248f 100644
--- a/Makefile
+++ b/Makefile
@@ -430,12 +430,7 @@ lib/%:
.PHONY: git-submodule
git-submodule:
- [ -e lib/ugfx ] && rm -rf lib/ugfx || true
- [ -e lib/pico-sdk ] && rm -rf lib/pico-sdk || true
- [ -e lib/chibios-contrib/ext/mcux-sdk ] && rm -rf lib/chibios-contrib/ext/mcux-sdk || true
- [ -e lib/lvgl ] && rm -rf lib/lvgl || true
- git submodule sync --recursive
- git submodule update --init --recursive --progress
+ $(QMK_BIN) git-submodule
.PHONY: git-submodules
git-submodules: git-submodule
diff --git a/builddefs/message.mk b/builddefs/message.mk
index 07d0e07ce8..2bd01669f8 100644
--- a/builddefs/message.mk
+++ b/builddefs/message.mk
@@ -65,7 +65,7 @@ MSG_CLEANING = Cleaning project:
MSG_CREATING_LIBRARY = Creating library:
MSG_GENERATING = Generating:
MSG_SUBMODULE_DIRTY = $(WARN_COLOR)WARNING:$(NO_COLOR) Some git submodules are out of date or modified.\n\
-Please consider running $(BOLD)make git-submodule$(NO_COLOR).\n\n
+Please consider running $(BOLD)qmk git-submodule$(NO_COLOR).\n\n
MSG_NO_CMP = $(ERROR_COLOR)Error:$(NO_COLOR)$(BOLD) cmp command not found, please install diffutils\n$(NO_COLOR)
define GENERATE_MSG_MAKE_KB
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index a6d53c1cb6..e0ab67da7b 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -61,6 +61,7 @@ subcommands = [
'qmk.cli.generate.rgb_breathe_table',
'qmk.cli.generate.rules_mk',
'qmk.cli.generate.version_h',
+ 'qmk.cli.git.submodule',
'qmk.cli.hello',
'qmk.cli.import.kbfirmware',
'qmk.cli.import.keyboard',
diff --git a/lib/python/qmk/cli/git/__init__.py b/lib/python/qmk/cli/git/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/lib/python/qmk/cli/git/__init__.py
diff --git a/lib/python/qmk/cli/git/submodule.py b/lib/python/qmk/cli/git/submodule.py
new file mode 100644
index 0000000000..bcc3868a52
--- /dev/null
+++ b/lib/python/qmk/cli/git/submodule.py
@@ -0,0 +1,22 @@
+import shutil
+from qmk.path import normpath
+
+from milc import cli
+
+REMOVE_DIRS = [
+ 'lib/ugfx',
+ 'lib/pico-sdk',
+ 'lib/chibios-contrib/ext/mcux-sdk',
+ 'lib/lvgl',
+]
+
+
+@cli.subcommand('Git Submodule actions.')
+def git_submodule(cli):
+ for folder in REMOVE_DIRS:
+ if normpath(folder).is_dir():
+ print(f"Removing '{folder}'")
+ shutil.rmtree(folder)
+
+ cli.run(['git', 'submodule', 'sync', '--recursive'], capture_output=False)
+ cli.run(['git', 'submodule', 'update', '--init', '--recursive', '--progress'], capture_output=False)