From 39e728622f2c4d6ef7b29a3c408f1ca9ded2dc10 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 14 Mar 2017 18:55:12 +0800 Subject: [PATCH] build system: Call 'git status' w/ machine-readable output once to check submodules 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/make/project.mk b/make/project.mk index e1a23e96e9..6f43f46984 100644 --- a/make/project.mk +++ b/make/project.mk @@ -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