]> granicus.if.org Git - esp-idf/commitdiff
build system: Call 'git status' w/ machine-readable output once to check submodules
authorAngus Gratton <angus@espressif.com>
Tue, 14 Mar 2017 10:55:12 +0000 (18:55 +0800)
committerAngus Gratton <angus@espressif.com>
Tue, 21 Mar 2017 08:00:03 +0000 (16:00 +0800)
This is substantially faster than the 'git submodule status' command, has same effect. Particularly noticeable on
Windows, where 'submodule status' takes 2 seconds and 'status' takes 0.2 seconds.

make/project.mk

index e1a23e96e9648e27c927e36e2e5675379bd5ac81..6f43f46984e2abb40c9155dd03a28a0dea75a95d 100644 (file)
@@ -404,6 +404,9 @@ clean: config-clean
 # This only works for components inside IDF_PATH
 check-submodules:
 
+# Dump the git status for the whole working copy once, then grep it for each submodule. This saves a lot of time on Windows.
+GIT_STATUS := $(shell cd ${IDF_PATH} && git status --porcelain=v1 --ignore-submodules=dirty)
+
 # Generate a target to check this submodule
 # $(1) - submodule directory, relative to IDF_PATH
 define GenerateSubmoduleCheckTarget
@@ -415,9 +418,8 @@ $(IDF_PATH)/$(1)/.git:
        @echo "Attempting 'git submodule update --init $(1)' in esp-idf root directory..."
        cd ${IDF_PATH} && git submodule update --init $(1)
 
-# Parse 'git submodule status' output for out-of-date submodule.
-# Status output prefixes status line with '+' if the submodule commit doesn't match
-ifneq ("$(shell cd ${IDF_PATH} && git submodule status $(1) | grep '^+')","")
+# Parse 'git status' output to check if the submodule commit is different to expected
+ifneq ("$(filter $(1),$(GIT_STATUS))","")
 $$(info WARNING: esp-idf git submodule $(1) may be out of date. Run 'git submodule update' in IDF_PATH dir to update.)
 endif
 endef