mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 07:10:29 +00:00
Add test suite targets for buck and bazel
This commit is contained in:
parent
e3e0a71291
commit
9bc613e7db
@ -25,6 +25,7 @@ matrix:
|
||||
script:
|
||||
- buck build :cxx#check --verbose=0
|
||||
- buck run demo-rs --verbose=0
|
||||
- buck test ... --verbose=0
|
||||
- name: Bazel
|
||||
rust: nightly
|
||||
before_install:
|
||||
@ -36,3 +37,4 @@ matrix:
|
||||
- cargo vendor --versioned-dirs --locked third-party/vendor
|
||||
script:
|
||||
- bazel run demo-rs:demo_rs --verbose_failures --noshow_progress
|
||||
- bazel test ... --verbose_failures --noshow_progress
|
||||
|
@ -2,6 +2,7 @@ load(
|
||||
"@io_bazel_rules_rust//rust:rust.bzl",
|
||||
_rust_binary = "rust_binary",
|
||||
_rust_library = "rust_library",
|
||||
_rust_test = "rust_test",
|
||||
)
|
||||
|
||||
def rust_binary(edition = "2018", **kwargs):
|
||||
@ -17,3 +18,6 @@ def rust_library(edition = "2018", **kwargs):
|
||||
def third_party_rust_library(rustc_flags = [], **kwargs):
|
||||
rustc_flags = rustc_flags + ["--cap-lints=allow"]
|
||||
rust_library(rustc_flags = rustc_flags, **kwargs)
|
||||
|
||||
def rust_test(edition = "2018", **kwargs):
|
||||
_rust_test(edition = edition, **kwargs)
|
||||
|
42
tests/BUCK
Normal file
42
tests/BUCK
Normal file
@ -0,0 +1,42 @@
|
||||
rust_test(
|
||||
name = "test",
|
||||
srcs = ["test.rs"],
|
||||
deps = [":ffi"],
|
||||
)
|
||||
|
||||
rust_library(
|
||||
name = "ffi",
|
||||
srcs = ["ffi/lib.rs"],
|
||||
crate = "cxx_test_suite",
|
||||
deps = [
|
||||
":impl",
|
||||
"//:cxx",
|
||||
],
|
||||
)
|
||||
|
||||
cxx_library(
|
||||
name = "impl",
|
||||
srcs = [
|
||||
"ffi/tests.cc",
|
||||
":gen-source",
|
||||
],
|
||||
headers = {
|
||||
"ffi/lib.rs": ":gen-header",
|
||||
"ffi/tests.h": "ffi/tests.h",
|
||||
},
|
||||
deps = ["//:core"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "gen-header",
|
||||
srcs = ["ffi/lib.rs"],
|
||||
cmd = "$(exe //:codegen) --header ${SRCS} > ${OUT}",
|
||||
out = "gen.h",
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "gen-source",
|
||||
srcs = ["ffi/lib.rs"],
|
||||
cmd = "$(exe //:codegen) ${SRCS} > ${OUT}",
|
||||
out = "gen.cc",
|
||||
)
|
51
tests/BUILD
Normal file
51
tests/BUILD
Normal file
@ -0,0 +1,51 @@
|
||||
load("//:build/rust.bzl", "rust_library", "rust_test")
|
||||
|
||||
rust_test(
|
||||
name = "test",
|
||||
srcs = ["test.rs"],
|
||||
deps = [":cxx_test_suite"],
|
||||
)
|
||||
|
||||
rust_library(
|
||||
name = "cxx_test_suite",
|
||||
srcs = ["ffi/lib.rs"],
|
||||
deps = [
|
||||
":impl",
|
||||
"//:cxx",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "impl",
|
||||
srcs = [
|
||||
"ffi/tests.cc",
|
||||
":gen-source",
|
||||
],
|
||||
hdrs = ["ffi/tests.h"],
|
||||
deps = [
|
||||
":include",
|
||||
"//:core",
|
||||
],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "gen-header",
|
||||
srcs = ["ffi/lib.rs"],
|
||||
outs = ["lib.rs"],
|
||||
cmd = "$(location //:codegen) --header $< > $@",
|
||||
tools = ["//:codegen"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "gen-source",
|
||||
srcs = ["ffi/lib.rs"],
|
||||
outs = ["gen.cc"],
|
||||
cmd = "$(location //:codegen) $< > $@",
|
||||
tools = ["//:codegen"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "include",
|
||||
hdrs = [":gen-header"],
|
||||
include_prefix = "tests/ffi",
|
||||
)
|
Loading…
Reference in New Issue
Block a user