mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 07:10:29 +00:00
b110613bee
Signed-off-by: 徐未来 <xuweilai2@huawei.com>
39 lines
1008 B
Python
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],
|
|
)
|