Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 19 additions & 30 deletions ffbuild/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -115,68 +115,59 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS)
$(BIN2CEXE): ffbuild/bin2c_host.o
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)

RUN_BIN2C = $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
RUN_GZIP = $(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
RUN_MINIFY = $(M)sed 's!/\\*.*\\*/!!g' $< | tr '\n' ' ' | tr -s ' ' | sed 's/^ //; s/ $$//' > $@
%.gz: TAG = GZIP
%.min: TAG = MINIFY

%.metal.air: %.metal
$(METALCC) $< -o $@

%.metallib: %.metal.air
$(METALLIB) --split-module-without-linking $< -o $@

%.metallib.c: %.metallib $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)

%.ptx: %.cu $(SRC_PATH)/compat/cuda/cuda_runtime.h
$(COMPILE_NVCC)

ifdef CONFIG_PTX_COMPRESSION
%.ptx.gz: TAG = GZIP
%.ptx.gz: %.ptx
$(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
$(RUN_GZIP)

%.ptx.c: %.ptx.gz $(BIN2CEXE)
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
else
%.ptx.c: %.ptx $(BIN2CEXE)
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
endif

# 1) Preprocess CSS to a minified version
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove those comments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone had asked on IRC whether I would submit AI generated code as those comments would look like I did.
(the only AI generated line of code I've ever submitted is the sed command in that file)

While I believe that comments are often useful, there aren't any other comments in common.mak, and there had been some disliking comments about those lines earlier, so I wanted to adapt to these attitudes.

One could also say that due to the command variables like $(RUN_GZIP), $(RUN_MINIFY)and $(RUN_BIN2C) it is now more clear what happens on each line.

PS: Thanks a lot for looking at this patchset :-)

%.css.min: TAG = SED
%.css.min: %.css
$(M)sed 's!/\\*.*\\*/!!g' $< \
| tr '\n' ' ' \
| tr -s ' ' \
| sed 's/^ //; s/ $$//' \
> $@
$(RUN_MINIFY)

ifdef CONFIG_RESOURCE_COMPRESSION

# 2) Gzip the minified CSS
%.css.min.gz: TAG = GZIP
%.css.min.gz: %.css.min
$(M)gzip -nc9 $< > $@
$(RUN_GZIP)

# 3) Convert the gzipped CSS to a .c array
%.css.c: %.css.min.gz $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)

# 4) Gzip the HTML file (no minification needed)
%.html.gz: TAG = GZIP
%.html.gz: %.html
$(M)gzip -nc9 $< > $@
$(RUN_GZIP)

# 5) Convert the gzipped HTML to a .c array
%.html.c: %.html.gz $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)

else # NO COMPRESSION

# 2) Convert the minified CSS to a .c array
%.css.c: %.css.min $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)

# 3) Convert the plain HTML to a .c array
%.html.c: %.html $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
endif

clean::
Expand Down Expand Up @@ -229,11 +220,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)

$(HOSTOBJS): %.o: %.c
Expand All @@ -252,7 +241,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 *.html.gz *.html.c *.css.min.gz *.css.min *.css.c *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a

define RULES
Expand Down
1 change: 1 addition & 0 deletions fftools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ OBJS-ffmpeg += \
fftools/textformat/tw_buffer.o \
fftools/textformat/tw_stdout.o \
$(OBJS-resman) \
$(RESOBJS) \

OBJS-ffprobe += \
fftools/textformat/avtextformat.o \
Expand Down
5 changes: 2 additions & 3 deletions fftools/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.html.c
*.css.c
*.html.gz
*.css.gz
*.min
*.min.gz
*.css.min
*.css.min.gz
12 changes: 9 additions & 3 deletions fftools/resources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ clean::
vpath %.html $(SRC_PATH)
vpath %.css $(SRC_PATH)

# Uncomment to prevent deletion during build
#.PRECIOUS: %.css.c %.css.min %.css.gz %.css.min.gz %.html.gz %.html.c

OBJS-resman += \
fftools/resources/resman.o \


RESOBJS += \
fftools/resources/graph.html.o \
fftools/resources/graph.css.o \


$(RESOBJS): CCDEP =
$(RESOBJS): CC_DEPFLAGS =

.SECONDARY: $(RESOBJS:.o=.gz) $(RESOBJS:.o=.c) $(RESOBJS:%.css.o=%.css.min) $(RESOBJS:%.css.o=%.css.min.gz) $(RESOBJS:%.html.o=%.html.gz) $(RESOBJS:.o=)