]> granicus.if.org Git - esp-idf/commitdiff
build system: Don't error out if an already-build project or IDF directory has moved
authorAngus Gratton <angus@espressif.com>
Fri, 14 Jul 2017 08:23:56 +0000 (16:23 +0800)
committerAngus Gratton <gus@projectgus.com>
Tue, 18 Jul 2017 23:10:48 +0000 (09:10 +1000)
make/component_wrapper.mk

index b4e81fe0cc8563f5c4547be98c80fbbf71700dce..be5333e48e9b99f6f4bfce93873e8fef5d550bbf 100644 (file)
@@ -181,6 +181,18 @@ endif
 # Include all dependency files already generated
 -include $(COMPONENT_OBJS:.o=.d)
 
+# This is a fix for situation where the project or IDF dir moves, and instead
+# of rebuilding the target the build fails until make clean is run
+#
+# It adds an empty dependency rule for the (possibly non-existent) source file itself,
+# which prevents it not being found from failing the build
+#
+# $1 == Source File, $2 == .o file used for .d file name
+define AppendSourceToDependencies
+echo "$1:" >> $$(patsubst %.o,%.d,$2)
+endef
+
+
 # This pattern is generated for each COMPONENT_SRCDIR to compile the files in it.
 define GenerateCompileTargets
 # $(1) - directory containing source files, relative to $(COMPONENT_PATH) - one of $(COMPONENT_SRCDIRS)
@@ -188,14 +200,17 @@ define GenerateCompileTargets
 $(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.c $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_SRCDIRS)
        $$(summary) CC $$@
        $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
+       $(call AppendSourceToDependencies,$$<,$$@)
 
 $(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_SRCDIRS)
        $$(summary) CXX $$@
        $$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) $$(addprefix -I,$$(COMPONENT_INCLUDES)) $$(addprefix -I,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
+       $(call AppendSourceToDependencies,$$<,$$@)
 
 $(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.S $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_SRCDIRS)
        $$(summary) AS $$@
        $$(CC) $$(CPPFLAGS) $$(DEBUG_FLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
+       $(call AppendSourceToDependencies,$$<,$$@)
 
 # CWD is build dir, create the build subdirectory if it doesn't exist
 #