diff --git a/Makefile b/Makefile index 5754ee08..f0950a8a 100644 --- a/Makefile +++ b/Makefile @@ -145,13 +145,23 @@ HTML := $(shell find html -name '*.js' -or -name '*.html' -or -name '*.svg' -or # The raw html/ sources stay untouched for development; the minified # copy is a build artifact under output/. HTML_MIN := $(BUILDDIR)/html_min +HTML_MIN_LIST := $(BUILDDIR)/html_min.list +HTML_MIN_STAMP := $(BUILDDIR)/html_min.stamp .PHONY: html_min -html_min: $(HTML) +html_min: $(HTML_MIN_STAMP) + +$(HTML_MIN_LIST): FORCE + @mkdir -p $(BUILDDIR) + @echo $(sort $(HTML)) > $@.tmp + @cmp -s $@.tmp $@ && rm -f $@.tmp || mv $@.tmp $@ + +$(HTML_MIN_STAMP): $(HTML) $(HTML_MIN_LIST) tools/minify.py $(if $(wildcard $(HTML_MIN)),,FORCE) rm -rf $(HTML_MIN) mkdir -p $(HTML_MIN) @for f in $(HTML); do python3 tools/minify.py $$f $(HTML_MIN)/$$(basename $$f) || exit 1; done + @touch $@ -html_data.c html_data.h &: $(HTML) | tools html_min +html_data.c html_data.h &: $(HTML_MIN_STAMP) | tools tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -z -d $(HTML_MIN) -p html_data $(VERSION_HEADER): FORCE @@ -169,11 +179,11 @@ $(SUBDIRS): $(MAKE) -C $@ BUILDDIR=$(BUILDDIR) clean: $(SUBDIRSCLEAN) - -rm -f html_data.c html_data.h $(VERSION_HEADER) + -rm -f html_data.c html_data.h $(VERSION_HEADER) $(HTML_MIN_LIST) $(HTML_MIN_STAMP) -if [ -d $(BUILDDIR) ]; then find $(BUILDDIR) -type f ! -name "*.bin" -delete; fi distclean: $(SUBDIRSCLEAN) - -rm -f html_data.c html_data.h $(VERSION_HEADER) + -rm -f html_data.c html_data.h $(VERSION_HEADER) $(HTML_MIN_LIST) $(HTML_MIN_STAMP) -rm -rf $(BUILDDIR) $(SUBDIRSCLEAN): diff --git a/doc/webui-compression.md b/doc/webui-compression.md index 1765609f..9e5185da 100644 --- a/doc/webui-compression.md +++ b/doc/webui-compression.md @@ -79,8 +79,11 @@ JSON polling of the visible section). computation no longer depends on uninitialised buffer content. - `version.h` is now written by a single atomic `printf` (change from upstream) instead of five separate `echo`s, so a parallel build - (`make -j`) can no longer read a half-written copy. It stays in - `.PHONY` so it is regenerated on every build. + (`make -j`) can no longer read a half-written copy. It depends on + `FORCE`, so its recipe runs on every build, but the file is only + rewritten when its content changes. The minified copy in + `output/html_min/` is redone only when a web file, the list of web + files or `tools/minify.py` changes. ## Verification