blob: a779c36d65d4c4b529a0fd91f79a98eba4ee181e [file] [log] [blame]
Vinh Tran0c4b9ec2023-08-24 11:10:01 -04001package bp2build
2
3import (
4 "android/soong/android"
5 "android/soong/rust"
6 "testing"
7)
8
9func runRustProtobufTestCase(t *testing.T, tc Bp2buildTestCase) {
10 t.Helper()
11 RunBp2BuildTestCase(t, registerRustProtobufModuleTypes, tc)
12}
13
14func registerRustProtobufModuleTypes(ctx android.RegistrationContext) {
15 ctx.RegisterModuleType("rust_protobuf_host", rust.RustProtobufHostFactory)
16
17}
18
19func TestRustProtobufHostTestCase(t *testing.T) {
20 runRustProtobufTestCase(t, Bp2buildTestCase{
21 Dir: "external/rust/crates/foo",
22 Blueprint: "",
23 Filesystem: map[string]string{
24 "external/rust/crates/foo/src/lib.rs": "",
25 "external/rust/crates/foo/src/helper.rs": "",
26 "external/rust/crates/foo/Android.bp": `
27rust_protobuf_host {
28 name: "libfoo",
29 crate_name: "foo",
30 protos: ["src/foo.proto"],
31 bazel_module: { bp2build_available: true },
32}
33`,
34 },
35 ExpectedBazelTargets: []string{
36 makeBazelTargetHostOrDevice("proto_library", "libfoo_proto", AttrNameToString{
37 "srcs": `["src/foo.proto"]`,
38 }, android.HostSupported),
39 makeBazelTargetHostOrDevice("rust_proto_library", "libfoo", AttrNameToString{
40 "crate_name": `"foo"`,
41 "deps": `[":libfoo_proto"]`,
42 }, android.HostSupported),
43 },
44 },
45 )
46}