rules_proto_grpc/objc/objc_proto_library.bzl

60 lines
1.6 KiB
Python

"""Generated definition of objc_proto_library."""
load("//objc:objc_proto_compile.bzl", "objc_proto_compile")
load("//:defs.bzl", "bazel_build_rule_common_attrs", "filter_files", "proto_compile_attrs")
load("@rules_cc//cc:defs.bzl", "objc_library")
def objc_proto_library(name, **kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = name + "_pb"
objc_proto_compile(
name = name_pb,
**{
k: v
for (k, v) in kwargs.items()
if k in proto_compile_attrs.keys() or
k in bazel_build_rule_common_attrs
} # Forward args
)
# Filter files to sources and headers
filter_files(
name = name_pb + "_srcs",
target = name_pb,
extensions = ["m"],
)
filter_files(
name = name_pb + "_hdrs",
target = name_pb,
extensions = ["h"],
)
# Create objc library
objc_library(
name = name,
srcs = [name_pb + "_srcs"],
deps = PROTO_DEPS + kwargs.get("deps", []),
hdrs = [name_pb + "_hdrs"],
includes = [name_pb],
**{
k: v
for (k, v) in kwargs.items()
if k in bazel_build_rule_common_attrs + [
"alwayslink",
"copts",
"defines",
"include_prefix",
"linkopts",
"linkstatic",
"local_defines",
"nocopts",
"strip_include_prefix",
]
}
)
PROTO_DEPS = [
"@com_google_protobuf//:protobuf_objc",
]