コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
    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)