Vinh Tran | 0c4b9ec | 2023-08-24 11:10:01 -0400 | [diff] [blame^] | 1 | package bp2build |
| 2 | |
| 3 | import ( |
| 4 | "android/soong/android" |
| 5 | "android/soong/rust" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func runRustProtobufTestCase(t *testing.T, tc Bp2buildTestCase) { |
| 10 | t.Helper() |
| 11 | RunBp2BuildTestCase(t, registerRustProtobufModuleTypes, tc) |
| 12 | } |
| 13 | |
| 14 | func registerRustProtobufModuleTypes(ctx android.RegistrationContext) { |
| 15 | ctx.RegisterModuleType("rust_protobuf_host", rust.RustProtobufHostFactory) |
| 16 | |
| 17 | } |
| 18 | |
| 19 | func 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": ` |
| 27 | rust_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 | } |