Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 7fa0696 | 2021-10-25 10:28:33 -0400 | [diff] [blame] | 1 | package bp2build |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "android/soong/cc" |
| 7 | ) |
| 8 | |
| 9 | func TestSharedPrebuiltLibrary(t *testing.T) { |
| 10 | runBp2BuildTestCaseSimple(t, |
| 11 | bp2buildTestCase{ |
| 12 | description: "prebuilt library shared simple", |
| 13 | moduleTypeUnderTest: "cc_prebuilt_library_shared", |
| 14 | moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory, |
| 15 | moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build, |
| 16 | filesystem: map[string]string{ |
| 17 | "libf.so": "", |
| 18 | }, |
| 19 | blueprint: ` |
| 20 | cc_prebuilt_library_shared { |
| 21 | name: "libtest", |
| 22 | srcs: ["libf.so"], |
| 23 | bazel_module: { bp2build_available: true }, |
| 24 | }`, |
| 25 | expectedBazelTargets: []string{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 26 | makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{ |
| 27 | "shared_library": `"libf.so"`, |
| 28 | }), |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 7fa0696 | 2021-10-25 10:28:33 -0400 | [diff] [blame] | 29 | }, |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) { |
| 34 | runBp2BuildTestCaseSimple(t, |
| 35 | bp2buildTestCase{ |
| 36 | description: "prebuilt library shared with arch variance", |
| 37 | moduleTypeUnderTest: "cc_prebuilt_library_shared", |
| 38 | moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory, |
| 39 | moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build, |
| 40 | filesystem: map[string]string{ |
| 41 | "libf.so": "", |
| 42 | "libg.so": "", |
| 43 | }, |
| 44 | blueprint: ` |
| 45 | cc_prebuilt_library_shared { |
| 46 | name: "libtest", |
| 47 | arch: { |
| 48 | arm64: { srcs: ["libf.so"], }, |
| 49 | arm: { srcs: ["libg.so"], }, |
| 50 | }, |
| 51 | bazel_module: { bp2build_available: true }, |
| 52 | }`, |
| 53 | expectedBazelTargets: []string{ |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 54 | makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{ |
| 55 | "shared_library": `select({ |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 7fa0696 | 2021-10-25 10:28:33 -0400 | [diff] [blame] | 56 | "//build/bazel/platforms/arch:arm": "libg.so", |
| 57 | "//build/bazel/platforms/arch:arm64": "libf.so", |
| 58 | "//conditions:default": None, |
Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 59 | })`, |
| 60 | }), |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 7fa0696 | 2021-10-25 10:28:33 -0400 | [diff] [blame] | 61 | }, |
| 62 | }) |
| 63 | } |