def _execute(self, api_name, api_version, organization_name, toolkit, descriptor_set, src_proto_path, service_yaml, input_dir, output_dir, package_metadata_yaml, language, artifact_type): toolkit_path = toolkit api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) proto_prefix = self._get_proto_prefix() pkg_dir = os.path.join( output_dir, language, proto_prefix + api_full_name) service_args = ['--service_yaml=' + os.path.abspath(yaml) for yaml in service_yaml] args = [ '--descriptor_set=' + os.path.abspath(descriptor_set), '--input=' + os.path.abspath(input_dir), '--output=' + os.path.abspath(pkg_dir), '--package_yaml2=' + os.path.abspath(package_metadata_yaml), '--artifact_type=' + artifact_type, '--language=' + language, ] + service_args self.exec_command(task_utils.gradle_task( toolkit_path, 'runGrpcMetadataGen', args)) return pkg_dir
def execute(self, src_proto_path, import_proto_path, output_dir, api_name, api_version, organization_name, toolkit_path, desc_proto_path=None, excluded_proto_path=[]): desc_proto_path = desc_proto_path or [] desc_protos = list( protoc_utils.find_protos(src_proto_path + desc_proto_path, excluded_proto_path)) header_proto_path = import_proto_path + desc_proto_path header_proto_path.extend(src_proto_path) desc_out_file = task_utils.api_full_name(api_name, api_version, organization_name) + '.desc' logger.info('Compiling descriptors for {0}'.format(desc_protos)) self.exec_command(['mkdir', '-p', output_dir]) # DescGen don't use _group_by_dirname right now because # - it doesn't have to # - and multiple invocation will overwrite the desc_out_file self.exec_command( ['protoc'] + protoc_utils.protoc_header_params( header_proto_path, toolkit_path) + protoc_utils.protoc_desc_params(output_dir, desc_out_file) + desc_protos) return os.path.join(output_dir, desc_out_file)
def execute(self, language, api_name, api_version, organization_name, output_dir, src_proto_path, import_proto_path, packman_flags=None, remote_repo_dir=None, final_src_proto_path=None, final_import_proto_path=None): src_proto_path = final_src_proto_path or src_proto_path import_proto_path = final_import_proto_path or import_proto_path packman_flags = packman_flags or [] api_name_arg = task_utils.packman_api_name( task_utils.api_full_name(api_name, api_version, organization_name)) pkg_dir = protoc_utils.pkg_root_dir(output_dir, api_name, api_version, organization_name, language) arg_list = [ language, api_name_arg, '-o', pkg_dir, '--package_prefix', 'grpc-' ] # Import path must be absolute. See # https://github.com/googleapis/packman/issues/1 import_proto_path = [os.path.abspath(imp) for imp in import_proto_path] arg_list += [arg for imp in import_proto_path for arg in ('-i', imp)] arg_list += [arg for src in src_proto_path for arg in ('-r', src)] arg_list += packman_flags if remote_repo_dir: arg_list += ['-r', remote_repo_dir] self.run_packman(*arg_list) return os.path.join(pkg_dir, language)
def execute(self, api_name, api_version, organization_name, output_dir, proto_deps, language, root_dir, src_proto_path, gapic_api_yaml, artifact_type, release_level=None, proto_test_deps=None): api_full_name = task_utils.api_full_name(api_name, api_version, organization_name) config = self._create_config(api_name, api_version, organization_name, output_dir, proto_deps, proto_test_deps, language, root_dir, src_proto_path, gapic_api_yaml, artifact_type, release_level) package_metadata_config = os.path.join( output_dir, language + '_' + api_full_name + '_package2.yaml') self._write_yaml(config, package_metadata_config) return package_metadata_config
def execute(self, src_proto_path, import_proto_path, output_dir, api_name, api_version, organization_name, toolkit_path, root_dir, excluded_proto_path=[], proto_deps=[]): desc_proto_paths = [] for dep in proto_deps: if 'proto_path' in dep and dep['proto_path']: desc_proto_paths.append( os.path.join(root_dir, dep['proto_path'])) desc_protos = list( protoc_utils.find_protos(src_proto_path + desc_proto_paths, excluded_proto_path)) header_proto_path = import_proto_path + desc_proto_paths header_proto_path.extend(src_proto_path) desc_out_file = task_utils.api_full_name(api_name, api_version, organization_name) + '.desc' logger.debug('Compiling descriptors for {0}'.format(desc_protos)) self.exec_command(['mkdir', '-p', output_dir]) # DescGen doesn't use group protos by package right now because # - it doesn't have to # - and multiple invocation will overwrite the desc_out_file self.exec_command( ['protoc'] + protoc_utils.protoc_header_params( header_proto_path, toolkit_path) + protoc_utils.protoc_desc_params(output_dir, desc_out_file) + desc_protos) return os.path.join(output_dir, desc_out_file)
def pkg_root_dir(output_dir, api_name, api_version, organization_name, language, prefix=None): pkg_name = task_utils.api_full_name( api_name, api_version, organization_name) if prefix is not None: pkg_name = prefix + pkg_name return os.path.join(output_dir, language, pkg_name)
def _execute(self, api_name, api_version, organization_name, toolkit, descriptor_set, src_proto_path, service_yaml, input_dir, output_dir, package_metadata_yaml, language, artifact_type): toolkit_path = toolkit api_full_name = task_utils.api_full_name(api_name, api_version, organization_name) proto_prefix = self._get_proto_prefix() pkg_dir = os.path.join(output_dir, language, proto_prefix + api_full_name) service_args = [ '--service_yaml=' + os.path.abspath(yaml) for yaml in service_yaml ] args = [ '--descriptor_set=' + os.path.abspath(descriptor_set), '--input=' + os.path.abspath(input_dir), '--output=' + os.path.abspath(pkg_dir), '--metadata_config=' + os.path.abspath(package_metadata_yaml), '--artifact_type=' + artifact_type, '--language=' + language, ] + service_args self.exec_command( task_utils.gradle_task(toolkit_path, 'runGrpcMetadataGen', args)) return pkg_dir
def execute(self, src_proto_path, import_proto_path, output_dir, api_name, api_version, organization_name, toolkit_path, root_dir, excluded_proto_path=[], proto_deps=[]): desc_proto_paths = [] for dep in proto_deps: if 'proto_path' in dep and dep['proto_path']: desc_proto_paths.append(os.path.join(root_dir, dep['proto_path'])) desc_protos = list( protoc_utils.find_protos(src_proto_path + desc_proto_paths, excluded_proto_path)) header_proto_path = import_proto_path + desc_proto_paths header_proto_path.extend(src_proto_path) desc_out_file = task_utils.api_full_name( api_name, api_version, organization_name) + '.desc' logger.debug('Compiling descriptors for {0}'.format(desc_protos)) self.exec_command(['mkdir', '-p', output_dir]) # DescGen don't use _group_by_dirname right now because # - it doesn't have to # - and multiple invocation will overwrite the desc_out_file self.exec_command( ['protoc'] + protoc_utils.protoc_header_params(header_proto_path, toolkit_path) + protoc_utils.protoc_desc_params(output_dir, desc_out_file) + desc_protos) return os.path.join(output_dir, desc_out_file)
def execute(self, language, api_name, api_version, organization_name, package_dir, staging_repo_dir): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) staging_lang_api_dir = os.path.join( staging_repo_dir, language, 'grpc-' + api_full_name) return [package_dir, staging_lang_api_dir]
def execute(self, language, api_name, api_version, organization_name, output_dir, src_proto_path, import_proto_path, packman_flags=None, remote_repo_dir=None, final_src_proto_path=None, final_import_proto_path=None): src_proto_path = final_src_proto_path or src_proto_path import_proto_path = final_import_proto_path or import_proto_path packman_flags = packman_flags or [] api_name_arg = task_utils.packman_api_name( task_utils.api_full_name(api_name, api_version, organization_name)) pkg_dir = protoc_utils.pkg_root_dir( output_dir, api_name, api_version, organization_name, language) arg_list = [language, api_name_arg, '-o', pkg_dir, '--package_prefix', 'grpc-'] # Import path must be absolute. See # https://github.com/googleapis/packman/issues/1 import_proto_path = [os.path.abspath(imp) for imp in import_proto_path] arg_list += [arg for imp in import_proto_path for arg in ('-i', imp)] arg_list += [arg for src in src_proto_path for arg in ('-r', src)] arg_list += packman_flags if remote_repo_dir: arg_list += ['-r', remote_repo_dir] self.run_packman(*arg_list) return os.path.join(pkg_dir, language)
def _execute(self, api_name, api_version, organization_name, toolkit_path, descriptor_set, src_proto_path, service_yaml, input_dir, output_dir, package_metadata_yaml, language, artifact_type): api_full_name = task_utils.api_full_name(api_name, api_version, organization_name) proto_prefix = self._get_proto_prefix() pkg_dir = os.path.join(output_dir, language, proto_prefix + api_full_name) args = [ '--descriptor_set=' + os.path.abspath(descriptor_set), '--input=' + os.path.abspath(input_dir), '--output=' + os.path.abspath(pkg_dir), '--package_yaml2=' + os.path.abspath(package_metadata_yaml), '--artifact_type=' + artifact_type, '--language=' + language, ] if service_yaml: args = args + ['--service_yaml=' + os.path.abspath(service_yaml)] self.exec_command( task_utils.gapic_gen_task(toolkit_path, ['LEGACY_GRPC_PACKAGE'] + args)) return pkg_dir
def execute(self, language, api_name, api_version, organization_name, gapic_code_dir, skip_packman=False): if not skip_packman: api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) # TODO: Use TaskBase.exec_command() self.run_packman(language, task_utils.packman_api_name(api_full_name), '--gax_dir=' + gapic_code_dir, '--template_root=templates/gax') return gapic_code_dir
def execute(self, api_name, api_version, organization_name, output_dir, proto_deps, language, root_dir, src_proto_path, gapic_api_yaml, artifact_type, release_level=None, proto_test_deps=None): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) config = self._create_config( api_name, api_version, organization_name, output_dir, proto_deps, proto_test_deps, language, root_dir, src_proto_path, gapic_api_yaml, artifact_type, release_level) package_metadata_config = os.path.join( output_dir, language + '_' + api_full_name + '_package2.yaml') self._write_yaml(config, package_metadata_config) return package_metadata_config
def execute(self, src_proto_path, import_proto_path, output_dir, api_name, api_version, organization_name, toolkit_path, root_dir, excluded_proto_path=[], proto_deps=[], language='python'): desc_proto_paths = [] for dep in proto_deps: if 'proto_path' in dep and dep['proto_path']: desc_proto_paths.append( os.path.join(root_dir, dep['proto_path'])) desc_protos = list( protoc_utils.find_protos(src_proto_path + desc_proto_paths, excluded_proto_path)) header_proto_path = import_proto_path + desc_proto_paths header_proto_path.extend(src_proto_path) desc_out_file = task_utils.api_full_name(api_name, api_version, organization_name) + '.desc' logger.debug('Compiling descriptors for {0}'.format(desc_protos)) self.exec_command(['mkdir', '-p', output_dir]) proto_params = protoc_utils.PROTO_PARAMS_MAP[language] proto_compiler_command = proto_params.proto_compiler_command logger.debug( 'Using protoc command: {0}'.format(proto_compiler_command)) # DescGen doesn't use group protos by package right now because # - it doesn't have to # - and multiple invocation will overwrite the desc_out_file (common_resources_includes, common_resources_paths) = \ protoc_utils.protoc_common_resources_params(root_dir) params = proto_params.proto_compiler_command + \ common_resources_includes + \ protoc_utils.protoc_header_params(header_proto_path, toolkit_path) + \ protoc_utils.protoc_desc_params(output_dir, desc_out_file) + \ common_resources_paths + \ desc_protos self.exec_command(params) return os.path.join(output_dir, desc_out_file)
def execute(self, toolkit_path, discovery_doc, output_dir, api_name, api_version, organization_name): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) config_gen_dir = os.path.join( output_dir, api_full_name + '-config-gen') self.exec_command(['mkdir', '-p', config_gen_dir]) config_gen_path = os.path.join(config_gen_dir, api_full_name + '_gapic.yaml') args = [ '--discovery_doc=' + os.path.abspath( os.path.expanduser(discovery_doc)), '--output=' + os.path.abspath(config_gen_path) ] self.exec_command( task_utils.gradle_task(toolkit_path, 'runDiscoConfigGen', args)) return config_gen_path
def execute(self, toolkit_path, discovery_doc, output_dir, api_name, api_version, organization_name): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) config_gen_dir = os.path.join( output_dir, api_full_name + '-config-gen') self.exec_command(['mkdir', '-p', config_gen_dir]) config_gen_path = os.path.join(config_gen_dir, api_full_name + '_gapic.yaml') args = [ '--discovery_doc=' + os.path.abspath( os.path.expanduser(discovery_doc)), '--output=' + os.path.abspath(config_gen_path) ] self.exec_command( task_utils.gapic_gen_task(toolkit_path, ['DISCOGAPIC_CONFIG'] + args)) return config_gen_path
def execute(self, toolkit_path, descriptor_set, service_yaml, output_dir, api_name, api_version, organization_name): api_full_name = task_utils.api_full_name(api_name, api_version, organization_name) config_gen_dir = os.path.join(output_dir, api_full_name + '-config-gen') self.exec_command(['mkdir', '-p', config_gen_dir]) config_gen_path = os.path.join(config_gen_dir, api_full_name + '_gapic.yaml') args = [ '--descriptor_set=' + os.path.abspath(descriptor_set), '--output=' + os.path.abspath(config_gen_path), ] if service_yaml: args = args + ['--service_yaml=' + os.path.abspath(service_yaml)] self.exec_command( task_utils.gapic_gen_task(toolkit_path, ['GAPIC_CONFIG'] + args)) return config_gen_path
def execute(self, api_name, api_version, organization_name, output_dir, package_dependencies_yaml, package_defaults_yaml, proto_deps, language, root_dir, src_proto_path, package_type, gapic_api_yaml, release_level=None, packaging='single-artifact', generated_package_version=None, proto_test_deps=None): api_full_name = task_utils.api_full_name(api_name, api_version, organization_name) config = self._create_config( api_name, api_version, api_full_name, output_dir, package_dependencies_yaml, package_defaults_yaml, proto_deps, proto_test_deps, language, root_dir, src_proto_path, package_type, gapic_api_yaml, release_level=release_level, packaging=packaging, generated_package_version=generated_package_version) package_metadata_config = os.path.join(output_dir, api_full_name + '_package.yaml') self._write_yaml(config, package_metadata_config) return package_metadata_config
def execute(self, toolkit_path, descriptor_set, service_yaml, output_dir, api_name, api_version, organization_name): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) config_gen_dir = os.path.join( output_dir, api_full_name + '-config-gen') self.exec_command(['mkdir', '-p', config_gen_dir]) config_gen_path = os.path.join(config_gen_dir, api_full_name + '_gapic.yaml') service_args = ['--service_yaml=' + os.path.abspath(yaml) for yaml in service_yaml] args = [ '--descriptor_set=' + os.path.abspath(descriptor_set), '--output=' + os.path.abspath(config_gen_path) ] + service_args self.exec_command( task_utils.gradle_task(toolkit_path, 'runConfigGen', args)) return config_gen_path
def execute(self, toolkit_path, descriptor_set, service_yaml, output_dir, api_name, api_version, organization_name): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) config_gen_dir = os.path.join( output_dir, api_full_name + '-config-gen') self.exec_command(['mkdir', '-p', config_gen_dir]) config_gen_path = os.path.join(config_gen_dir, api_full_name + '_gapic.yaml') args = [ '--descriptor_set=' + os.path.abspath(descriptor_set), '--output=' + os.path.abspath(config_gen_path), ] if service_yaml: args = args + ['--service_yaml=' + os.path.abspath(service_yaml)] self.exec_command( task_utils.gapic_gen_task(toolkit_path, ['GAPIC_CONFIG'] + args)) return config_gen_path
def execute(self, api_name, api_version, organization_name, output_dir, package_dependencies_yaml, package_defaults_yaml, proto_deps, language, local_paths, src_proto_path, package_type, gapic_api_yaml, release_level=None, packaging='single-artifact', generated_package_version=None, proto_test_deps=None): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) config = self._create_config( api_name, api_version, api_full_name, output_dir, package_dependencies_yaml, package_defaults_yaml, proto_deps, proto_test_deps, language, local_paths, src_proto_path, package_type, gapic_api_yaml, release_level=release_level, packaging=packaging, generated_package_version=generated_package_version) package_metadata_config = os.path.join( output_dir, api_full_name + '_package.yaml') self._write_yaml(config, package_metadata_config) return package_metadata_config
def execute(self, language, api_name, api_version, organization_name, gapic_code_dir, staging_repo_dir): api_full_name = task_utils.api_full_name( api_name, api_version, organization_name) return [gapic_code_dir, os.path.join(staging_repo_dir, language, api_full_name)]