2016-11-30 06:21:50 +10:30
|
|
|
#! /usr/bin/make
|
|
|
|
|
2020-08-31 10:43:25 +09:30
|
|
|
WIRE_HEADERS := wire/onion_defs.h \
|
2018-09-14 08:13:12 +09:30
|
|
|
wire/peer_wire.h \
|
2020-09-08 06:36:50 +09:30
|
|
|
wire/onion_wire.h \
|
2020-08-31 10:43:25 +09:30
|
|
|
wire/tlvstream.h \
|
2017-04-01 20:55:59 +10:30
|
|
|
wire/wire.h \
|
2017-01-10 15:22:20 +10:30
|
|
|
wire/wire_sync.h \
|
2020-08-31 10:43:25 +09:30
|
|
|
wire/wire_io.h \
|
2023-05-22 10:21:44 +09:30
|
|
|
wire/peer_wiregen.h \
|
|
|
|
wire/onion_wiregen.h \
|
|
|
|
wire/bolt12_wiregen.h \
|
2021-09-09 12:20:52 +09:30
|
|
|
wire/channel_type_wiregen.h \
|
2023-05-22 10:21:44 +09:30
|
|
|
wire/bolt12_printgen.h \
|
|
|
|
wire/peer_printgen.h \
|
|
|
|
wire/onion_printgen.h
|
2020-08-31 10:43:25 +09:30
|
|
|
|
2022-10-17 11:07:05 +10:30
|
|
|
# We don't include peer_printgen/onion_printgen or bolt12 here since most don't need it.
|
2017-01-10 15:21:20 +10:30
|
|
|
WIRE_SRC := wire/wire_sync.c \
|
2017-01-10 15:22:20 +10:30
|
|
|
wire/wire_io.c \
|
2017-01-10 15:21:20 +10:30
|
|
|
wire/fromwire.c \
|
2017-04-01 20:55:59 +10:30
|
|
|
wire/peer_wire.c \
|
2020-05-15 19:59:34 +09:30
|
|
|
wire/tlvstream.c \
|
2020-08-31 10:43:25 +09:30
|
|
|
wire/towire.c \
|
2023-05-22 10:21:44 +09:30
|
|
|
wire/peer_wiregen.c \
|
2021-09-09 12:20:52 +09:30
|
|
|
wire/channel_type_wiregen.c \
|
2023-05-22 10:21:44 +09:30
|
|
|
wire/onion_wiregen.c
|
2020-08-31 10:43:25 +09:30
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
WIRE_BOLT12_SRC := wire/bolt12_wiregen.c
|
2022-10-17 11:07:05 +10:30
|
|
|
|
2020-08-31 10:43:25 +09:30
|
|
|
WIRE_PRINT_SRC := \
|
2023-05-22 10:21:44 +09:30
|
|
|
wire/onion_printgen.c \
|
|
|
|
wire/peer_printgen.c \
|
|
|
|
wire/bolt12_printgen.c \
|
2021-09-09 12:20:52 +09:30
|
|
|
wire/channel_type_printgen.c
|
2017-01-04 14:09:20 +10:30
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
WIRE_PRINT_HEADERS := $(WIRE_PRINT_SRC:.c=.h)
|
|
|
|
|
2024-05-09 13:04:13 +09:30
|
|
|
WIRE_OBJS := $(WIRE_SRC:.c=.o) common/sciddir_or_pubkey.o
|
2020-08-31 10:43:25 +09:30
|
|
|
WIRE_PRINT_OBJS := $(WIRE_PRINT_SRC:.c=.o)
|
2022-10-17 11:07:05 +10:30
|
|
|
WIRE_BOLT12_OBJS := $(WIRE_BOLT12_SRC:.c=.o)
|
2023-05-22 10:21:44 +09:30
|
|
|
$(WIRE_OBJS) $(WIRE_PRINT_OBJS) $(WIRE_BOLT12_OBJS): $(WIRE_HEADERS) $(WIRE_PRINT_HEADERS)
|
2017-08-29 01:43:01 +09:30
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
ALL_C_SOURCES += $(WIRE_SRC) $(WIRE_BOLT12_SRC) $(WIRE_PRINT_SRC)
|
2021-06-03 12:59:47 +09:30
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
ALL_C_HEADERS += $(WIRE_HEADERS)
|
2016-11-30 06:21:50 +10:30
|
|
|
|
|
|
|
# They may not have the bolts.
|
2018-09-14 08:29:22 +09:30
|
|
|
BOLT_EXTRACT=$(LOCAL_BOLTDIR)/tools/extract-formats.py
|
2017-01-06 13:40:35 +10:30
|
|
|
|
2019-07-15 18:20:37 -05:00
|
|
|
WIRE_BOLT_DEPS := $(BOLT_DEPS) tools/gen/impl_template tools/gen/header_template
|
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
# These are applied to the bolts.
|
|
|
|
PEER_PATCHES := $(sort $(wildcard wire/extracted_peer*.patch))
|
|
|
|
ONION_PATCHES := $(sort $(wildcard wire/extracted_onion*.patch))
|
|
|
|
BOLT12_PATCHES := $(sort $(wildcard wire/extracted_bolt12*.patch))
|
2020-12-05 12:50:54 +10:30
|
|
|
|
2021-01-13 12:19:35 +10:30
|
|
|
# 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 12:36:19 -07:00
|
|
|
|
2021-01-13 12:19:35 +10:30
|
|
|
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 12:36:19 -07:00
|
|
|
|
2021-01-13 12:19:35 +10:30
|
|
|
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-09 18:57:04 -05:00
|
|
|
|
2021-01-13 12:19:35 +10:30
|
|
|
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 > $@
|
|
|
|
|
|
|
|
# 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
|
2023-05-22 10:21:44 +09:30
|
|
|
@$(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/0[127]*.md | diff -u wire/peer_wire.csv - >wire/extracted_peer_$(BOLTVERSION).patch | if [ $$? -lt 0 ];then exit 1;fi; echo wire/extracted_peer_$(BOLTVERSION).patch
|
|
|
|
@{ echo '#include <wire/onion_defs.h>'; $(BOLT_EXTRACT) $(LOCAL_BOLTDIR)/04*.md; } | diff -u wire/onion_wire.csv - > wire/extracted_onion_$(BOLTVERSION).patch | if [ $$? -lt 0 ];then exit 1;fi; echo wire/extracted_onion_$(BOLTVERSION).patch
|
2016-11-30 06:21:50 +10:30
|
|
|
|
2019-08-01 14:29:10 +09:30
|
|
|
# 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.
|
2022-03-23 10:01:14 +10:30
|
|
|
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=tlv_n1 --expose-tlv-type=tlv_n2
|
2017-01-06 13:40:35 +10:30
|
|
|
|
2022-03-23 10:01:14 +10:30
|
|
|
wire/peer_wiregen.c_args := -s --expose-tlv-type=tlv_n1 --expose-tlv-type=tlv_n2
|
2019-04-16 12:32:30 -07:00
|
|
|
|
2023-04-07 16:06:14 +09:30
|
|
|
# The payload isn't parsed in a fromwire, so we need to expose it.
|
2024-05-09 13:06:20 +09:30
|
|
|
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' --include='common/sciddir_or_pubkey.h' -s --expose-tlv-type=tlv_payload
|
2019-11-28 19:07:52 +01:00
|
|
|
|
2023-04-07 16:06:14 +09:30
|
|
|
wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_payload
|
2019-11-28 19:07:52 +01:00
|
|
|
|
2020-09-08 06:36:50 +09:30
|
|
|
# Same for _exp versions
|
2021-09-09 12:20:52 +09:30
|
|
|
wire/peer_exp_wiregen.h_args := $(wire/peer_wiregen.h_args) --include='wire/channel_type_wiregen.h'
|
2020-09-08 06:36:50 +09:30
|
|
|
wire/peer_exp_wiregen.c_args := $(wire/peer_wiregen.c_args)
|
2021-09-09 12:20:52 +09:30
|
|
|
wire/peer_exp_printgen.h_args := --include='wire/channel_type_printgen.h'
|
2020-09-08 06:36:50 +09:30
|
|
|
wire/onion_exp_wiregen.h_args := $(wire/onion_wiregen.h_args)
|
|
|
|
wire/onion_exp_wiregen.c_args := $(wire/onion_wiregen.c_args)
|
|
|
|
|
2022-11-09 13:02:01 +10:30
|
|
|
wire/bolt12_wiregen.c_args := -s --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request --expose-tlv-type=tlv_invoice
|
2021-01-13 12:19:36 +10:30
|
|
|
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)
|
2022-03-23 10:01:14 +10:30
|
|
|
|
2023-05-22 10:21:44 +09:30
|
|
|
wire/bolt12_printgen.c_args := --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request --include='wire/onion_wiregen.h' --include='wire/onion_printgen.h'
|
|
|
|
wire/bolt12_printgen.h_args := --include='wire/bolt12_wiregen.h' --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request
|
2022-03-23 10:01:14 +10:30
|
|
|
|
2021-01-13 12:19:36 +10:30
|
|
|
# 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)
|
2022-03-23 10:01:14 +10:30
|
|
|
wire/bolt12_exp_printgen.h_args := $(wire/bolt12_printgen.h_args)
|
|
|
|
wire/bolt12_exp_printgen.c_args := $(wire/bolt12_printgen.c_args)
|
2020-12-05 12:50:54 +10:30
|
|
|
|
2022-03-23 10:01:14 +10:30
|
|
|
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=tlv_n1 --expose-tlv-type=tlv_n2
|
2020-12-05 12:50:54 +10:30
|
|
|
|
2021-09-09 12:20:52 +09:30
|
|
|
wire/channel_type_wiregen.h_args := -s
|
|
|
|
wire/channel_type_wiregen.c_args := $(wire/channel_type_wiregen.h_args)
|
|
|
|
|
2020-12-16 13:43:12 +10:30
|
|
|
# All generated wire/ files depend on this Makefile
|
2023-05-22 10:21:44 +09:30
|
|
|
$(filter %printgen.h %printgen.c %wiregen.h %wiregen.c, $(WIRE_SRC) $(WIRE_BOLT12_SRC) $(WIRE_PRINT_SRC) $(WIRE_HEADERS)): wire/Makefile
|
2020-12-16 13:43:12 +10:30
|
|
|
|
2017-01-10 15:23:20 +10:30
|
|
|
maintainer-clean: wire-maintainer-clean
|
|
|
|
|
2021-03-24 11:59:06 -05:00
|
|
|
clean: wire-clean
|
|
|
|
|
|
|
|
wire-clean:
|
|
|
|
$(RM) wire/*.csv.*
|
2021-09-19 12:57:02 +02:00
|
|
|
$(RM) wire/channel_type_*gen*
|
2023-05-22 10:21:44 +09:30
|
|
|
$(RM) wire/*_exp_*gen.[ch] # From when we had experimental builds
|
2021-03-24 11:59:06 -05:00
|
|
|
|
|
|
|
wire-maintainer-clean: wire-clean
|
2019-04-16 12:36:19 -07:00
|
|
|
$(RM) wire/gen_*_csv wire/extracted_*_experimental_csv
|
2017-01-10 15:23:20 +10:30
|
|
|
|
2017-01-04 14:09:20 +10:30
|
|
|
include wire/test/Makefile
|