From: softworkz <softwo...@hotmail.com>

When there's a chain of implicit rules, make treats files generated
inside that chain as intermediate files. Those intermediate files are
removed after completion of make. When make is run again, it normally
determines the need for a rebuild by comparing the timestamps of the
original source file and the final output of the chain and if still
up-to-date, it doesn't rebuild, even when the intermediate files are
not present. That makes sense of course - why would it delete them
otherwise, it would end up in builds being never up-to-date.
But this original by-the-book logic appeared to be broken and has been
worked around by adding all intermediate files to the .SECONDARY
special target, which required extra logic and issues with make clean.

What broke the up-to-date checking is the dependency file generation.
For the .c files generated by BIN2C the compile target created a .d
file which indicated that the .ptx.o file has a dependency on the
ptx.c file. And that dependency broke the normal make behavior with
intermediate files.

This patch compiles the BIN2C generated .c files without generating
.d files. In turn the files do not longer need to be added to the
.SECONDARY target in common.mak.

When interested in those files for debugging, a line can be added to
the corresponding Makefile like

.SECONDARY: %.ptx.c %.ptx.gz

Signed-off-by: softworkz <softwo...@hotmail.com>
---
    ffbuild/commonmak: Fix rebuild check with implicit rule chains
    
    
    V2
    ==
    
     * Fix MSVC build
       (use the universal command pattern)
    
    
    V3
    ==
    
     * Skip dependency generation by clearing CC_DEPS instead
       (as suggested by Ramiro - thanks!)
    
    
    V4
    ==
    
     * Always keep .ptx files (as suggested by Timo - thanks) Tested all
       scenarios:
       * .ptx.c and .ptx.gz still get deleted (as intermediates)
       * repeated make shows "up-to-date"
       * removing a .ptx file does not cause a rebuild (it's still an
         intermediate, but an "intermediate to keep")
       * but changing a .ptx does (in case of dev/debugging)
       * changed .cu files always rebuild of course
    
    .

Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-80%2Fsoftworkz%2Fsubmit_commonmak-v4
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-80/softworkz/submit_commonmak-v4
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/80

Range-diff vs v3:

 1:  981329e5d9 ! 1:  20c2fb65ed ffbuild/commonmak: Fix rebuild check with 
implicit rule chains
     @@ ffbuild/common.mak: else   # NO COMPRESSION
       clean::
        $(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
       
     -@@ ffbuild/common.mak: ALLHEADERS := $(subst 
$(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)
     - SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
     +@@ ffbuild/common.mak: SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) 
$(SKIPHEADERS-)
       SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
       HOBJS        = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
     --PTXOBJS      = $(filter %.ptx.o,$(OBJS))
     + PTXOBJS      = $(filter %.ptx.o,$(OBJS))
      -RESOURCEOBJS = $(filter %.css.o %.html.o,$(OBJS))
       $(HOBJS):     CCFLAGS += $(CFLAGS_HEADERS)
       checkheaders: $(HOBJS)
      -.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) 
$(PTXOBJS:.o=) $(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:%.css.o=%.css.min) 
$(RESOURCEOBJS:%.css.o=%.css.min.gz) $(RESOURCEOBJS:%.html.o=%.html.gz) 
$(RESOURCEOBJS:.o=)
     -+.SECONDARY:   $(HOBJS:.o=.c)
     ++.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=)
       
       alltools: $(TOOLS)
       


 ffbuild/common.mak | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index 0e1eb1f62b..f03b9ca051 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -139,6 +139,10 @@ else
        $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst 
.,_,$(basename $(notdir $@)))
 endif
 
+%.ptx.o: CCDEP       =
+%.ptx.o: CC_DEPFLAGS =
+
+
 # 1) Preprocess CSS to a minified version
 %.css.min: %.css
        # Must start with a tab in the real Makefile
@@ -177,6 +181,10 @@ else   # NO COMPRESSION
        $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
 endif
 
+%.html.o %.css.o: CCDEP       =
+%.html.o %.css.o: CC_DEPFLAGS =
+
+
 clean::
        $(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
 
@@ -229,10 +237,9 @@ SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
 HOBJS        = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
 PTXOBJS      = $(filter %.ptx.o,$(OBJS))
-RESOURCEOBJS = $(filter %.css.o %.html.o,$(OBJS))
 $(HOBJS):     CCFLAGS += $(CFLAGS_HEADERS)
 checkheaders: $(HOBJS)
-.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=) 
$(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:%.css.o=%.css.min) 
$(RESOURCEOBJS:%.css.o=%.css.min.gz) $(RESOURCEOBJS:%.html.o=%.html.gz) 
$(RESOURCEOBJS:.o=)
+.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=)
 
 alltools: $(TOOLS)
 

base-commit: 4099d53759ce5d9190a339c02b6bb486e2880f66
-- 
ffmpeg-codebot
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to