update-mocks: don't try to regenerate files.

If you do update-mocks in a dirty tree, the recursive make that it
uses will try to rebuild things!  Suppress that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-05-21 14:46:05 +09:30
parent 33736b860a
commit cc6f1fd120
6 changed files with 19 additions and 9 deletions

View File

@ -280,12 +280,18 @@ else
EXP :=
endif
# tools/update-mocks.sh does nasty recursive make, must not do this!
ifeq ($(SUPPRESS_GENERATION),1)
SHA256STAMP_CHANGED = false
SHA256STAMP = exit 1
else
# Git doesn't maintain timestamps, so we only regen if sources actually changed:
# We place the SHA inside some generated files so we can tell if they need updating.
# Usage: $(call SHA256STAMP_CHANGED)
SHA256STAMP_CHANGED = [ x"`sed -n 's/.*SHA256STAMP://p' $@ 2>/dev/null`" != x"`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64`" ]
# Usage: $(call SHA256STAMP,commentprefix)
SHA256STAMP = echo '$(1) SHA256STAMP:'`cat $(sort $(filter-out FORCE,$^)) | $(SHA256SUM) | cut -c1-64` >> $@
endif
# generate-wire.py --page [header|impl] hdrfilename wirename < csv > file
%_wiregen.h: %_wire.csv $(WIRE_GEN_DEPS)
@ -363,7 +369,7 @@ ALL_OBJS := $(ALL_C_SOURCES:.c=.o)
# We always regen wiregen and printgen files, since SHA256STAMP protects against
# spurious rebuilds.
$(filter %printgen.h %printgen.c %wiregen.h %wiregen.c, $(ALL_C_HEADERS) $(ALL_C_SOURCES)): FORCE
$(filter %printgen.h %printgen.c %wiregen.h %wiregen.c, $(ALL_C_HEADERS) $(ALL_C_SOURCES)): $(FORCE)
ifneq ($(TEST_GROUP_COUNT),)
PYTEST_OPTS += --test-group=$(TEST_GROUP) --test-group-count=$(TEST_GROUP_COUNT)
@ -527,9 +533,13 @@ ncc: ${TARGET_DIR}/libwally-core-build/src/libwallycore.la
$(MAKE) CC="ncc -ncgcc -ncld -ncfabs" AR=nccar LD=nccld
# Ignore test/ directories.
TAGS: FORCE
TAGS:
$(RM) TAGS; find * -name test -type d -prune -o -name '*.[ch]' -print -o -name '*.py' -print | xargs etags --append
ifneq ($(SUPPRESS_GENERATION),1)
FORCE = FORCE
FORCE::
endif
ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS)
@ -537,7 +547,7 @@ ALL_PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr
# Can't add to ALL_OBJS, as that makes a circular dep.
ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS) Makefile
version_gen.h: FORCE
version_gen.h: $(FORCE)
@(echo "#define VERSION \"$(VERSION)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new
@if cmp $@.new $@ >/dev/null 2>&1; then rm -f $@.new; else mv $@.new $@; $(ECHO) Version updated; fi

View File

@ -89,7 +89,7 @@ doc-all: $(MANPAGES) doc/index.rst
$(MANPAGES): doc/%: doc/%.md
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE, "mrkd $<", mrkd $< $@ && $(call SHA256STAMP,\")); else touch $@; fi
$(MANPAGES): FORCE
$(MANPAGES): $(FORCE)
doc/protocol-%.svg: test/test_protocol
test/test_protocol --svg < test/commits/$*.script > $@

2
external/Makefile vendored
View File

@ -48,7 +48,7 @@ endif
EXTERNAL_LDLIBS := -L${TARGET_DIR} $(patsubst lib%.a,-l%,$(notdir $(EXTERNAL_LIBS)))
submodcheck: FORCE
submodcheck: $(FORCE)
@tools/refresh-submodules.sh $(SUBMODULES)
@cd external/libwally-core && ../../tools/refresh-submodules.sh src/secp256k1

View File

@ -12,7 +12,7 @@ TOOLS_COMMON_OBJS = common/utils.o
# We force make to relink this every time, to detect version changes.
# Do it atomically, otherwise parallel builds can get upset!
tools/headerversions: FORCE tools/headerversions.o $(CCAN_OBJS)
tools/headerversions: $(FORCE) tools/headerversions.o $(CCAN_OBJS)
@trap "rm -f $@.tmp.$$$$" EXIT; $(LINK.o) tools/headerversions.o $(CCAN_OBJS) $(LOADLIBES) $(LDLIBS) -o $@.tmp.$$$$ && mv $@.tmp.$$$$ $@
tools/check-bolt: tools/check-bolt.o $(CCAN_OBJS) $(TOOLS_COMMON_OBJS)

View File

@ -13,7 +13,7 @@ START=$(grep -F -n '/* AUTOGENERATED MOCKS START */' "$FILE" | cut -d: -f1)
END=$(grep -F -n '/* AUTOGENERATED MOCKS END */' "$FILE" | cut -d: -f1)
function make_binary() {
$MAKE "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null
$MAKE SUPPRESS_GENERATION=1 "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null
}
if [ -n "$START" ]; then

View File

@ -36,12 +36,12 @@ SQL_FILES := \
wallet/test/run-db.c \
wallet/test/run-wallet.c \
wallet/statements_gettextgen.po: $(SQL_FILES) FORCE
wallet/statements_gettextgen.po: $(SQL_FILES) $(FORCE)
@if $(call SHA256STAMP_CHANGED); then if [ "$$NO_PYTHON" = 1 ]; then echo "Error: NO_PYTHON on $@"; exit 1; fi; \
$(call VERBOSE,"xgettext $@",xgettext -kNAMED_SQL -kSQL --add-location --no-wrap --omit-header -o $@ $(SQL_FILES) && $(call SHA256STAMP,# )); \
fi
wallet/db_%_sqlgen.c: wallet/statements_gettextgen.po devtools/sql-rewrite.py FORCE
wallet/db_%_sqlgen.c: wallet/statements_gettextgen.po devtools/sql-rewrite.py $(FORCE)
@if $(call SHA256STAMP_CHANGED); then if [ "$$NO_PYTHON" = 1 ]; then echo "Error: NO_PYTHON on $@"; exit 1; fi; \
$(call VERBOSE,"sql-rewrite $@",devtools/sql-rewrite.py wallet/statements_gettextgen.po $* > $@ && $(call SHA256STAMP,//)); \
fi