[FFmpeg-devel] [PATCH 4/5] ffbuild/common.mak: clean up and move fftools/resources-specific code its Makefile

softworkz . softworkz at hotmail.com
Tue May 27 04:48:08 EEST 2025



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Ramiro Polla
> Sent: Dienstag, 27. Mai 2025 03:33
> To: ffmpeg-devel at ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 4/5] ffbuild/common.mak: clean up and move
> fftools/resources-specific code its Makefile
> 
> - Intermediate files are no longer removed;
> - A .res suffix has been added to resource files, so that there's no
>   need to add new rules for each new filetype;
> - Superfluous comments have been removed;
> - Targets depending on CONFIG_RESOURCE_COMPRESSION have been
>   deduplicated.
> ---
>  ffbuild/common.mak                            | 45 +------------------
>  fftools/resources/.gitignore                  |  7 ++-
>  fftools/resources/Makefile                    | 31 ++++++++++---
>  .../resources/{graph.css => graph.css.res}    |  0
>  .../resources/{graph.html => graph.html.res}  |  0
>  fftools/resources/resman.c                    | 12 ++---
>  6 files changed, 36 insertions(+), 59 deletions(-)
>  rename fftools/resources/{graph.css => graph.css.res} (100%)
>  rename fftools/resources/{graph.html => graph.html.res} (100%)
> 
> diff --git a/ffbuild/common.mak b/ffbuild/common.mak
> index ddf48923ea..27dd48a4e6 100644
> --- a/ffbuild/common.mak
> +++ b/ffbuild/common.mak
> @@ -139,46 +139,6 @@ else
>  	$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst
> .,_,$(basename $(notdir $@)))
>  endif
> 
> -# 1) Preprocess CSS to a minified version
> -%.css.min: TAG = SED
> -%.css.min: %.css
> -	$(M)sed 's!/\\*.*\\*/!!g' $< \
> -	| tr '\n' ' ' \
> -	| tr -s ' ' \
> -	| sed 's/^ //; s/ $$//' \
> -	> $@
> -
> -ifdef CONFIG_RESOURCE_COMPRESSION
> -
> -# 2) Gzip the minified CSS
> -%.css.min.gz: TAG = GZIP
> -%.css.min.gz: %.css.min
> -	$(M)gzip -nc9 $< > $@
> -
> -# 3) Convert the gzipped CSS to a .c array
> -%.css.c: %.css.min.gz $(BIN2CEXE)
> -	$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
> -
> -# 4) Gzip the HTML file (no minification needed)
> -%.html.gz: TAG = GZIP
> -%.html.gz: %.html
> -	$(M)gzip -nc9 $< > $@
> -
> -# 5) Convert the gzipped HTML to a .c array
> -%.html.c: %.html.gz $(BIN2CEXE)
> -	$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
> -
> -else   # NO COMPRESSION
> -
> -# 2) Convert the minified CSS to a .c array
> -%.css.c: %.css.min $(BIN2CEXE)
> -	$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
> -
> -# 3) Convert the plain HTML to a .c array
> -%.html.c: %.html $(BIN2CEXE)
> -	$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
> -endif
> -
>  clean::
>  	$(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
> 
> @@ -229,10 +189,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=.c) $(PTXOBJS:.o=.gz)
> $(PTXOBJS:.o=)
> 
>  alltools: $(TOOLS)
> 
> @@ -252,7 +211,7 @@ $(TOOLOBJS): | tools
> 
>  OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SHLIBOBJS)
> $(STLIBOBJS) $(TESTOBJS))
> 
> -CLEANSUFFIXES     = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx
> *.ptx.gz *.ptx.c *.ver *.version *.html.gz *.html.c *.css.gz *.css.c
> *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
> +CLEANSUFFIXES     = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx
> *.ptx.gz *.ptx.c *.ver *.version *.min.res *.res.gz *.res.c
> *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
>  LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
> 
>  define RULES
> diff --git a/fftools/resources/.gitignore b/fftools/resources/.gitignore
> index 5f496535a6..4c56856284 100644
> --- a/fftools/resources/.gitignore
> +++ b/fftools/resources/.gitignore
> @@ -1,4 +1,3 @@
> -*.html.c
> -*.css.c
> -*.html.gz
> -*.css.gz
> +*.res.c
> +*.res.gz
> +*.res
> diff --git a/fftools/resources/Makefile b/fftools/resources/Makefile
> index 8579a52678..a8eb111441 100644
> --- a/fftools/resources/Makefile
> +++ b/fftools/resources/Makefile
> @@ -1,13 +1,32 @@
>  clean::
>  	$(RM) $(CLEANSUFFIXES:%=fftools/resources/%)
> 
> -vpath %.html $(SRC_PATH)
> -vpath %.css  $(SRC_PATH)
> +vpath %.res $(SRC_PATH)
> 
> -# Uncomment to prevent deletion during build
> -#.PRECIOUS: %.css.c %.css.min %.css.gz %.css.min.gz %.html.gz %.html.c
> +RESOURCEOBJS += fftools/resources/graph.css.min.res.o
> +RESOURCEOBJS += fftools/resources/graph.html.res.o
> 
>  OBJS-resman +=                     \
>      fftools/resources/resman.o     \
> -    fftools/resources/graph.html.o \
> -    fftools/resources/graph.css.o  \
> +    $(RESOURCEOBJS)
> +
> +%.css.min.res: TAG = SED
> +%.css.min.res: %.css.res
> +	$(M)sed 's!/\\*.*\\*/!!g' $< \
> +	| tr '\n' ' ' \
> +	| tr -s ' ' \
> +	| sed 's/^ //; s/ $$//' \
> +	> $@
> +
> +ifdef CONFIG_RESOURCE_COMPRESSION
> +RES_GZ = .gz
> +endif
> +
> +%.res.gz: TAG = GZIP
> +%.res.gz: %.res
> +	$(M)gzip -nc9 $< > $@
> +
> +%.res.c: %.res$(RES_GZ) $(BIN2CEXE)
> +	$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
> +
> +.SECONDARY: $(RESOURCEOBJS:.o=) $(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:.o=.gz)
> diff --git a/fftools/resources/graph.css b/fftools/resources/graph.css.res
> similarity index 100%
> rename from fftools/resources/graph.css
> rename to fftools/resources/graph.css.res
> diff --git a/fftools/resources/graph.html b/fftools/resources/graph.html.res
> similarity index 100%
> rename from fftools/resources/graph.html
> rename to fftools/resources/graph.html.res
> diff --git a/fftools/resources/resman.c b/fftools/resources/resman.c
> index a9e21626fa..00518efd87 100644
> --- a/fftools/resources/resman.c
> +++ b/fftools/resources/resman.c
> @@ -38,15 +38,15 @@
>  #include "libavutil/dict.h"
>  #include "libavutil/common.h"
> 
> -extern const unsigned char ff_graph_html_data[];
> -extern const unsigned int ff_graph_html_len;
> +extern const unsigned char ff_graph_html_res_data[];
> +extern const unsigned int ff_graph_html_res_len;
> 
> -extern const unsigned char ff_graph_css_data[];
> -extern const unsigned ff_graph_css_len;
> +extern const unsigned char ff_graph_css_min_res_data[];
> +extern const unsigned ff_graph_css_min_res_len;
> 
>  static const FFResourceDefinition resource_definitions[] = {
> -    [FF_RESOURCE_GRAPH_CSS]   = { FF_RESOURCE_GRAPH_CSS,   "graph.css",
> &ff_graph_css_data[0],   &ff_graph_css_len   },
> -    [FF_RESOURCE_GRAPH_HTML]  = { FF_RESOURCE_GRAPH_HTML,  "graph.html",
> &ff_graph_html_data[0],  &ff_graph_html_len  },
> +    [FF_RESOURCE_GRAPH_CSS]   = { FF_RESOURCE_GRAPH_CSS,   "graph.css",
> &ff_graph_css_min_res_data[0],  &ff_graph_css_min_res_len },
> +    [FF_RESOURCE_GRAPH_HTML]  = { FF_RESOURCE_GRAPH_HTML,  "graph.html",
> &ff_graph_html_res_data[0],     &ff_graph_html_res_len    },
>  };
> 
> 
> --

I actually wanted to push this tomorrow:

https://patchwork.ffmpeg.org/project/ffmpeg/patch/pull.80.v4.ffstaging.FFmpeg.1748037922309.ffmpegagent@gmail.com/

As discussed with Timo, the V4 keeps .ptx files unconditionally while 
all other intermediates are handled as intermediates per Gnu make 
default behavior (i.e. get deleted)

Thanks
sw



More information about the ffmpeg-devel mailing list