From f5bac832322f509946af2ece3921d48ac2c70f69 Mon Sep 17 00:00:00 2001 From: niftynei Date: Mon, 24 Jul 2023 00:43:50 -0500 Subject: [PATCH] makefile: use recursive delete to target extraneous .baks Make this a bit less difficult to see what's going on; use common variables for the paths etc. Also make the final `rm` step recursive, same as the above find step which patches the files. Files are in `contrib/pyln-grpc-proto/pyln/grpc`, but the upper level find command acts at a level above. --- Makefile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index e5aa0bc39..66c724e8e 100644 --- a/Makefile +++ b/Makefile @@ -369,22 +369,24 @@ ifneq ($(RUST),0) $(MSGGEN_GENALL)&: doc/schemas/*.request.json doc/schemas/*.schema.json PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py +# The compiler assumes that the proto files are in the same +# directory structure as the generated files will be. Since we +# don't do that we need to path the files up. +GRPC_DIR = contrib/pyln-grpc-proto/pyln +GRPC_PATH = $(GRPC_DIR)/grpc + GRPC_GEN = \ - contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py \ - contrib/pyln-grpc-proto/pyln/grpc/node_pb2_grpc.py \ - contrib/pyln-grpc-proto/pyln/grpc/primitives_pb2.py + $(GRPC_PATH)/node_pb2.py \ + $(GRPC_PATH)/node_pb2_grpc.py \ + $(GRPC_PATH)/primitives_pb2.py ALL_TEST_GEN += $(GRPC_GEN) $(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-grpc-proto/pyln/grpc/ --grpc_python_out=contrib/pyln-grpc-proto/pyln/grpc/ --experimental_allow_proto3_optional - python -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/primitives.proto --python_out=contrib/pyln-grpc-proto/pyln/grpc/ --experimental_allow_proto3_optional - # The compiler assumes that the proto files are in the same - # directory structure as the generated files will be. Since we - # don't do that we need to path the files up. - find contrib/pyln-grpc-proto/pyln/ -type f -name "*.py" -print0 | xargs -0 sed -i'.bak' -e 's/^import \(.*\)_pb2 as .*__pb2/from pyln.grpc import \1_pb2 as \1__pb2/g' - rm -f contrib/pyln-grpc-proto/pyln/*.py.bak - + python -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/node.proto --python_out=$(GRPC_PATH)/ --grpc_python_out=$(GRPC_PATH)/ --experimental_allow_proto3_optional + python -m grpc_tools.protoc -I cln-grpc/proto cln-grpc/proto/primitives.proto --python_out=$(GRPC_PATH)/ --experimental_allow_proto3_optional + find $(GRPC_DIR)/ -type f -name "*.py" -print0 | xargs -0 sed -i'.bak' -e 's/^import \(.*\)_pb2 as .*__pb2/from pyln.grpc import \1_pb2 as \1__pb2/g' + find $(GRPC_DIR)/ -type f -name "*.py.bak" -delete endif # We make pretty much everything depend on these.