mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
build: minify the web files only when they change
html_min was phony, so every make deleted output/html_min and minified all of html/ again, even with nothing changed. A stamp file now stands for the minified copy and depends on the sources and on minify.py. A list of the source names, rewritten only when it changes, is a dependency too, so adding or removing a file in html/ still redoes the copy and a removed file does not stay behind in the image. If output/html_min is missing, the stamp is remade in the same run. The note on version.h in webui-compression.md still said it was phony.
This commit is contained in:
1 parent
53eb3f5486
commit
337b171ac4
2 files changed
+19
-6
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user