Skip to content

Commit

Permalink
Add native call to Starlark proto_common.declare_generated_files to P…
Browse files Browse the repository at this point in the history
…rotoCommon.

PiperOrigin-RevId: 441097695
  • Loading branch information
comius authored and copybara-github committed Apr 12, 2022
1 parent e45fb7a commit 8864578
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,29 @@ public static void checkPrivateStarlarkificationAllowlist(StarlarkThread thread)
}
}

public static ImmutableList<Artifact> declareGeneratedFiles(
RuleContext ruleContext, ConfiguredTarget protoTarget, String extension)
throws RuleErrorException, InterruptedException {
StarlarkFunction declareGeneratedFiles =
(StarlarkFunction)
ruleContext.getStarlarkDefinedBuiltin("proto_common_declare_generated_files");
ruleContext.initStarlarkRuleContext();
Sequence<?> outputs =
(Sequence<?>)
ruleContext.callStarlarkOrThrowRuleError(
declareGeneratedFiles,
ImmutableList.of(
/* actions */ ruleContext.getStarlarkRuleContext().actions(),
/* proto_library_target */ protoTarget,
/* extension */ extension),
ImmutableMap.of());
try {
return Sequence.cast(outputs, Artifact.class, "declare_generated_files").getImmutableList();
} catch (EvalException e) {
throw new RuleErrorException(e.getMessageWithStack());
}
}

public static void compile(
RuleContext ruleContext,
ConfiguredTarget protoTarget,
Expand Down
1 change: 1 addition & 0 deletions src/main/starlark/builtins_bzl/common/exports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ exported_rules = {
exported_to_java = {
"register_compile_and_archive_actions_for_j2objc": compilation_support.register_compile_and_archive_actions_for_j2objc,
"proto_common_compile": proto_common_do_not_use.compile,
"proto_common_declare_generated_files": proto_common_do_not_use.declare_generated_files,
"proto_common_experimental_should_generate_code": proto_common_do_not_use.experimental_should_generate_code,
"proto_common_experimental_filter_sources": proto_common_do_not_use.experimental_filter_sources,
"link_multi_arch_static_library": linking_support.link_multi_arch_static_library,
Expand Down

0 comments on commit 8864578

Please sign in to comment.