mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
build: make the static-file build repeatable
Two things kept the same source from producing the same image. fileadder walked the input directory with readdir(), which returns entries in whatever order the filesystem hands them over. The same tree therefore embedded the files in a different order on a different filesystem, and the image differed byte for byte. scandir() with alphasort() fixes the order. version.h was listed in .PHONY, which makes it permanently out of date and propagates that to everything including it, so a plain build recompiled the four largest translation units even when nothing had changed. Dropping it from .PHONY alone would go too far the other way: with no prerequisites the recipe would never run again and the version string would freeze at its first value. A FORCE prerequisite keeps the recipe running every time, and the generated header is only moved into place when its content actually differs, so the timestamp survives an unchanged rebuild. Measured on this tree: with FORCE the version follows GIT_VERSION and an unchanged rebuild leaves version.h untouched; without it the header keeps the value from the first build.
This commit is contained in:
1 parent
de705380c9
commit
5ffeb3d16a
2 files changed
+14
-7
No files matched your search
@@ -112,11 +112,14 @@ html_min: $(HTML)
|
||||
html_data.c html_data.h &: $(HTML) | tools html_min
|
||||
tools/output/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -z -d $(HTML_MIN) -p html_data
|
||||
|
||||
$(VERSION_HEADER):
|
||||
$(VERSION_HEADER): FORCE
|
||||
@printf '%s\n' "#ifndef VERSION_H" "#define VERSION_H" \
|
||||
"#define VERSION_SW \"$(VERSION_EXTENSION)\"" \
|
||||
"#define BUILD_DATE \"$(BUILD_DATE)\"" \
|
||||
"#endif" > $(VERSION_HEADER)
|
||||
"#endif" > $(VERSION_HEADER).tmp
|
||||
@cmp -s $(VERSION_HEADER).tmp $(VERSION_HEADER) \
|
||||
&& rm -f $(VERSION_HEADER).tmp \
|
||||
|| mv $(VERSION_HEADER).tmp $(VERSION_HEADER)
|
||||
|
||||
httpd: html_data.h
|
||||
|
||||
@@ -166,7 +169,7 @@ $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.i
|
||||
tools/output/crc_calculator -u $@
|
||||
ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin output/rtlplayground.bin
|
||||
|
||||
.PHONY: clean distclean all $(SUBDIRS) $(SUBDIRSCLEAN) $(VERSION_HEADER) create_build_dir
|
||||
.PHONY: clean distclean all $(SUBDIRS) $(SUBDIRSCLEAN) create_build_dir
|
||||
|
||||
.PHONY:
|
||||
machine_check:
|
||||
|
||||
Reference in new issue
Block a user