Makefile: use completely separate spec-derived files for EXPERIMENTAL_FEATURES

This avoids overwriting the ones in git, and generally makes things neater.

We have convenience headers wire/peer_wire.h and wire/onion_wire.h to
avoid most #ifdefs: simply include those.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-09-08 06:36:50 +09:30
parent d8e8426b52
commit c34c055d82
58 changed files with 109 additions and 80 deletions

View File

@@ -253,6 +253,14 @@ config.vars:
%.o: %.c
@$(call VERBOSE, "cc $<", $(CC) $(CFLAGS) -c -o $@ $<)
# '_exp' inserted before _wiregen.[ch] to demark experimental
# spec-derived headers, which are *not* committed into git.
ifeq ($(EXPERIMENTAL_FEATURES),1)
EXP := _exp
else
EXP :=
endif
# 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)
@@ -262,16 +270,16 @@ SHA256STAMP = echo '$(1) SHA256STAMP:'`cat $(filter-out FORCE,$^) | sha256sum |
# generate-wire.py --page [header|impl] hdrfilename wirename < csv > file
%_wiregen.h: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"wiregen $@",tools/generate-wire.py --page header $($@_args) $@ `basename $< .csv` < $< > $@ && $(call SHA256STAMP,//)); fi
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"wiregen $@",tools/generate-wire.py --page header $($@_args) $@ `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//)); fi
%_wiregen.c: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"wiregen $@",tools/generate-wire.py --page impl $($@_args) ${@:.c=.h} `basename $< .csv` < $< > $@ && $(call SHA256STAMP,//)); fi
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"wiregen $@",tools/generate-wire.py --page impl $($@_args) ${@:.c=.h} `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//)); fi
%_printgen.h: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page header $($@_args) $@ `basename $< .csv` < $< > $@ && $(call SHA256STAMP,//)); fi
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page header $($@_args) $@ `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//)); fi
%_printgen.c: %_wire.csv $(WIRE_GEN_DEPS)
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page impl $($@_args) ${@:.c=.h} `basename $< .csv` < $< > $@ && $(call SHA256STAMP,//)); fi
@if $(call SHA256STAMP_CHANGED); then $(call VERBOSE,"printgen $@",tools/generate-wire.py -s -P --page impl $($@_args) ${@:.c=.h} `basename $< .csv | sed 's/_exp_/_/'` < $< > $@ && $(call SHA256STAMP,//)); fi
include external/Makefile
include bitcoin/Makefile

View File

@@ -63,7 +63,7 @@
#include <sodium/crypto_aead_chacha20poly1305.h>
#include <stdio.h>
#include <wire/common_wiregen.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
#include <wire/peer_wire.h>
#include <wire/wire.h>
#include <wire/wire_io.h>

View File

@@ -6,7 +6,7 @@
#include <common/amount.h>
#include <common/htlc.h>
#include <common/pseudorand.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct htlc {
/* What's the status. */

View File

@@ -1,7 +1,7 @@
#include <ccan/cast/cast.h>
#include <common/decode_array.h>
#include <common/utils.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire.h>
#include <zlib.h>

View File

@@ -11,7 +11,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#if DEVELOPER
/* We move the fd if and only if we do a disconnect. */

View File

@@ -4,7 +4,7 @@
#include <common/gossip_rcvd_filter.h>
#include <common/memleak.h>
#include <common/pseudorand.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
static u64 msg_key(const u8 *msg)
{

View File

@@ -9,7 +9,7 @@
#include <errno.h>
#include <inttypes.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
void gossip_setup_timestamp_filter(struct per_peer_state *pps,
u32 first_timestamp,

View File

@@ -20,7 +20,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
/* We need this global to decode indexes for hash functions */
static struct gossmap *map;

View File

@@ -6,7 +6,7 @@
#include <common/amount.h>
#include <common/htlc.h>
#include <common/sphinx.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct bitcoin_tx;
struct shachain;

View File

@@ -5,7 +5,7 @@
#include <common/ecdh.h>
#include <common/sphinx.h>
#include <sodium/crypto_aead_chacha20poly1305.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
/* BOLT #4:
*

View File

@@ -1,7 +1,7 @@
#include <common/ping.h>
#include <common/status.h>
#include <common/version.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
bool check_ping_make_pong(const tal_t *ctx, const u8 *ping, u8 **pong)
{

View File

@@ -10,7 +10,7 @@
#include <common/hmac.h>
#include <secp256k1.h>
#include <sodium/randombytes.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct node_id;

View File

@@ -13,7 +13,7 @@ ALL_C_SOURCES += $(COMMON_TEST_SRC)
ALL_TEST_PROGRAMS += $(COMMON_TEST_PROGRAMS)
# Sphinx test wants to decode TLVs.
common/test/run-sphinx: wire/onion_wiregen.o wire/towire.o wire/fromwire.o
common/test/run-sphinx: wire/onion$(EXP)_wiregen.o wire/towire.o wire/fromwire.o
common/test/run-param \
common/test/run-json: \
@@ -25,7 +25,7 @@ common/test/run-json: \
common/wireaddr.o \
common/type_to_string.o \
wire/fromwire.o \
wire/onion_wiregen.o \
wire/onion$(EXP)_wiregen.o \
wire/towire.o
update-mocks: $(COMMON_TEST_SRC:%=update-mocks/%)

View File

@@ -3,7 +3,7 @@
#include <common/type_to_string.h>
#include <common/utils.h>
#include <common/wire_error.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
u8 *towire_errorfmtv(const tal_t *ctx,
const struct channel_id *channel,

View File

@@ -63,7 +63,7 @@ CONNECTD_COMMON_OBJS := \
common/wire_error.o \
gossipd/gossipd_wiregen.o \
lightningd/gossip_msg.o \
wire/onion_wiregen.o
wire/onion$(EXP)_wiregen.o
lightningd/lightning_connectd: $(CONNECTD_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(HSMD_CLIENT_OBJS)

View File

@@ -68,7 +68,6 @@
#include <sys/un.h>
#include <unistd.h>
#include <wire/peer_wire.h>
#include <wire/peer_wiregen.h>
#include <wire/wire_io.h>
#include <wire/wire_sync.h>
#include <zlib.h>

View File

@@ -41,8 +41,8 @@ DEVTOOLS_COMMON_OBJS := \
common/utils.o \
common/version.o \
common/wireaddr.o \
wire/onion_wiregen.o \
wire/peer_wiregen.o
wire/onion$(EXP)_wiregen.o \
wire/peer$(EXP)_wiregen.o
devtools/bolt11-cli: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o
@@ -61,7 +61,7 @@ devtools/onion: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS
devtools/blindedpath: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) common/blinding.o $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/blindedpath.o common/onion.o common/onionreply.o common/sphinx.o
devtools/gossipwith: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer_wiregen.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o common/crypto_sync.o
devtools/gossipwith: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer$(EXP)_wiregen.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o common/crypto_sync.o
$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h

View File

@@ -16,7 +16,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
struct scidsat {

View File

@@ -5,8 +5,13 @@
#include <common/utils.h>
#include <stdio.h>
#include <unistd.h>
#if EXPERIMENTAL_FEATURES
#include <wire/onion_exp_printgen.h>
#include <wire/peer_exp_printgen.h>
#else
#include <wire/onion_printgen.h>
#include <wire/peer_printgen.h>
#endif
int main(int argc, char *argv[])
{

View File

@@ -12,7 +12,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
int main(int argc, char *argv[])
{

View File

@@ -21,7 +21,7 @@
#include <common/type_to_string.h>
#include <common/utils.h>
#include <inttypes.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <stdio.h>
static bool verbose = false;

View File

@@ -11,7 +11,7 @@
#include <common/gossip_constants.h>
#include <common/utils.h>
#include <inttypes.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <stdio.h>
static void usage(void)

View File

@@ -3,8 +3,8 @@
#include <bitcoin/preimage.h>
#include <bitcoin/tx.h>
#include <common/wireaddr.h>
#include <wire/peer_wiregen.h>
#include <wire/onion_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/onion_wire.h>
struct tlv_print_record_type {
u64 type;

View File

@@ -66,7 +66,7 @@ GOSSIPD_COMMON_OBJS := \
common/wire_error.o \
connectd/connectd_gossipd_wiregen.o \
lightningd/gossip_msg.o \
wire/onion_wiregen.o
wire/onion$(EXP)_wiregen.o
lightningd/lightning_gossipd: $(GOSSIPD_OBJS) $(GOSSIPD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(HSMD_CLIENT_OBJS)

View File

@@ -14,7 +14,7 @@
#include <gossipd/gossipd.h>
#include <gossipd/gossipd_peerd_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire_sync.h>
/* Create a node_announcement with the given signature. It may be NULL in the

View File

@@ -18,7 +18,7 @@
#include <sys/stat.h>
#include <sys/uio.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire.h>
#define GOSSIP_STORE_FILENAME "gossip_store"

View File

@@ -63,7 +63,7 @@
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire_io.h>
#include <wire/wire_sync.h>

View File

@@ -1,7 +1,7 @@
#include <common/cryptomsg.h>
#include <common/features.h>
#include <common/wireaddr.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
# Initialize the gossip daemon.
msgtype,gossipd_init,3000
Can't render this file because it has a wrong number of fields in line 7.

View File

@@ -858,4 +858,4 @@ bool fromwire_gossipd_new_blockheight(const void *p, u32 *blockheight)
return cursor != NULL;
}
// SHA256STAMP:4aa62af856e3554603b0038eb0c9c6f5623cdb8d17abb6650338d1b728babd4b
// SHA256STAMP:9ac18b60ff39a11d7871d17a660aa9661a49d2585abe25d0ba0e048c32ac02eb

View File

@@ -10,7 +10,7 @@
#include <common/cryptomsg.h>
#include <common/features.h>
#include <common/wireaddr.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
#include <lightningd/gossip_msg.h>
#include <common/bolt11.h>
@@ -200,4 +200,4 @@ bool fromwire_gossipd_new_blockheight(const void *p, u32 *blockheight);
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_WIREGEN_H */
// SHA256STAMP:4aa62af856e3554603b0038eb0c9c6f5623cdb8d17abb6650338d1b728babd4b
// SHA256STAMP:9ac18b60ff39a11d7871d17a660aa9661a49d2585abe25d0ba0e048c32ac02eb

View File

@@ -15,7 +15,7 @@
#include <gossipd/queries.h>
#include <gossipd/routing.h>
#include <gossipd/seeker.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire.h>
#include <zlib.h>

View File

@@ -21,7 +21,7 @@
#include <gossipd/gossipd_peerd_wiregen.h>
#include <gossipd/gossipd_wiregen.h>
#include <inttypes.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)

View File

@@ -11,7 +11,7 @@
#include <common/node_id.h>
#include <gossipd/broadcast.h>
#include <gossipd/gossip_store.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
#include <wire/wire.h>
struct daemon;

View File

@@ -17,7 +17,7 @@
#include <gossipd/queries.h>
#include <gossipd/routing.h>
#include <gossipd/seeker.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#define GOSSIP_SEEKER_INTERVAL(seeker) \
DEV_FAST_GOSSIP((seeker)->daemon->rstate->dev_fast_gossip, 5, 60)

View File

@@ -17,7 +17,7 @@ GOSSIPD_TEST_COMMON_OBJS := \
common/pseudorand.o \
common/type_to_string.o \
common/utils.o \
wire/peer_wiregen.o \
wire/peer$(EXP)_wiregen.o \
wire/fromwire.o \
wire/towire.o

View File

@@ -51,7 +51,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <wally_bip32.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire_io.h>
/*~ Each subdaemon is started with stdin connected to lightningd (for status

View File

@@ -27,7 +27,7 @@
#include <lightningd/opening_control.h>
#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire_sync.h>
struct connect {

View File

@@ -33,7 +33,7 @@
#include <lightningd/ping.h>
#include <sodium/randombytes.h>
#include <string.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/wire_sync.h>
static void got_txout(struct bitcoind *bitcoind,

View File

@@ -7,7 +7,7 @@
#include <common/amount.h>
#include <common/htlc_state.h>
#include <common/sphinx.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
/* We look up HTLCs by channel & id */
struct htlc_key {

View File

@@ -7,7 +7,7 @@
#include <common/amount.h>
#include <common/pseudorand.h>
#include <common/utils.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct htlc_in;
struct lightningd;

View File

@@ -1,7 +1,7 @@
#ifndef LIGHTNING_LIGHTNINGD_INVOICE_H
#define LIGHTNING_LIGHTNINGD_INVOICE_H
#include "config.h"
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct amount_msat;
struct htlc_set;

View File

@@ -17,7 +17,7 @@
#include <lightningd/pay.h>
#include <lightningd/plugin.h>
#include <wallet/wallet.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct onionreply;

View File

@@ -58,7 +58,7 @@
#include <unistd.h>
#include <wally_bip32.h>
#include <wire/common_wiregen.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
#include <wire/wire_sync.h>
struct close_command {

View File

@@ -36,7 +36,7 @@
#include <lightningd/subd.h>
#include <onchaind/onchaind_wiregen.h>
#include <wallet/wallet.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
#include <wire/wire_sync.h>
#ifndef SUPERVERBOSE

View File

@@ -52,7 +52,6 @@
#include <wally_bip32.h>
#include <wire/common_wiregen.h>
#include <wire/peer_wire.h>
#include <wire/peer_wiregen.h>
#include <wire/wire.h>
#include <wire/wire_sync.h>

View File

@@ -82,7 +82,7 @@ PLUGIN_COMMON_OBJS := \
common/version.o \
common/wireaddr.o \
wire/fromwire.o \
wire/onion_wiregen.o \
wire/onion$(EXP)_wiregen.o \
wire/tlvstream.o \
wire/towire.o
@@ -95,7 +95,7 @@ plugins/fundchannel: common/addr.o $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS)
plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)
plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion_wiregen.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)
plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion$(EXP)_wiregen.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)
$(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER)
$(PLUGIN_ALL_OBJS): $(PLUGIN_LIB_HEADER)

View File

@@ -3,7 +3,7 @@
#include <ccan/tal/str/str.h>
#include <plugins/libplugin-pay.h>
#include <plugins/libplugin.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
#define PREIMAGE_TLV_TYPE 5482373484
#define KEYSEND_FEATUREBIT 55

View File

@@ -4,7 +4,7 @@
#include <common/bolt11.h>
#include <plugins/libplugin.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct legacy_payload {
struct short_channel_id scid;

View File

@@ -42,7 +42,7 @@ tools/test/gen_test.c.tmp.c: $(TOOLS_WIRE_DEPS)
tools/test/gen_test.c: tools/test/gen_test.c.tmp.c $(EXTERNAL_HEADERS) tools/test/gen_test.h
@MAKE=$(MAKE) tools/update-mocks.sh "$<" $(SUPPRESS_OUTPUT) && mv "$<" "$@"
tools/test/gen_print.h: wire/onion_wiregen.h $(TOOLS_WIRE_DEPS)
tools/test/gen_print.h: wire/onion$(EXP)_wiregen.h $(TOOLS_WIRE_DEPS)
$(BOLT_GEN) -P --page header $@ test_type < tools/test/test_cases > $@
tools/test/gen_print.c: $(TOOLS_WIRE_DEPS)

View File

@@ -20,7 +20,7 @@
#include <lightningd/log.h>
#include <onchaind/onchaind_wire.h>
#include <wally_bip32.h>
#include <wire/onion_wiregen.h>
#include <wire/onion_wire.h>
struct amount_msat;
struct invoices;

View File

@@ -2,15 +2,16 @@
WIRE_HEADERS := wire/onion_defs.h \
wire/peer_wire.h \
wire/onion_wire.h \
wire/tlvstream.h \
wire/wire.h \
wire/wire_sync.h \
wire/wire_io.h \
wire/peer_wiregen.h \
wire/onion_wiregen.h \
wire/peer$(EXP)_wiregen.h \
wire/onion$(EXP)_wiregen.h \
wire/common_wiregen.h \
wire/peer_printgen.h \
wire/onion_printgen.h
wire/peer$(EXP)_printgen.h \
wire/onion$(EXP)_printgen.h
# We don't include peer_printgen/onion_printgen here since most don't need it.
WIRE_SRC := wire/wire_sync.c \
@@ -20,12 +21,12 @@ WIRE_SRC := wire/wire_sync.c \
wire/tlvstream.c \
wire/towire.c \
wire/common_wiregen.c \
wire/peer_wiregen.c \
wire/onion_wiregen.c
wire/peer$(EXP)_wiregen.c \
wire/onion$(EXP)_wiregen.c
WIRE_PRINT_SRC := \
wire/onion_printgen.c \
wire/peer_printgen.c
wire/onion$(EXP)_printgen.c \
wire/peer$(EXP)_printgen.c
WIRE_OBJS := $(WIRE_SRC:.c=.o)
WIRE_PRINT_OBJS := $(WIRE_PRINT_SRC:.c=.o)
@@ -61,23 +62,13 @@ ifeq ($(EXPERIMENTAL_FEATURES),1)
EXPERIMENTAL_PEER_PATCHES := $(sort $(wildcard wire/extracted_peer_experimental_*))
EXPERIMENTAL_ONION_PATCHES := $(sort $(wildcard wire/extracted_onion_experimental_*))
wire/peer_wire.csv: wire/extracted_peer_wire_csv $(EXPERIMENTAL_PEER_PATCHES)
wire/peer_exp_wire.csv: wire/peer_wire_csv $(EXPERIMENTAL_PEER_PATCHES)
@set -e; trap "rm -f $@.$$$$" 0; cp $< $@.$$$$; for exp in $(EXPERIMENTAL_PEER_PATCHES); do patch $@.$$$$ $$exp >/dev/null ; done; mv $@.$$$$ $@
wire/onion_wire.csv: wire/extracted_onion_wire_csv $(EXPERIMENTAL_ONION_PATCHES)
wire/onion_exp_wire.csv: wire/onion_wire_csv $(EXPERIMENTAL_ONION_PATCHES)
@set -e; trap "rm -f $@.$$$$" 0; cp $< $@.$$$$; for exp in $(EXPERIMENTAL_ONION_PATCHES); do patch $@.$$$$ $$exp; done >/dev/null ; mv $@.$$$$ $@
else # /* EXPERIMENTAL_FEATURES */
wire/peer_wire.csv: wire/extracted_peer_wire_csv
@cp $< $@
wire/onion_wire.csv: wire/extracted_onion_wire_csv
@cp $< $@
endif
# We (may) need to rebuild these if config changes
wire/peer_wire.csv wire/onion_wire.csv: config.vars
# 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.
@@ -90,6 +81,12 @@ wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='b
wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_payload
# 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)
maintainer-clean: wire-maintainer-clean
wire-maintainer-clean:

12
wire/onion_wire.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef LIGHTNING_WIRE_ONION_WIRE_H
#define LIGHTNING_WIRE_ONION_WIRE_H
#include "config.h"
#include <stdbool.h>
#if EXPERIMENTAL_FEATURES
#include <wire/onion_exp_wiregen.h>
#else
#include <wire/onion_wiregen.h>
#endif
#endif /* LIGHTNING_WIRE_ONION_WIRE_H */

View File

@@ -2,7 +2,12 @@
#define LIGHTNING_WIRE_PEER_WIRE_H
#include "config.h"
#include <stdbool.h>
#if EXPERIMENTAL_FEATURES
#include <wire/peer_exp_wiregen.h>
#else
#include <wire/peer_wiregen.h>
#endif
/* BOLT #1:
*

View File

@@ -21,4 +21,4 @@ $(WIRE_TEST_OBJS): $(WIRE_HEADERS) $(WIRE_SRC) $(WIRE_PRINT_SRC)
wire-tests: $(WIRE_TEST_PROGRAMS:%=unittest/%)
wire/test/run-peer-wire: wire/peer_wiregen.o common/bigsize.o
wire/test/run-peer-wire: wire/peer$(EXP)_wiregen.o common/bigsize.o

View File

@@ -14,7 +14,7 @@
#include <common/bigsize.h>
#include <bitcoin/chainparams.h>
#include <common/sphinx.h>
#include <wire/peer_wiregen.h>
#include <wire/peer_wire.h>
extern secp256k1_context *secp256k1_ctx;

View File

@@ -13,7 +13,11 @@ static const char *reason;
#include <common/bigsize.c>
#include <common/node_id.c>
#if EXPERIMENTAL_FEATURES
#include <wire/peer_exp_wiregen.c>
#else
#include <wire/peer_wiregen.c>
#endif
#include <wire/fromwire.c>
#include <wire/towire.c>