|
1 | 1 | GENERATED_DIR=$(shell pwd)/generated_python |
2 | | -FINAL_DIR=gcloud/bigtable/_generated |
| 2 | +FINAL_DIR=$(shell pwd)/gcloud/bigtable/_generated |
3 | 3 | GRPC_PLUGIN=grpc_python_plugin |
| 4 | +PROTOC_CMD=protoc |
| 5 | +PROTOS_DIR=$(shell pwd)/cloud-bigtable-client/bigtable-protos/src/main/proto |
4 | 6 |
|
5 | 7 | help: |
6 | 8 | @echo 'Makefile for gcloud-python Bigtable protos ' |
@@ -13,59 +15,54 @@ generate: |
13 | 15 | [ -d cloud-bigtable-client ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client |
14 | 16 | cd cloud-bigtable-client && git pull origin master |
15 | 17 | mkdir -p $(GENERATED_DIR) |
16 | | - # Data API |
17 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
18 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
19 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) google/bigtable/v1/*.proto |
20 | | - mv $(GENERATED_DIR)/google/bigtable/v1/* $(FINAL_DIR) |
21 | | - # Cluster API |
22 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
23 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
| 18 | + # Generate all *_pb2.py files. |
| 19 | + $(PROTOC_CMD) \ |
| 20 | + --proto_path=$(PROTOS_DIR) \ |
24 | 21 | --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
25 | | - google/bigtable/admin/cluster/v1/*.proto |
| 22 | + --python_out=$(GENERATED_DIR) \ |
| 23 | + --grpc_out=$(GENERATED_DIR) \ |
| 24 | + $(PROTOS_DIR)/google/bigtable/v1/*.proto \ |
| 25 | + $(PROTOS_DIR)/google/bigtable/admin/cluster/v1/*.proto \ |
| 26 | + $(PROTOS_DIR)/google/bigtable/admin/table/v1/*.proto \ |
| 27 | + $(PROTOS_DIR)/google/api/*.proto \ |
| 28 | + $(PROTOS_DIR)/google/protobuf/any.proto \ |
| 29 | + $(PROTOS_DIR)/google/protobuf/duration.proto \ |
| 30 | + $(PROTOS_DIR)/google/protobuf/empty.proto \ |
| 31 | + $(PROTOS_DIR)/google/protobuf/timestamp.proto \ |
| 32 | + $(PROTOS_DIR)/google/longrunning/operations.proto \ |
| 33 | + $(PROTOS_DIR)/google/rpc/status.proto |
| 34 | + # Move the newly generated *_pb2.py files into our library. |
| 35 | + mv $(GENERATED_DIR)/google/bigtable/v1/* $(FINAL_DIR) |
26 | 36 | mv $(GENERATED_DIR)/google/bigtable/admin/cluster/v1/* $(FINAL_DIR) |
27 | | - # Table API |
28 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
29 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
30 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
31 | | - google/bigtable/admin/table/v1/*.proto |
32 | 37 | mv $(GENERATED_DIR)/google/bigtable/admin/table/v1/* $(FINAL_DIR) |
33 | | - # Auxiliary protos |
34 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
35 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
36 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
37 | | - google/api/*.proto |
38 | 38 | mv $(GENERATED_DIR)/google/api/* $(FINAL_DIR) |
39 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
40 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
41 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
42 | | - google/protobuf/any.proto |
43 | 39 | mv $(GENERATED_DIR)/google/protobuf/any_pb2.py $(FINAL_DIR) |
44 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
45 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
46 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
47 | | - google/protobuf/duration.proto |
48 | 40 | mv $(GENERATED_DIR)/google/protobuf/duration_pb2.py $(FINAL_DIR) |
49 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
50 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
51 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
52 | | - google/protobuf/empty.proto |
53 | 41 | mv $(GENERATED_DIR)/google/protobuf/empty_pb2.py $(FINAL_DIR) |
54 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
55 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
56 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
57 | | - google/protobuf/timestamp.proto |
58 | 42 | mv $(GENERATED_DIR)/google/protobuf/timestamp_pb2.py $(FINAL_DIR) |
59 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
60 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
61 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
62 | | - google/longrunning/operations.proto |
63 | 43 | mv $(GENERATED_DIR)/google/longrunning/operations_pb2.py $(FINAL_DIR) |
64 | | - cd cloud-bigtable-client/bigtable-protos/src/main/proto && \ |
65 | | - protoc --python_out=$(GENERATED_DIR) --grpc_out=$(GENERATED_DIR) \ |
66 | | - --plugin=protoc-gen-grpc=$(GRPC_PLUGIN) \ |
67 | | - google/rpc/status.proto |
68 | 44 | mv $(GENERATED_DIR)/google/rpc/status_pb2.py $(FINAL_DIR) |
| 45 | + # Remove all existing *.proto files before we replace |
| 46 | + rm -f $(FINAL_DIR)/*.proto |
| 47 | + # Copy over the *.proto files into our library. |
| 48 | + cp $(PROTOS_DIR)/google/bigtable/v1/*.proto $(FINAL_DIR) |
| 49 | + cp $(PROTOS_DIR)/google/bigtable/admin/cluster/v1/*.proto $(FINAL_DIR) |
| 50 | + cp $(PROTOS_DIR)/google/bigtable/admin/table/v1/*.proto $(FINAL_DIR) |
| 51 | + cp $(PROTOS_DIR)/google/api/*.proto $(FINAL_DIR) |
| 52 | + cp $(PROTOS_DIR)/google/protobuf/any.proto $(FINAL_DIR) |
| 53 | + cp $(PROTOS_DIR)/google/protobuf/duration.proto $(FINAL_DIR) |
| 54 | + cp $(PROTOS_DIR)/google/protobuf/empty.proto $(FINAL_DIR) |
| 55 | + cp $(PROTOS_DIR)/google/protobuf/timestamp.proto $(FINAL_DIR) |
| 56 | + cp $(PROTOS_DIR)/google/longrunning/operations.proto $(FINAL_DIR) |
| 57 | + cp $(PROTOS_DIR)/google/rpc/status.proto $(FINAL_DIR) |
| 58 | + # Rename all *.proto files in our library with an |
| 59 | + # underscore and remove executable bit. |
| 60 | + cd $(FINAL_DIR) && \ |
| 61 | + for filename in *.proto; do \ |
| 62 | + chmod -x $$filename ; \ |
| 63 | + mv $$filename _$$filename ; \ |
| 64 | + done |
| 65 | + # Rewrite the imports in the generated *_pb2.py files. |
69 | 66 | python scripts/rewrite_imports.py |
70 | 67 |
|
71 | 68 | check_generate: |
|