11GENERATED_DIR=$(shell pwd)/generated_python
2- BIGTABLE_DIR = $( shell pwd) /gcloud/bigtable/ _generated
3- DATASTORE_DIR =$(shell pwd) /gcloud/datastore/_generated
2+ GENERATED_SUBDIR= _generated
3+ BIGTABLE_DIR =$(shell pwd)/gcloud/bigtable/$(GENERATED_SUBDIR)
44GRPC_PLUGIN=grpc_python_plugin
55PROTOC_CMD=protoc
6- BIGTABLE_PROTOS_DIR =$(shell pwd) /cloud-bigtable-client/bigtable-protos/src/main/proto
6+ BIGTABLE_CHECKOUT_DIR=$(shell pwd)/cloud-bigtable-client
7+ BIGTABLE_PROTOS_DIR=$(BIGTABLE_CHECKOUT_DIR)/bigtable-protos/src/main/proto
78GOOGLEAPIS_PROTOS_DIR=$(shell pwd)/googleapis-pb
89
910help:
1516
1617generate:
1718 # Retrieve git repos that have our *.proto files.
18- [ -d cloud-bigtable-client ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client --depth=1
19- cd cloud-bigtable-client && git pull origin master
19+ [ -d $(BIGTABLE_CHECKOUT_DIR) ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client --depth=1
20+ cd $(BIGTABLE_CHECKOUT_DIR) && git pull origin master
2021 [ -d googleapis-pb ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
2122 cd googleapis-pb && git pull origin master
2223 # Make the directory where our *_pb2.py files will go.
@@ -41,49 +42,37 @@ generate:
4142 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/cluster/v1/bigtable_cluster_service_messages.proto \
4243 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_data.proto \
4344 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_service_messages.proto \
44- $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/datastore.proto \
45- $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/entity.proto \
46- $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/query.proto
4745 # Move the newly generated *_pb2.py files into our library.
48- mv $(GENERATED_DIR ) /google/bigtable/v1/* $(BIGTABLE_DIR )
49- mv $(GENERATED_DIR ) /google/bigtable/admin/cluster/v1/* $(BIGTABLE_DIR )
50- mv $(GENERATED_DIR ) /google/bigtable/admin/table/v1/* $(BIGTABLE_DIR )
51- mv $(GENERATED_DIR ) /google/datastore/v1beta3/* $(DATASTORE_DIR )
46+ cp $(GENERATED_DIR)/google/bigtable/v1/* $(BIGTABLE_DIR)
47+ cp $(GENERATED_DIR)/google/bigtable/admin/cluster/v1/* $(BIGTABLE_DIR)
48+ cp $(GENERATED_DIR)/google/bigtable/admin/table/v1/* $(BIGTABLE_DIR)
5249 # Remove all existing *.proto files before we replace
5350 rm -f $(BIGTABLE_DIR)/*.proto
54- rm -f $(DATASTORE_DIR ) /* .proto
5551 # Copy over the *.proto files into our library.
5652 cp $(BIGTABLE_PROTOS_DIR)/google/bigtable/v1/*.proto $(BIGTABLE_DIR)
5753 cp $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/cluster/v1/*.proto $(BIGTABLE_DIR)
5854 cp $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/*.proto $(BIGTABLE_DIR)
5955 cp $(BIGTABLE_PROTOS_DIR)/google/longrunning/operations.proto $(BIGTABLE_DIR)
60- cp $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/* .proto $(DATASTORE_DIR )
6156 # Rename all *.proto files in our library with an
6257 # underscore and remove executable bit.
6358 cd $(BIGTABLE_DIR) && \
6459 for filename in *.proto; do \
6560 chmod -x $$filename ; \
6661 mv $$filename _$$filename ; \
6762 done
68- cd $(DATASTORE_DIR ) && \
69- for filename in * .proto; do \
70- chmod -x $$ filename ; \
71- mv $$ filename _$$ filename ; \
72- done
7363 # Separate the gRPC parts of the operations service from the
7464 # non-gRPC parts so that the protos from `googleapis-common-protos`
7565 # can be used without gRPC.
76- python scripts/make_operations_grpc.py
77- # Separate the gRPC parts of the datastore service from the
78- # non-gRPC parts so that the protos can be used without gRPC.
79- python scripts/make_datastore_grpc.py
66+ PROTOC_CMD=$(PROTOC_CMD) GRPC_PLUGIN=$(GRPC_PLUGIN) \
67+ GENERATED_SUBDIR=$(GENERATED_SUBDIR) \
68+ python scripts/make_operations_grpc.py
8069 # Rewrite the imports in the generated *_pb2.py files.
81- python scripts/rewrite_imports.py
70+ python scripts/rewrite_imports.py $(BIGTABLE_DIR)/*pb2.py
8271
8372check_generate:
8473 python scripts/check_generate.py
8574
8675clean:
87- rm -fr cloud-bigtable-client $(GENERATED_DIR )
76+ rm -fr $(BIGTABLE_CHECKOUT_DIR) $(GOOGLEAPIS_PROTOS_DIR) $(GENERATED_DIR)
8877
8978.PHONY: generate check_generate clean
0 commit comments