Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions artman/config/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def convert_to_legacy_config_dict(artifact_config, root_dir, output_dir):
if 'test_proto_deps' in artifact_config_dict:
common['test_proto_deps'] = artifact_config_dict['test_proto_deps']
common['artifact_type'] = Artifact.Type.Name(artifact_config.type)
common['language_out_override'] = artifact_config.language_out_override

result = {}
result['common'] = common
Expand Down
8 changes: 8 additions & 0 deletions artman/config/proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,12 @@ message Artifact {
}

Aspect aspect = 17;

// Override the --language_out= protoc parameter (for the given language).
// In the override string, use {root} for the output directory path.
// Examples:
// "{root}" - equals to the default value, no override
// "key=value:{root}" - passes an extra key-value pair to the protoc plugin
// (some language plugins accept that)
string language_out_override = 21;
}
95 changes: 51 additions & 44 deletions artman/config/proto/config_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 21 additions & 10 deletions artman/tasks/protoc_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ def _execute_proto_codegen(
toolkit_path, gapic_yaml, root_dir,
gen_proto=False, gen_grpc=False, gen_common_resources=False,
final_src_proto_path=None, final_import_proto_path=None,
excluded_proto_path=[]):
excluded_proto_path=[], language_out_override=None):
# Adding 17th parameter is a sin that I commit here just because
# refactoring of this code will never happen.
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_yaml, with_grpc=True)
proto_params, pkg_dir, gapic_yaml, with_grpc=True,
language_out_override=language_out_override)
else:
protoc_proto_params = []

Expand Down Expand Up @@ -151,7 +154,8 @@ class ProtoCodeGenTask(ProtocCodeGenTaskBase):
def execute(self, language, src_proto_path, import_proto_path,
output_dir, api_name, api_version, organization_name,
toolkit_path, gapic_yaml, root_dir, final_src_proto_path=None,
final_import_proto_path=None, excluded_proto_path=[]):
final_import_proto_path=None, excluded_proto_path=[],
language_out_override=None):
pkg_dir = protoc_utils.prepare_proto_pkg_dir(
output_dir, api_name, api_version, organization_name, language)
return self._execute_proto_codegen(
Expand All @@ -160,7 +164,8 @@ def execute(self, language, src_proto_path, import_proto_path,
gapic_yaml, root_dir, gen_proto=True,
final_src_proto_path=final_src_proto_path,
final_import_proto_path=final_import_proto_path,
excluded_proto_path=excluded_proto_path)
excluded_proto_path=excluded_proto_path,
language_out_override=language_out_override)

class ResourceNameGenTask(ProtocCodeGenTaskBase):
default_provides = 'proto_code_dir'
Expand All @@ -169,7 +174,8 @@ class ResourceNameGenTask(ProtocCodeGenTaskBase):
def execute(self, language, src_proto_path, import_proto_path,
output_dir, api_name, api_version, organization_name,
toolkit_path, gapic_yaml, root_dir, final_src_proto_path=None,
final_import_proto_path=None, excluded_proto_path=[]):
final_import_proto_path=None, excluded_proto_path=[],
language_out_override=None):
pkg_dir = protoc_utils.prepare_proto_pkg_dir(
output_dir, api_name, api_version, organization_name, language)
return self._execute_proto_codegen(
Expand All @@ -178,7 +184,8 @@ def execute(self, language, src_proto_path, import_proto_path,
gapic_yaml, root_dir, gen_common_resources=True,
final_src_proto_path=final_src_proto_path,
final_import_proto_path=final_import_proto_path,
excluded_proto_path=excluded_proto_path)
excluded_proto_path=excluded_proto_path,
language_out_override=language_out_override)

class GrpcCodeGenTask(ProtocCodeGenTaskBase):
default_provides = 'grpc_code_dir'
Expand All @@ -187,7 +194,8 @@ class GrpcCodeGenTask(ProtocCodeGenTaskBase):
def execute(self, language, src_proto_path, import_proto_path,
toolkit_path, output_dir, api_name, api_version,
organization_name, gapic_yaml, root_dir, final_src_proto_path=None,
final_import_proto_path=None, excluded_proto_path=[]):
final_import_proto_path=None, excluded_proto_path=[],
language_out_override=None):
pkg_dir = protoc_utils.prepare_grpc_pkg_dir(
output_dir, api_name, api_version, organization_name, language)
return self._execute_proto_codegen(
Expand All @@ -196,7 +204,8 @@ def execute(self, language, src_proto_path, import_proto_path,
gapic_yaml, root_dir, gen_grpc=True,
final_src_proto_path=final_src_proto_path,
final_import_proto_path=final_import_proto_path,
excluded_proto_path=excluded_proto_path)
excluded_proto_path=excluded_proto_path,
language_out_override=language_out_override)


class ProtoAndGrpcCodeGenTask(ProtocCodeGenTaskBase):
Expand All @@ -206,7 +215,8 @@ class ProtoAndGrpcCodeGenTask(ProtocCodeGenTaskBase):
def execute(self, language, src_proto_path, import_proto_path,
toolkit_path, output_dir, api_name, api_version,
organization_name, gapic_yaml, root_dir, final_src_proto_path=None,
final_import_proto_path=None, excluded_proto_path=[]):
final_import_proto_path=None, excluded_proto_path=[],
language_out_override=None):
pkg_dir = protoc_utils.prepare_grpc_pkg_dir(
output_dir, api_name, api_version, organization_name, language)
return self._execute_proto_codegen(
Expand All @@ -215,7 +225,8 @@ def execute(self, language, src_proto_path, import_proto_path,
gapic_yaml, root_dir, gen_proto=True, gen_grpc=True,
final_src_proto_path=final_src_proto_path,
final_import_proto_path=final_import_proto_path,
excluded_proto_path=excluded_proto_path)
excluded_proto_path=excluded_proto_path,
language_out_override=language_out_override)


class GoCopyTask(task_base.TaskBase):
Expand Down
Loading