Skip to content

Commit

Permalink
update-mocks: don't try to regenerate files.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell committed May 22, 2021
1 parent 33736b8 commit cc6f1fd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -527,17 +533,21 @@ 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)

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

Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 > $@
Expand Down
2 changes: 1 addition & 1 deletion external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/update-mocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions wallet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc6f1fd

Please sign in to comment.