Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed helper functions in well-known-type protos #12

Merged
merged 2 commits into from
Feb 28, 2024
Merged
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
11 changes: 9 additions & 2 deletions closure/protobuf/closure_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ def _generate_closure_js(target, ctx):
# |goog.require()| for enums.
js_out_options = [
"import_style=closure",
"library=%s" % ctx.label.name,
"add_require_for_enums",
]
# Don't add library option to well-known-types so embedded functions are added properly
if ctx.label.workspace_name == "com_google_protobuf":
# If library option is not specified, output file name is expected to match the input proto file name, not the bazel label name
# e.g. struct instead of struct_proto
out_file_name = ctx.label.name[:-len("_proto")]
else:
out_file_name = ctx.label.name
js_out_options.append("library=%s" % ctx.label.name)
if getattr(ctx.rule.attr, "testonly", False):
js_out_options.append("testonly")
js = ctx.actions.declare_file("%s.js" % ctx.label.name)
js = ctx.actions.declare_file("%s.js" % out_file_name)

# Add include paths for all proto files,
# to avoid copying/linking the files for every target.
Expand Down