|
20 | 20 | # $ git clone https://github.com/googleapis/googleapis.git
|
21 | 21 | # $ git clone https://github.com/googleapis/discovery-artifact-manager.git
|
22 | 22 | #
|
23 |
| -# Run this script: |
| 23 | +# Run this script from the top-level google-cloud-java directory: |
24 | 24 | #
|
25 | 25 | # $ python utilities/batch_generate_apis.py PATH_TO_GOOGLEAPIS PATH_TO_DISCOVERY_ARTIFACT_MANAGER
|
26 | 26 |
|
27 | 27 | import argparse
|
28 | 28 | import os
|
| 29 | +import sys |
| 30 | +from subprocess import check_output |
29 | 31 |
|
30 | 32 | import generate_api
|
31 | 33 |
|
@@ -93,7 +95,27 @@ def generate(artman_yaml):
|
93 | 95 | generate('gapic/google/compute/artman_compute.yaml')
|
94 | 96 |
|
95 | 97 |
|
| 98 | +def verify_protoc_version(): |
| 99 | + protobuf_version_node = check_output( |
| 100 | + ['grep', '-zohr', '--include=pom.xml', |
| 101 | + '<protobuf.version>.*</protobuf.version>']) |
| 102 | + version_start_index = protobuf_version_node.find('>') + 1 |
| 103 | + version_end_index = protobuf_version_node.rfind('<') |
| 104 | + protobuf_version = protobuf_version_node[version_start_index : version_end_index].strip() |
| 105 | + |
| 106 | + # This will be something like 'libprotoc 3.6.0' |
| 107 | + protoc_version_str = check_output(['protoc', '--version']) |
| 108 | + |
| 109 | + if not (protobuf_version in protoc_version_str): |
| 110 | + sys.exit("ERROR: Local version of protoc is %s" |
| 111 | + " (see output of `which protoc`)." |
| 112 | + " Please use protoc version %s" |
| 113 | + " to match the version of protobuf-java used in this repo." |
| 114 | + % (protoc_version_str, protobuf_version)) |
| 115 | + |
| 116 | + |
96 | 117 | def main():
|
| 118 | + verify_protoc_version() |
97 | 119 | # TODO Make the docker image the default, add --local option
|
98 | 120 | parser = argparse.ArgumentParser(description='Batch generate all APIs.')
|
99 | 121 | parser.add_argument('googleapis', help='The path to the googleapis repo')
|
|
0 commit comments