2016-11-29 20:51:50 +01:00
|
|
|
#! /usr/bin/make
|
|
|
|
|
2020-08-31 03:13:25 +02:00
|
|
|
WIRE_HEADERS := wire/onion_defs.h \
|
2018-09-14 00:43:12 +02:00
|
|
|
wire/peer_wire.h \
|
2020-09-07 23:06:50 +02:00
|
|
|
wire/onion_wire.h \
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/tlvstream.h \
|
2017-04-01 12:25:59 +02:00
|
|
|
wire/wire.h \
|
2017-01-10 05:52:20 +01:00
|
|
|
wire/wire_sync.h \
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/wire_io.h \
|
2020-09-07 23:06:50 +02:00
|
|
|
wire/peer$(EXP)_wiregen.h \
|
|
|
|
wire/onion$(EXP)_wiregen.h \
|
2021-01-13 04:00:24 +01:00
|
|
|
wire/bolt12$(EXP)_wiregen.h \
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/common_wiregen.h \
|
2020-09-07 23:06:50 +02:00
|
|
|
wire/peer$(EXP)_printgen.h \
|
|
|
|
wire/onion$(EXP)_printgen.h
|
2020-08-31 03:13:25 +02:00
|
|
|
|
2020-08-31 03:13:25 +02:00
|
|
|
# We don't include peer_printgen/onion_printgen here since most don't need it.
|
2017-01-10 05:51:20 +01:00
|
|
|
WIRE_SRC := wire/wire_sync.c \
|
2017-01-10 05:52:20 +01:00
|
|
|
wire/wire_io.c \
|
2017-01-10 05:51:20 +01:00
|
|
|
wire/fromwire.c \
|
2017-04-01 12:25:59 +02:00
|
|
|
wire/peer_wire.c \
|
2020-05-15 12:29:34 +02:00
|
|
|
wire/tlvstream.c \
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/towire.c \
|
|
|
|
wire/common_wiregen.c \
|
2021-01-13 04:00:24 +01:00
|
|
|
wire/bolt12$(EXP)_wiregen.c \
|
2020-09-07 23:06:50 +02:00
|
|
|
wire/peer$(EXP)_wiregen.c \
|
|
|
|
wire/onion$(EXP)_wiregen.c
|
2020-08-31 03:13:25 +02:00
|
|
|
|
|
|
|
WIRE_PRINT_SRC := \
|
2020-09-07 23:06:50 +02:00
|
|
|
wire/onion$(EXP)_printgen.c \
|
|
|
|
wire/peer$(EXP)_printgen.c
|
2017-01-04 04:39:20 +01:00
|
|
|
|
2020-08-31 03:13:25 +02:00
|
|
|
WIRE_OBJS := $(WIRE_SRC:.c=.o)
|
|
|
|
WIRE_PRINT_OBJS := $(WIRE_PRINT_SRC:.c=.o)
|
|
|
|
$(WIRE_OBJS) $(WIRE_PRINT_OBJS): $(WIRE_HEADERS)
|
2017-08-28 18:13:01 +02:00
|
|
|
|
2021-06-03 05:29:47 +02:00
|
|
|
# Make sure these depend on everything: in case we're experimental,
|
|
|
|
# include non-experimental ones here so they get rebuilt.
|
|
|
|
WIRE_NONEXP_SRC := wire/bolt12_wiregen.c \
|
|
|
|
wire/peer_wiregen.c \
|
|
|
|
wire/onion_wiregen.c \
|
|
|
|
wire/onion_printgen.c \
|
|
|
|
wire/peer_printgen.c
|
|
|
|
WIRE_NONEXP_HEADERS := wire/peer_wiregen.h \
|
|
|
|
wire/onion_wiregen.h \
|
|
|
|
wire/bolt12_wiregen.h \
|
|
|
|
wire/peer_printgen.h \
|
|
|
|
wire/onion_printgen.h
|
|
|
|
|
|
|
|
ALL_C_SOURCES += $(WIRE_SRC) $(WIRE_PRINT_SRC) $(WIRE_NONEXP_SRC)
|
|
|
|
|
|
|
|
ALL_C_HEADERS += $(WIRE_HEADERS) $(WIRE_NONEXP_HEADERS)
|
2016-11-29 20:51:50 +01:00
|
|
|
|
|
|
|
# They may not have the bolts.
|
2018-09-14 00:59:22 +02:00
|
|
|
BOLT_EXTRACT=$(LOCAL_BOLTDIR)/tools/extract-formats.py
|
2017-01-06 04:10:35 +01:00
|
|
|
|
2019-07-16 01:20:37 +02:00
|
|
|
WIRE_BOLT_DEPS := $(BOLT_DEPS) tools/gen/impl_template tools/gen/header_template
|
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
ALL_PEER_PATCHES := $(sort $(wildcard wire/extracted_peer*.patch))
|
|
|
|
ALL_ONION_PATCHES := $(sort $(wildcard wire/extracted_onion*.patch))
|
2018-09-14 00:59:22 +02:00
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
# These are applied to the non-exp csvs to make the exp csvs.
|
|
|
|
PEER_EXP_PATCHES := $(sort $(wildcard wire/extracted_peer_exp*.patch))
|
|
|
|
ONION_EXP_PATCHES := $(sort $(wildcard wire/extracted_onion_exp*.patch))
|
2020-12-05 03:20:54 +01:00
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
# These are always applied to the bolts.
|
|
|
|
PEER_PATCHES := $(filter-out $(PEER_EXP_PATCHES),$(ALL_PEER_PATCHES))
|
|
|
|
ONION_PATCHES := $(filter-out $(ONION_EXP_PATCHES),$(ALL_ONION_PATCHES))
|
2020-12-05 03:20:54 +01:00
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
# Explicit command to re-extract CSV from BOLTs and patch.
|
|
|
|
# This is not a normal make depencency, since we don't want this
|
|
|
|
# called implicitly.
|
|
|
|
# Note: You will need to run extract-bolt12-csv manually!
|
|
|
|
extract-bolt-csv: extract-peer-csv extract-onion-csv
|
2019-04-16 21:36:19 +02:00
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
extract-peer-csv: wire/peer_wire.csv.raw
|
|
|
|
@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
|
2019-04-16 21:36:19 +02:00
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
extract-onion-csv: wire/onion_wire.csv.raw
|
|
|
|
@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
|
2019-09-10 01:57:04 +02:00
|
|
|
|
2021-01-13 02:49:35 +01:00
|
|
|
extract-bolt12-csv: wire/bolt12_wire.csv.raw
|
|
|
|
@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
|
|
|
|
|
|
|
|
wire/peer_wire.csv.raw: bolt-precheck
|
|
|
|
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/0[127]*.md > $@
|
|
|
|
|
|
|
|
wire/onion_wire.csv.raw: bolt-precheck
|
|
|
|
@(echo '#include <wire/onion_defs.h>'; $(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/04*.md) > $@
|
|
|
|
|
|
|
|
wire/bolt12_wire.csv.raw: bolt-precheck
|
|
|
|
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/12*.md > $@
|
|
|
|
|
|
|
|
# How to make the exp versions from non-exp versions:
|
2021-03-03 02:12:55 +01:00
|
|
|
wire/peer_exp_wire.csv: wire/peer_wire.csv $(PEER_EXP_PATCHES)
|
2021-01-13 02:49:35 +01:00
|
|
|
@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
|
|
|
|
|
2021-03-03 02:12:55 +01:00
|
|
|
wire/onion_exp_wire.csv: wire/onion_wire.csv $(ONION_EXP_PATCHES)
|
2021-01-13 02:49:35 +01:00
|
|
|
@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
|
|
|
|
|
2021-03-03 02:12:55 +01:00
|
|
|
wire/bolt12_exp_wire.csv: wire/bolt12_wire.csv $(BOLT12_EXP_PATCHES)
|
2021-01-13 02:49:35 +01:00
|
|
|
@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
|
|
|
|
|
|
|
|
# These can be deleted.
|
|
|
|
.INTERMEDIATE: wire/peer_wire.csv.raw wire/onion_wire.csv.raw wire/bolt12_wire.csv.raw
|
|
|
|
|
|
|
|
# Explicit command to add patchfile for BOLT CSV's against current one.
|
|
|
|
generate-bolt-csv-patch: bolt-precheck
|
|
|
|
@$(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
|
|
|
|
@{ 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
|
2016-11-29 20:51:50 +01:00
|
|
|
|
2019-08-01 06:59:10 +02:00
|
|
|
# tlvs_n1 and n2 are used for test vectors, thus not referenced: expose them
|
|
|
|
# for testing and to prevent compile error about them being unused.
|
|
|
|
# This will be easier if test vectors are moved to separate files.
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2
|
2017-01-06 04:10:35 +01:00
|
|
|
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/peer_wiregen.c_args := -s --expose-tlv-type=n1 --expose-tlv-type=n2
|
2019-04-16 21:32:30 +02:00
|
|
|
|
2019-08-02 05:24:25 +02:00
|
|
|
# The tlv_payload isn't parsed in a fromwire, so we need to expose it.
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' -s --expose-tlv-type=tlv_payload
|
2019-11-28 19:07:52 +01:00
|
|
|
|
2020-08-31 03:13:25 +02:00
|
|
|
wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_payload
|
2019-11-28 19:07:52 +01:00
|
|
|
|
2020-09-07 23:06:50 +02:00
|
|
|
# Same for _exp versions
|
|
|
|
wire/peer_exp_wiregen.h_args := $(wire/peer_wiregen.h_args)
|
|
|
|
wire/peer_exp_wiregen.c_args := $(wire/peer_wiregen.c_args)
|
|
|
|
wire/onion_exp_wiregen.h_args := $(wire/onion_wiregen.h_args)
|
|
|
|
wire/onion_exp_wiregen.c_args := $(wire/onion_wiregen.c_args)
|
|
|
|
|
2021-01-13 02:49:36 +01:00
|
|
|
wire/bolt12_wiregen.c_args := -s --expose-tlv-type=blinded_path --expose-tlv-type=invoice_request
|
|
|
|
wire/bolt12_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/signature.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' --include='wire/onion_wire.h' $(wire/bolt12_wiregen.c_args)
|
|
|
|
# Same for _exp versions
|
|
|
|
wire/bolt12_exp_wiregen.h_args := $(wire/bolt12_wiregen.h_args)
|
|
|
|
wire/bolt12_exp_wiregen.c_args := $(wire/bolt12_wiregen.c_args)
|
2020-12-05 03:20:54 +01:00
|
|
|
|
|
|
|
wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2
|
|
|
|
|
2020-12-16 04:13:12 +01:00
|
|
|
# All generated wire/ files depend on this Makefile
|
2021-06-03 05:29:47 +02:00
|
|
|
$(filter %printgen.h %printgen.c %wiregen.h %wiregen.c, $(WIRE_SRC) $(WIRE_PRINT_SRC) $(WIRE_NONEXP_SRC) $(WIRE_HEADERS) $(WIRE_NONEXP_HEADERS)): wire/Makefile
|
2020-12-16 04:13:12 +01:00
|
|
|
|
2017-01-10 05:53:20 +01:00
|
|
|
maintainer-clean: wire-maintainer-clean
|
|
|
|
|
2021-03-24 17:59:06 +01:00
|
|
|
clean: wire-clean
|
|
|
|
|
|
|
|
wire-clean:
|
|
|
|
$(RM) wire/*.csv.*
|
|
|
|
|
|
|
|
wire-maintainer-clean: wire-clean
|
2019-04-16 21:36:19 +02:00
|
|
|
$(RM) wire/gen_*_csv wire/extracted_*_experimental_csv
|
2017-01-10 05:53:20 +01:00
|
|
|
|
2017-01-04 04:39:20 +01:00
|
|
|
include wire/test/Makefile
|