2021-10-25 16:28:33 +02:00
|
|
|
package bp2build
|
|
|
|
|
|
|
|
import (
|
2022-04-07 22:36:39 +02:00
|
|
|
"fmt"
|
2021-10-25 16:28:33 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"android/soong/cc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSharedPrebuiltLibrary(t *testing.T) {
|
2022-09-01 20:57:01 +02:00
|
|
|
RunBp2BuildTestCaseSimple(t,
|
2022-06-21 21:28:33 +02:00
|
|
|
Bp2buildTestCase{
|
|
|
|
Description: "prebuilt library shared simple",
|
|
|
|
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
|
|
|
|
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
|
|
|
Filesystem: map[string]string{
|
2021-10-25 16:28:33 +02:00
|
|
|
"libf.so": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `
|
2021-10-25 16:28:33 +02:00
|
|
|
cc_prebuilt_library_shared {
|
|
|
|
name: "libtest",
|
|
|
|
srcs: ["libf.so"],
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-10-17 16:48:57 +02:00
|
|
|
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
2021-11-08 18:56:31 +01:00
|
|
|
"shared_library": `"libf.so"`,
|
|
|
|
}),
|
2021-10-25 16:28:33 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) {
|
2022-09-01 20:57:01 +02:00
|
|
|
RunBp2BuildTestCaseSimple(t,
|
2022-06-21 21:28:33 +02:00
|
|
|
Bp2buildTestCase{
|
|
|
|
Description: "prebuilt library shared with arch variance",
|
|
|
|
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
|
|
|
|
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
|
|
|
Filesystem: map[string]string{
|
2021-10-25 16:28:33 +02:00
|
|
|
"libf.so": "",
|
|
|
|
"libg.so": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `
|
2021-10-25 16:28:33 +02:00
|
|
|
cc_prebuilt_library_shared {
|
|
|
|
name: "libtest",
|
|
|
|
arch: {
|
|
|
|
arm64: { srcs: ["libf.so"], },
|
|
|
|
arm: { srcs: ["libg.so"], },
|
|
|
|
},
|
|
|
|
bazel_module: { bp2build_available: true },
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedBazelTargets: []string{
|
2022-10-17 16:48:57 +02:00
|
|
|
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
|
2021-11-08 18:56:31 +01:00
|
|
|
"shared_library": `select({
|
2023-10-11 12:51:28 +02:00
|
|
|
"//build/bazel_common_rules/platforms/arch:arm": "libg.so",
|
|
|
|
"//build/bazel_common_rules/platforms/arch:arm64": "libf.so",
|
2021-10-25 16:28:33 +02:00
|
|
|
"//conditions:default": None,
|
2021-11-08 18:56:31 +01:00
|
|
|
})`,
|
|
|
|
}),
|
2021-10-25 16:28:33 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2022-04-07 22:36:39 +02:00
|
|
|
|
|
|
|
func TestSharedPrebuiltLibrarySharedStanzaFails(t *testing.T) {
|
2022-09-01 20:57:01 +02:00
|
|
|
RunBp2BuildTestCaseSimple(t,
|
2022-06-21 21:28:33 +02:00
|
|
|
Bp2buildTestCase{
|
|
|
|
Description: "prebuilt library shared with shared stanza fails because multiple sources",
|
|
|
|
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
|
|
|
|
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
|
|
|
Filesystem: map[string]string{
|
2022-04-07 22:36:39 +02:00
|
|
|
"libf.so": "",
|
|
|
|
"libg.so": "",
|
|
|
|
},
|
2022-06-21 21:28:33 +02:00
|
|
|
Blueprint: `
|
2022-04-07 22:36:39 +02:00
|
|
|
cc_prebuilt_library_shared {
|
|
|
|
name: "libtest",
|
|
|
|
srcs: ["libf.so"],
|
|
|
|
shared: {
|
|
|
|
srcs: ["libg.so"],
|
|
|
|
},
|
|
|
|
bazel_module: { bp2build_available: true},
|
|
|
|
}`,
|
2022-06-21 21:28:33 +02:00
|
|
|
ExpectedErr: fmt.Errorf("Expected at most one source file"),
|
2022-04-07 22:36:39 +02:00
|
|
|
})
|
|
|
|
}
|