代码拉取完成,页面将自动刷新
"""
Rules for building C++ srpc with Bazel.
"""
load("@rules_cc//cc:defs.bzl", "cc_library")
tool_path = ":srpc_generator"
def srpc_cc_library(
name,
srcs,
deps = [],
type = "proto",
out_prefix = "",
visibility = None):
output_directory = (
("$(@D)/%s" % (out_prefix)) if len(srcs) > 1 else ("$(@D)")
)
proto_output_headers = [
(out_prefix + "%s.srpc.h") % (s.replace(".%s" % type, "").split("/")[-1])
for s in srcs
]
thrift_output_headers = [
(out_prefix + "%s.thrift.h") % (s.replace(".%s" % type, "").split("/")[-1])
for s in srcs
]
if type == "thrift":
output_headers = proto_output_headers + thrift_output_headers
gen_proto = "thrift"
if type == "proto":
output_headers = proto_output_headers
gen_proto = "protobuf"
genrule_cmd = " ".join([
"SRCS=($(SRCS));",
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
"$(location %s)" % (tool_path),
" %s " % gen_proto,
"$$f",
output_directory + ";",
"done",
])
srcs_lib = "%s_srcs" % (name)
native.genrule(
name = srcs_lib,
srcs = srcs,
outs = output_headers,
tools = [tool_path],
cmd = genrule_cmd,
output_to_bindir = True,
message = "Generating srpc files for %s:" % (name),
)
runtime_deps = deps + [":libsrpc"]
print(runtime_deps)
cc_library(
name = name,
hdrs = [
":" + srcs_lib,
],
srcs = [
":" + srcs_lib,
],
features = [
"-parse_headers",
],
deps = runtime_deps,
includes = [],
linkstatic = 1,
visibility = visibility,
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。