def _execute_proto_codegen(self, language, src_proto_path, import_proto_path, pkg_dir, api_name, api_version, organization_name, toolkit_path, gapic_api_yaml, gen_proto=False, gen_grpc=False, final_src_proto_path=None, final_import_proto_path=None, excluded_proto_path=[]): gapic_api_yaml = gapic_api_yaml[0] if gapic_api_yaml else None src_proto_path = final_src_proto_path or src_proto_path import_proto_path = final_import_proto_path or import_proto_path proto_params = protoc_utils.PROTO_PARAMS_MAP[language] if gen_proto: protoc_proto_params = protoc_utils.protoc_proto_params( proto_params, pkg_dir, gapic_api_yaml, with_grpc=True) else: protoc_proto_params = [] if gen_grpc: protoc_grpc_params = protoc_utils.protoc_grpc_params( proto_params, pkg_dir, toolkit_path) else: protoc_grpc_params = [] # protoc-gen-go has some peculiarities: # It can only compile one package per invocation. So, we need to split # proto files by packages. # # The order of the input files affects comments and internal variables. # While this doesn't affect the correctness of the result, we sort # proto files for reproducibility. # # Other languages don't mind us doing this, so we just do it for # everyone. for (dirname, protos) in protoc_utils.group_by_dirname( protoc_utils.find_protos(src_proto_path, excluded_proto_path)).items(): # It is possible to get duplicate protos. De-dupe them. protos = sorted(set(protos)) # Execute protoc. self.exec_command(proto_params.proto_compiler_command + protoc_utils.protoc_header_params( import_proto_path + src_proto_path, toolkit_path) + protoc_proto_params + protoc_grpc_params + protos) return pkg_dir
def _execute_proto_codegen( self, language, src_proto_path, import_proto_path, pkg_dir, api_name, api_version, organization_name, toolkit_path, gapic_api_yaml, gen_proto=False, gen_grpc=False, final_src_proto_path=None, final_import_proto_path=None, excluded_proto_path=[]): gapic_api_yaml = gapic_api_yaml[0] if gapic_api_yaml else None src_proto_path = final_src_proto_path or src_proto_path import_proto_path = final_import_proto_path or import_proto_path proto_params = protoc_utils.PROTO_PARAMS_MAP[language] if gen_proto: protoc_proto_params = protoc_utils.protoc_proto_params( proto_params, pkg_dir, gapic_api_yaml, with_grpc=True) else: protoc_proto_params = [] if gen_grpc: protoc_grpc_params = protoc_utils.protoc_grpc_params( proto_params, pkg_dir, toolkit_path) else: protoc_grpc_params = [] # protoc-gen-go has some peculiarities: # It can only compile one package per invocation. So, we need to split # proto files by packages. # # The order of the input files affects comments and internal variables. # While this doesn't affect the correctness of the result, we sort # proto files for reproducibility. # # Other languages don't mind us doing this, so we just do it for # everyone. for (dirname, protos) in protoc_utils.group_by_dirname( protoc_utils.find_protos(src_proto_path, excluded_proto_path)).items(): # It is possible to get duplicate protos. De-dupe them. protos = sorted(set(protos)) # Execute protoc. self.exec_command(proto_params.proto_compiler_command + protoc_utils.protoc_header_params( import_proto_path + src_proto_path, toolkit_path) + protoc_proto_params + protoc_grpc_params + protos) return pkg_dir
def _execute_proto_codegen(self, language, src_proto_path, import_proto_path, pkg_dir, api_name, api_version, organization_name, toolkit_path, gapic_api_yaml, gen_proto=False, gen_grpc=False, final_src_proto_path=None, final_import_proto_path=None, excluded_proto_path=[]): gapic_api_yaml = gapic_api_yaml[0] if gapic_api_yaml else None src_proto_path = final_src_proto_path or src_proto_path import_proto_path = final_import_proto_path or import_proto_path proto_params = protoc_utils.PROTO_PARAMS_MAP[language] if gen_proto: protoc_proto_params = protoc_utils.protoc_proto_params( proto_params, pkg_dir, gapic_api_yaml, with_grpc=True) else: protoc_proto_params = [] if gen_grpc: protoc_grpc_params = protoc_utils.protoc_grpc_params( proto_params, pkg_dir, toolkit_path) else: protoc_grpc_params = [] # protoc-gen-go must compile all protos in a package at the same # time, and *only* the protos in that package. This doesn't break # other languages, so we do it that way for all of them. for (dirname, protos) in protoc_utils.group_by_dirname( protoc_utils.find_protos(src_proto_path, excluded_proto_path)).items(): self.exec_command(proto_params.proto_compiler_command + protoc_utils.protoc_header_params( import_proto_path + src_proto_path, toolkit_path) + protoc_proto_params + protoc_grpc_params + protos) return pkg_dir