Skip to content

Commit 7af63eb

Browse files
rustyrussellcdecker
authored andcommitted
wire/Makefile: refactor to allow non-experimental spec patches.
And rename the current patches to all be _exp_*.patch. These are applied after the basic patches. Signed-off-by: Rusty Russell <[email protected]> Header from folded patch 'fix.patch':
1 parent 1794d0f commit 7af63eb

21 files changed

+56
-32
lines changed

wire/Makefile

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,58 @@ BOLT_EXTRACT=$(LOCAL_BOLTDIR)/tools/extract-formats.py
4747

4848
WIRE_BOLT_DEPS := $(BOLT_DEPS) tools/gen/impl_template tools/gen/header_template
4949

50-
# Explicit command to re-extract CSV from BOLTs.
51-
extract-bolt-csv: bolt-precheck
52-
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/0[127]*.md > wire/peer_wire.csv
53-
@echo '#include <wire/onion_defs.h>' > wire/onion_wire.csv
54-
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/04*.md >> wire/onion_wire.csv
50+
ALL_PEER_PATCHES := $(sort $(wildcard wire/extracted_peer*.patch))
51+
ALL_ONION_PATCHES := $(sort $(wildcard wire/extracted_onion*.patch))
5552

56-
extract-bolt12-csv: bolt-precheck
57-
$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/12*.md > wire/bolt12_exp_wire.csv
53+
# These are applied to the non-exp csvs to make the exp csvs.
54+
PEER_EXP_PATCHES := $(sort $(wildcard wire/extracted_peer_exp*.patch))
55+
ONION_EXP_PATCHES := $(sort $(wildcard wire/extracted_onion_exp*.patch))
5856

59-
ifeq ($(EXPERIMENTAL_FEATURES),1)
60-
extract-bolt-csv: extract-bolt12-csv
61-
endif
57+
# These are always applied to the bolts.
58+
PEER_PATCHES := $(filter-out $(PEER_EXP_PATCHES),$(ALL_PEER_PATCHES))
59+
ONION_PATCHES := $(filter-out $(ONION_EXP_PATCHES),$(ALL_ONION_PATCHES))
6260

