1 Star 0 Fork 1

Mmagic/srpc

forked from mirrors/srpc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
srpc.bzl 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
"""
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,
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hust-miao/srpc.git
[email protected]:hust-miao/srpc.git
hust-miao
srpc
srpc
master

搜索帮助