Merge pull request #190 from haberman/style

Some minor style fixes.
pull/13171/head
Joshua Haberman 5 years ago committed by GitHub
commit 21cef48fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      bazel/build_defs.bzl
  2. 14
      bazel/upb_proto_library.bzl

@ -1,6 +1,6 @@
"""Internal rules for building upb."""
load(":upb_proto_library.bzl", "GeneratedSrcs")
load(":upb_proto_library.bzl", "GeneratedSrcsInfo")
def _librule(name):
return name + "_lib"
@ -173,8 +173,8 @@ SrcList = provider(
)
def _file_list_aspect_impl(target, ctx):
if GeneratedSrcs in target:
srcs = target[GeneratedSrcs]
if GeneratedSrcsInfo in target:
srcs = target[GeneratedSrcsInfo]
return [SrcList(srcs = srcs.srcs + srcs.hdrs)]
srcs = []

@ -134,7 +134,7 @@ def _cc_library_func(ctx, name, hdrs, srcs, dep_ccinfos):
# upb_proto_library / upb_proto_reflection_library shared code #################
GeneratedSrcs = provider(
GeneratedSrcsInfo = provider(
fields = {
"srcs": "list of srcs",
"hdrs": "list of hdrs",
@ -142,7 +142,7 @@ GeneratedSrcs = provider(
)
_WrappedCcInfo = provider(fields = ["cc_info"])
_WrappedGeneratedSrcs = provider(fields = ["srcs"])
_WrappedGeneratedSrcsInfo = provider(fields = ["srcs"])
def _compile_upb_protos(ctx, proto_info, proto_sources, ext):
srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources]
@ -164,17 +164,17 @@ def _compile_upb_protos(ctx, proto_info, proto_sources, ext):
[_get_real_short_path(file) for file in proto_sources],
progress_message = "Generating upb protos for :" + ctx.label.name,
)
return GeneratedSrcs(srcs = srcs, hdrs = hdrs)
return GeneratedSrcsInfo(srcs = srcs, hdrs = hdrs)
def _upb_proto_rule_impl(ctx):
if len(ctx.attr.deps) != 1:
fail("only one deps dependency allowed.")
dep = ctx.attr.deps[0]
if _WrappedCcInfo not in dep or _WrappedGeneratedSrcs not in dep:
if _WrappedCcInfo not in dep or _WrappedGeneratedSrcsInfo not in dep:
fail("proto_library rule must generate _WrappedCcInfo and " +
"_WrappedGeneratedSrcs (aspect should have handled this).")
"_WrappedGeneratedSrcsInfo (aspect should have handled this).")
cc_info = dep[_WrappedCcInfo].cc_info
srcs = dep[_WrappedGeneratedSrcs].srcs
srcs = dep[_WrappedGeneratedSrcsInfo].srcs
lib = cc_info.linking_context.libraries_to_link.to_list()[0]
files = _filter_none([
lib.static_library,
@ -200,7 +200,7 @@ def _upb_proto_aspect_impl(target, ctx):
srcs = files.srcs,
dep_ccinfos = dep_ccinfos,
)
return [_WrappedCcInfo(cc_info = cc_info), _WrappedGeneratedSrcs(srcs = files)]
return [_WrappedCcInfo(cc_info = cc_info), _WrappedGeneratedSrcsInfo(srcs = files)]
def _maybe_add(d):
if not _is_bazel:

Loading…
Cancel
Save