Makefile: use generic rules to make spec-derived sources.

Now we use the same Makefile rules for all CSV->C generation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-08-31 10:43:25 +09:30
committed by neil saitug
parent a00179d557
commit 8150d28575
74 changed files with 212 additions and 227 deletions

View File

@@ -1,5 +1,3 @@
DEVTOOLS_SRC := devtools/gen_print_wire.c devtools/gen_print_onion_wire.c devtools/print_wire.c
DEVTOOLS_OBJS := $(DEVTOOLS_SRC:.c=.o)
DEVTOOLS := devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/dump-gossipstore devtools/gossipwith devtools/create-gossipstore devtools/mkcommit devtools/mkfunding devtools/mkclose devtools/mkgossip devtools/mkencoded devtools/mkquery devtools/lightning-checkmessage devtools/topology devtools/route
ifeq ($(HAVE_SQLITE3),1)
DEVTOOLS += devtools/checkchannels
@@ -40,45 +38,31 @@ DEVTOOLS_COMMON_OBJS := \
common/utils.o \
common/version.o \
common/wireaddr.o \
wire/gen_onion_wire.o \
wire/gen_peer_wire.o
wire/onion_wiregen.o \
wire/peer_wiregen.o
devtools-all: $(DEVTOOLS)
devtools/gen_print_wire.h: $(DEVTOOL_BOLT_DEPS) wire/gen_peer_wire_csv
$(BOLT_GEN) -P -s --page header $@ wire_type < wire/gen_peer_wire_csv > $@
devtools/bolt11-cli: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o
devtools/gen_print_wire.c: $(DEVTOOL_BOLT_DEPS) wire/gen_peer_wire_csv
$(BOLT_GEN) -P -s --page impl ${@:.c=.h} wire_type < wire/gen_peer_wire_csv > $@
devtools/decodemsg: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer_printgen.o wire/onion_printgen.o devtools/print_wire.o devtools/decodemsg.o
devtools/gen_print_onion_wire.h: $(DEVTOOL_BOLT_DEPS) wire/gen_onion_wire_csv
$(BOLT_GEN) -P -s --page header $@ onion_type < wire/gen_onion_wire_csv > $@
devtools/gen_print_onion_wire.c: $(DEVTOOL_BOLT_DEPS) wire/gen_onion_wire_csv
$(BOLT_GEN) -P -s --page impl ${@:.c=.h} onion_type < wire/gen_onion_wire_csv > $@
devtools/bolt11-cli: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o
devtools/decodemsg: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/decodemsg.o
devtools/dump-gossipstore: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/dump-gossipstore.o gossipd/gossip_store_wiregen.o
devtools/dump-gossipstore: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/dump-gossipstore.o gossipd/gossip_store_wiregen.o
devtools/dump-gossipstore.o: gossipd/gossip_store_wiregen.h
devtools/create-gossipstore: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/create-gossipstore.o gossipd/gossip_store_wiregen.o
devtools/create-gossipstore: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/create-gossipstore.o gossipd/gossip_store_wiregen.o
devtools/create-gossipstore.o: gossipd/gossip_store_wiregen.h
devtools/onion.c: ccan/config.h
devtools/onion: $(DEVTOOLS_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) common/onion.o common/onionreply.o wire/fromwire.o wire/towire.o devtools/onion.o common/sphinx.o
devtools/onion: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) common/onion.o common/onionreply.o wire/fromwire.o wire/towire.o devtools/onion.o common/sphinx.o
devtools/blindedpath: $(DEVTOOLS_OBJS) $(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/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_OBJS) $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/gen_peer_wire.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_wiregen.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o common/crypto_sync.o
$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h devtools/gen_print_wire.h devtools/gen_print_onion_wire.h
devtools/gen_print_wire.o: devtools/gen_print_wire.h wire/gen_peer_wire.h devtools/print_wire.h
devtools/gen_print_onion_wire.o: devtools/gen_print_onion_wire.h devtools/print_wire.h
$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h
devtools/mkcommit: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) common/derive_basepoints.o common/keyset.o common/key_derive.o common/initial_commit_tx.o common/permute_tx.o wire/fromwire.o wire/towire.o devtools/mkcommit.o channeld/full_channel.o common/initial_channel.o common/htlc_state.o common/pseudorand.o common/htlc_tx.o channeld/commit_tx.o common/htlc_trim.o
@@ -102,11 +86,11 @@ devtools/topology: $(DEVTOOLS_COMMON_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fro
# Make sure these depend on everything.
ALL_PROGRAMS += $(DEVTOOLS)
ALL_OBJS += $(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS)
ALL_OBJS += $(DEVTOOLS_TOOL_OBJS)
check-source: $(DEVTOOLS_SRC:%=check-src-include-order/%) $(DEVTOOLS_TOOLS_SRC:%=check-src-include-order/%)
clean: devtools-clean
devtools-clean:
$(RM) $(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS) devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/gen_print_wire.[c,h,o] devtools/gen_print_onion_wire.[c,h,o]
$(RM) $(DEVTOOLS_TOOL_OBJS) $(DEVTOOLS)

View File

@@ -16,7 +16,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wire/gen_peer_wire.h>
#include <wire/peer_wiregen.h>
struct scidsat {
@@ -175,7 +175,7 @@ int main(int argc, char *argv[])
if (verbose)
fprintf(stderr, "%s\n",
wire_type_name(fromwire_peektype(inmsg)));
peer_wire_name(fromwire_peektype(inmsg)));
switch (fromwire_peektype(inmsg)) {
case WIRE_CHANNEL_ANNOUNCEMENT:
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
default:
warnx("Unknown message %u (%s)", fromwire_peektype(inmsg),
wire_type_name(fromwire_peektype(inmsg)));
peer_wire_name(fromwire_peektype(inmsg)));
tal_free(inmsg);
continue;
}