63-
# Explicit command to add patchfile for BOLT CSV's
64-
extract-experimental-bolt-csv: bolt-precheck
65-
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/0[127]*.md | diff -u wire/peer_exp_wire.csv - >wire/extracted_peer_experimental_$(BOLTVERSION) | if [ $$? -lt 0 ];then exit 1;fi
66-
@{ echo '#include <wire/onion_defs.h>'; $(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/04*.md; } | diff -u wire/onion_exp_wire.csv - > wire/extracted_onion_experimental_$(BOLTVERSION) | if [ $$? -lt 0 ];then exit 1;fi
61+
# Explicit command to re-extract CSV from BOLTs and patch.
62+
# This is not a normal make depencency, since we don't want this
63+
# called implicitly.
64+
# Note: You will need to run extract-bolt12-csv manually!
65+
extract-bolt-csv: extract-peer-csv extract-onion-csv
6766

68-
ifeq ($(EXPERIMENTAL_FEATURES),1)
69-
EXPERIMENTAL_PEER_PATCHES := $(sort $(wildcard wire/extracted_peer_experimental_*))
70-
EXPERIMENTAL_ONION_PATCHES := $(sort $(wildcard wire/extracted_onion_experimental_*))
67+
extract-peer-csv: wire/peer_wire.csv.raw
68+
@set -e; T=wire/peer_wire.csv; trap "rm -f $$T.$$$$" 0; cp $< $$T.$$$$; for p in $(PEER_PATCHES); do echo APPLY $$p; patch $$T.$$$$ $$p; done; mv $$T.$$$$ $$T
7169

72-
wire/peer_exp_wire.csv: wire/peer_wire.csv $(EXPERIMENTAL_PEER_PATCHES)
73-
@set -e; trap "rm -f $@.$$$$" 0; cp $< $@.$$$$; for exp in $(EXPERIMENTAL_PEER_PATCHES); do patch $@.$$$$ $$exp >/dev/null ; done; mv $@.$$$$ $@
70+
extract-onion-csv: wire/onion_wire.csv.raw
71+
@set -e; T=wire/onion_wire.csv; trap "rm -f $$T.$$$$" 0; cp $< $$T.$$$$; for p in $(ONION_PATCHES); do echo APPLY $$p; patch $$T.$$$$ $$p; done; mv $$T.$$$$ $$T
7472

75-
wire/onion_exp_wire.csv: wire/onion_wire.csv $(EXPERIMENTAL_ONION_PATCHES)
76-
@set -e; trap "rm -f $@.$$$$" 0; cp $< $@.$$$$; for exp in $(EXPERIMENTAL_ONION_PATCHES); do patch $@.$$$$ $$exp; done >/dev/null ; mv $@.$$$$ $@
77-
endif
73+
extract-bolt12-csv: wire/bolt12_wire.csv.raw
74+
@set -e; T=wire/bolt12_wire.csv; trap "rm -f $$T.$$$$" 0; cp $< $$T.$$$$; for p in $(BOLT12_PATCHES); do echo APPLY $$p; patch $$T.$$$$ $$p; done; mv $$T.$$$$ $$T
75+
76+
wire/peer_wire.csv.raw: bolt-precheck
77+
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/0[127]*.md > $@
78+
79+
wire/onion_wire.csv.raw: bolt-precheck
80+
@(echo '#include <wire/onion_defs.h>'; $(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/04*.md) > $@
81+
82+
wire/bolt12_wire.csv.raw: bolt-precheck
83+
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/12*.md > $@
84+
85+
# How to make the exp versions from non-exp versions:
86+
wire/peer_exp_wire.csv: wire/peer_wire.csv
87+
@set -e; T=$@; trap "rm -f $$T.$$$$" 0; cp $< $$T.$$$$; for p in $(PEER_EXP_PATCHES); do echo APPLY $$p; patch $$T.$$$$ $$p; done; mv $$T.$$$$ $$T
88+
89+
wire/onion_exp_wire.csv: wire/onion_wire.csv
90+
@set -e; T=$@; trap "rm -f $$T.$$$$" 0; cp $< $$T.$$$$; for p in $(ONION_EXP_PATCHES); do echo APPLY $$p; patch $$T.$$$$ $$p; done; mv $$T.$$$$ $$T
91+
92+
wire/bolt12_exp_wire.csv: wire/bolt12_wire.csv
93+
@set -e; T=$@; trap "rm -f $$T.$$$$" 0; cp $< $$T.$$$$; for p in $(BOLT12_EXP_PATCHES); do echo APPLY $$p; patch $$T.$$$$ $$p; done; mv $$T.$$$$ $$T
94+
95+
# These can be deleted.
96+
.INTERMEDIATE: wire/peer_wire.csv.raw wire/onion_wire.csv.raw wire/bolt12_wire.csv.raw
97+
98+
# Explicit command to add patchfile for BOLT CSV's against current one.
99+
generate-bolt-csv-patch: bolt-precheck
100+
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/0[127]*.md | diff -u wire/peer$(EXP)_wire.csv - >wire/extracted_peer$(EXP)_$(BOLTVERSION).patch | if [ $$? -lt 0 ];then exit 1;fi; echo wire/extracted_peer$(EXP)_$(BOLTVERSION).patch
101+
@{ echo '#include <wire/onion_defs.h>'; $(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/04*.md; } | diff -u wire/onion$(EXP)_wire.csv - > wire/extracted_onion$(EXP)_$(BOLTVERSION).patch | if [ $$? -lt 0 ];then exit 1;fi; echo wire/extracted_onion$(EXP)_$(BOLTVERSION).patch
78102

79103
# tlvs_n1 and n2 are used for test vectors, thus not referenced: expose them
80104
# for testing and to prevent compile error about them being unused.

wire/common_wiregen.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wire/common_wiregen.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)