Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: use grouped targets for recipes with multiple fixed outputs #6307

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,28 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \

# We also need a relatively recent protobuf-compiler, at least 3.12.0,
# in order to support the experimental `optional` flag.
PROTOC_VERSION=3.15.8

# BUT WAIT! Gentoo wants this to match the version from the Python protobuf,
# which comes from the same tree. Makes sense!

# And
# grpcio-tools-1.54.0` requires `protobuf = ">=4.21.6,<5.0dev"`

# Now, protoc changed to date-based releases, BUT Python protobuf
# didn't, so Python protobuf 4.21.12 (in Ubuntu 23.04) corresponds to
# protoc 21.12 (which, FYI, is packaged in Ubuntu as version 3.21.12).

# So we're going to nail these versions as 21.12, which is what recent
# Ubuntu has, and hopefully everyone else can get. And this means that
# When CI checks that no files have changed under regeneration, you won't
# get a fail just because the dev's protoc is a different version.

# Honorable mention go to Matt Whitlock for spelunking this horror with me!

PROTOC_VERSION=21.12
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
curl -LO $PB_REL/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
sudo unzip protoc-3.15.8-linux-x86_64.zip -d /usr/local/
sudo unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local/
sudo chmod a+x /usr/local/bin/protoc
export PROTOC=/usr/local/bin/protoc
export PATH=$PATH:/usr/local/bin
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ ifeq ($(HAVE_POSTGRES),1)
LDLIBS += $(POSTGRES_LDLIBS)
endif

default: show-flags all-programs all-test-programs doc-all default-targets
default: show-flags all-programs all-test-programs doc-all default-targets $(PYTHON_GENERATED)

ifneq ($(SUPPRESS_GENERATION),1)
FORCE = FORCE
Expand Down Expand Up @@ -363,13 +363,16 @@ ifneq ($(RUST),0)
include cln-rpc/Makefile
include cln-grpc/Makefile

$(MSGGEN_GENALL)&: doc/schemas/*.request.json doc/schemas/*.schema.json
PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py

GRPC_GEN = contrib/pyln-testing/pyln/testing/node_pb2.py \
contrib/pyln-testing/pyln/testing/node_pb2_grpc.py \
contrib/pyln-testing/pyln/testing/primitives_pb2.py

ALL_TEST_GEN += $(GRPC_GEN)

$(GRPC_GEN): cln-grpc/proto/node.proto cln-grpc/proto/primitives.proto
$(GRPC_GEN)&: cln-grpc/proto/node.proto cln-grpc/proto/primitives.proto
python -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/node.proto --python_out=contrib/pyln-testing/pyln/testing/ --grpc_python_out=contrib/pyln-testing/pyln/testing/ --experimental_allow_proto3_optional
python -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/primitives.proto --python_out=contrib/pyln-testing/pyln/testing/ --experimental_allow_proto3_optional
# The compiler assumes that the proto files are in the same
Expand Down Expand Up @@ -416,7 +419,7 @@ mkdocs.yml: $(MANPAGES:=.md)


# Don't delete these intermediaries.
.PRECIOUS: $(ALL_GEN_HEADERS) $(ALL_GEN_SOURCES)
.PRECIOUS: $(ALL_GEN_HEADERS) $(ALL_GEN_SOURCES) $(PYTHON_GENERATED)

# Every single object file.
ALL_OBJS := $(ALL_C_SOURCES:.c=.o)
Expand Down Expand Up @@ -686,6 +689,7 @@ default-targets: $(DEFAULT_TARGETS)

distclean: clean
$(RM) ccan/config.h config.vars
$(RM) $(PYTHON_GENERATED)

maintainer-clean: distclean
@echo 'This command is intended for maintainers to use; it'
Expand Down
3 changes: 1 addition & 2 deletions cln-grpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CLN_GRPC_GENALL = cln-grpc/proto/node.proto \

DEFAULT_TARGETS += $(CLN_GRPC_EXAMPLES) $(CLN_GRPC_GENALL)

$(CLN_GRPC_GENALL): $(JSON_SCHEMA)
PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py
MSGGEN_GENALL += $(CLN_GRPC_GENALL) contrib/pyln-testing/pyln/testing/grpc2py.py

cln-grpc-all: ${CLN_GRPC_GENALL} ${CLN_GRPC_EXAMPLES}
4 changes: 1 addition & 3 deletions cln-rpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ cln-rpc-wrongdir:
CLN_RPC_EXAMPLES := target/${RUST_PROFILE}/examples/cln-rpc-getinfo
CLN_RPC_GENALL = cln-rpc/src/model.rs
CLN_RPC_SOURCES = $(shell find cln-rpc -name *.rs) ${CLN_RPC_GENALL}
JSON_SCHEMAS = $(wildcard doc/schemas/*.request.json doc/schemas/*.schema.json)
DEFAULT_TARGETS += $(CLN_RPC_EXAMPLES) $(CLN_RPC_GENALL)

$(CLN_RPC_GENALL): $(JSON_SCHEMAS)
PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py
MSGGEN_GENALL += $(CLN_RPC_GENALL)

target/${RUST_PROFILE}/examples/cln-rpc-getinfo: $(shell find cln-rpc -name *.rs)
cargo build ${CARGO_OPTS} --example cln-rpc-getinfo
Expand Down
Loading