View File

@@ -3,10 +3,10 @@
#include <ccan/tal/grab_file/grab_file.h>
#include <common/decode_array.h>
#include <common/utils.h>
#include <devtools/gen_print_onion_wire.h>
#include <devtools/gen_print_wire.h>
#include <stdio.h>
#include <unistd.h>
#include <wire/onion_printgen.h>
#include <wire/peer_printgen.h>
int main(int argc, char *argv[])
{
@@ -37,13 +37,13 @@ int main(int argc, char *argv[])
if (onion)
if (tlv_name)
printonion_type_tlv_message(tlv_name, m);
printonion_wire_tlv_message(tlv_name, m);
else
printonion_type_message(m);
printonion_wire_message(m);
else if (tlv_name)
printwire_type_tlv_message(tlv_name, m);
printpeer_wire_tlv_message(tlv_name, m);
else
printwire_type_message(m);
printpeer_wire_message(m);
} else {
u8 *f = grab_fd(NULL, STDIN_FILENO);
size_t off = 0;
@@ -64,13 +64,13 @@ int main(int argc, char *argv[])
m = tal_dup_arr(f, u8, f + off, be16_to_cpu(len), 0);
if (onion)
if (tlv_name)
printonion_type_tlv_message(tlv_name, m);
printonion_wire_tlv_message(tlv_name, m);
else
printonion_type_message(m);
printonion_wire_message(m);
else if (tlv_name)
printwire_type_tlv_message(tlv_name, m);
printpeer_wire_tlv_message(tlv_name, m);
else
printwire_type_message(m);
printpeer_wire_message(m);
off += be16_to_cpu(len);
tal_free(m);
}

View File

@@ -12,7 +12,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <wire/gen_peer_wire.h>
#include <wire/peer_wiregen.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/gen_peer_wire.h>
#include <wire/peer_wiregen.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/gen_peer_wire.h>
#include <wire/peer_wiregen.h>
#include <stdio.h>
static void usage(void)

View File

@@ -124,7 +124,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion,
struct privkey seckey;
struct route_step *step;
struct onionpacket packet;
enum onion_type why_bad;
enum onion_wire why_bad;
struct secret shared_secret;
if (!hex_decode(hexprivkey, strlen(hexprivkey), &seckey, sizeof(seckey)))
errx(1, "Invalid private key hex '%s'", hexprivkey);
@@ -132,7 +132,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion,
why_bad = parse_onionpacket(onion, TOTAL_PACKET_SIZE, &packet);
if (why_bad != 0)
errx(1, "Error parsing message: %s", onion_type_name(why_bad));
errx(1, "Error parsing message: %s", onion_wire_name(why_bad));
if (!onion_shared_secret(&shared_secret, &packet, &seckey))
errx(1, "Error creating shared secret.");

View File

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