be46fccc40
Each conversion required defining a separate mutator, which will each operate on _all_ modules and requires each to repeat checks whether the mutator should operator. Instead, we introduce a single mutator and modules can define a ConvertWithBp2build to implement bp2build conversion for that module. Test: bp2build.sh Bug: 183079158 Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package bp2build
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"android/soong/cc"
|
|
)
|
|
|
|
func TestSharedPrebuiltLibrary(t *testing.T) {
|
|
runBp2BuildTestCaseSimple(t,
|
|
bp2buildTestCase{
|
|
description: "prebuilt library shared simple",
|
|
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
|
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
|
filesystem: map[string]string{
|
|
"libf.so": "",
|
|
},
|
|
blueprint: `
|
|
cc_prebuilt_library_shared {
|
|
name: "libtest",
|
|
srcs: ["libf.so"],
|
|
bazel_module: { bp2build_available: true },
|
|
}`,
|
|
expectedBazelTargets: []string{
|
|
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
|
"shared_library": `"libf.so"`,
|
|
}),
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) {
|
|
runBp2BuildTestCaseSimple(t,
|
|
bp2buildTestCase{
|
|
description: "prebuilt library shared with arch variance",
|
|
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
|
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
|
filesystem: map[string]string{
|
|
"libf.so": "",
|
|
"libg.so": "",
|
|
},
|
|
blueprint: `
|
|
cc_prebuilt_library_shared {
|
|
name: "libtest",
|
|
arch: {
|
|
arm64: { srcs: ["libf.so"], },
|
|
arm: { srcs: ["libg.so"], },
|
|
},
|
|
bazel_module: { bp2build_available: true },
|
|
}`,
|
|
expectedBazelTargets: []string{
|
|
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
|
"shared_library": `select({
|
|
"//build/bazel/platforms/arch:arm": "libg.so",
|
|
"//build/bazel/platforms/arch:arm64": "libf.so",
|
|
"//conditions:default": None,
|
|
})`,
|
|
}),
|
|
},
|
|
})
|
|
}
|