third_party_rust_cxx/tools/buck/rust_cxx_bridge.bzl
徐未来 b110613bee cxx 1.0.91升级至1.0.97
Signed-off-by: 徐未来 <xuweilai2@huawei.com>
2024-04-02 19:59:25 +08:00

39 lines
1008 B
Python

def rust_cxx_bridge(
name: str.type,
src: str.type,
deps: [str.type] = []):
native.export_file(
name = "%s/header" % name,
src = ":%s/generated[generated.h]" % name,
out = src + ".h",
)
native.export_file(
name = "%s/source" % name,
src = ":%s/generated[generated.cc]" % name,
out = src + ".cc",
)
native.genrule(
name = "%s/generated" % name,
srcs = [src],
outs = {
"generated.cc": ["generated.cc"],
"generated.h": ["generated.h"],
},
cmd = "$(exe //:codegen) ${SRCS} -o ${OUT}/generated.h -o ${OUT}/generated.cc",
type = "cxxbridge",
)
native.cxx_library(
name = name,
srcs = [":%s/source" % name],
preferred_linkage = "static",
exported_deps = deps + [":%s/include" % name],
)
native.cxx_library(
name = "%s/include" % name,
exported_headers = [":%s/header" % name],
)