]> granicus.if.org Git - esp-idf/commitdiff
build system: Print a WARNING if any submodule is out of date
authorAngus Gratton <angus@espressif.com>
Tue, 4 Oct 2016 05:33:18 +0000 (16:33 +1100)
committerAngus Gratton <angus@espressif.com>
Mon, 10 Oct 2016 20:56:08 +0000 (07:56 +1100)
Inspired by Github #27 and related "gotchas" with keeping submodules up to date.

components/bt/component.mk
components/esp32/component.mk
components/esptool_py/Makefile.projbuild
make/common.mk

index a9233cc74aa62d191db5979eacdc09252ac48986..e88651aa137361c072028e4ea4076be084de9b7d 100644 (file)
@@ -4,8 +4,6 @@
 
 #COMPONENT_ADD_INCLUDEDIRS := 
 
-CURRENT_DIR=$(IDF_PATH)/components/bt
-
 COMPONENT_ADD_INCLUDEDIRS := include
 
 CFLAGS += -Wno-error=unused-label -Wno-error=return-type -Wno-error=missing-braces -Wno-error=pointer-sign -Wno-error=parentheses
@@ -22,4 +20,4 @@ ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
 $(COMPONENT_LIBRARY): $(ALL_LIB_FILES)
 
 # automatically trigger a git submodule update if BT library is missing
-$(eval $(call SubmoduleRequiredForFiles,$(ALL_LIB_FILES)))
+$(eval $(call SubmoduleCheck,$(ALL_LIB_FILES),$(COMPONENT_PATH)/lib))
index 6eac77afd307582cba66cf532821ec2ab4bb1403..b41acee60daa9f01ad71269021ca13eb23777eaf 100644 (file)
@@ -27,7 +27,7 @@ ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
 
 # automatically trigger a git submodule update
 # if any libraries are missing
-$(eval $(call SubmoduleRequiredForFiles,$(ALL_LIB_FILES)))
+$(eval $(call SubmoduleCheck,$(ALL_LIB_FILES),$(COMPONENT_PATH)/lib))
 
 # this is a hack to make sure the app is re-linked if the binary
 # libraries change or are updated. If they change, the main esp32
index a3d49b7df93d286ce75cb8630adaed8b96e66d59..4d0dd1b3e5ecf28eacf2d4157a03925b5290fe26 100644 (file)
@@ -31,4 +31,4 @@ app-flash: $(APP_BIN) $(ESPTOOLPY_SRC)
        @echo "Flashing app to serial port $(ESPPORT), offset $(CONFIG_APP_OFFSET)..."
        $(Q) $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
 
-$(eval $(call SubmoduleRequiredForFiles,$(ESPTOOLPY_SRC)))
+$(eval $(call SubmoduleCheck,$(ESPTOOLPY_SRC),$(COMPONENT_PATH)/esptool))
index a515584a9b72c7f93b96055d420376a7841b471e..14aa4074b35d8137944dc99f4c4ae419ec713dec 100644 (file)
@@ -23,19 +23,27 @@ summary := @echo
 details := @true
 endif
 
-# Pseudo-target to handle the case where submodules need to be
-# re-initialised.
+# Pseudo-target to check a git submodule has been properly initialised
 #
-# $(eval $(call SubmoduleRequiredForFiles,FILENAMES)) to create a target that
-# automatically runs 'git submodule update --init' if those files
-# are missing, and fails if this is not possible.
-define SubmoduleRequiredForFiles
+# $(eval $(call SubmoduleCheck,FILENAMES,SUBMODULE_PATH)) to create a target that
+# automatically runs 'git submodule update --init SUBMODULE_PATH' if any of
+# the files in FILENAMES are missing, and fails if this is not possible.
+#
+# Will also print a WARNING if the submodule at SUBMODULE_PATH appears
+# to require an update.
+define SubmoduleCheck
 $(1):
-       @echo "WARNING: Missing submodule for $$@..."
+       @echo "WARNING: Missing submodule $(2) for $$@..."
        $(Q) [ -d ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
        $(Q) [ -x $(which git) ] || ( echo "ERROR: Need to run 'git submodule --init' in esp-idf root directory."; exit 1)
        @echo "Attempting 'git submodule update --init' in esp-idf root directory..."
-       cd ${IDF_PATH} && git submodule update --init
+       cd ${IDF_PATH} && git submodule update --init $(2)
+
+# 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 $(2) | grep '^+')","")
+$$(info WARNING: git submodule $2 may be out of date. Run 'git submodule update' to update.)
+endif
 endef