Support prebuilt_root_host in bp2build
Also fix a bug that filename string may contain wild card Test: Added unittest and CI Bug: 303725325 Bug: 304590341 Change-Id: I5de9c195343328981a4154024c0fe4e14969ce79
This commit is contained in:
parent
379257c84b
commit
040541496a
2 changed files with 44 additions and 8 deletions
|
@ -26,10 +26,17 @@ func runPrebuiltEtcTestCase(t *testing.T, tc Bp2buildTestCase) {
|
|||
t.Helper()
|
||||
(&tc).ModuleTypeUnderTest = "prebuilt_etc"
|
||||
(&tc).ModuleTypeUnderTestFactory = etc.PrebuiltEtcFactory
|
||||
RunBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerPrebuiltModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerPrebuiltEtcModuleTypes(ctx android.RegistrationContext) {
|
||||
func runPrebuiltRootHostTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).ModuleTypeUnderTest = "prebuilt_root_host"
|
||||
(&tc).ModuleTypeUnderTestFactory = etc.PrebuiltRootHostFactory
|
||||
RunBp2BuildTestCase(t, registerPrebuiltModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerPrebuiltModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcSimple(t *testing.T) {
|
||||
|
@ -160,7 +167,7 @@ func runPrebuiltUsrShareTestCase(t *testing.T, tc Bp2buildTestCase) {
|
|||
t.Helper()
|
||||
(&tc).ModuleTypeUnderTest = "prebuilt_usr_share"
|
||||
(&tc).ModuleTypeUnderTestFactory = etc.PrebuiltUserShareFactory
|
||||
RunBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerPrebuiltModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerPrebuiltUsrShareModuleTypes(ctx android.RegistrationContext) {
|
||||
|
@ -360,3 +367,30 @@ prebuilt_etc {
|
|||
ExpectedBazelTargets: []string{},
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltRootHostWithWildCardInSrc(t *testing.T) {
|
||||
runPrebuiltRootHostTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt_root_host - src string has wild card",
|
||||
Filesystem: map[string]string{
|
||||
"prh.dat": "",
|
||||
},
|
||||
Blueprint: `
|
||||
prebuilt_root_host {
|
||||
name: "prh_test",
|
||||
src: "*.dat",
|
||||
filename_from_src: true,
|
||||
relative_install_path: "test/install/path",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("prebuilt_file", "prh_test", AttrNameToString{
|
||||
"filename": `"prh.dat"`,
|
||||
"src": `"prh.dat"`,
|
||||
"dir": `"./test/install/path"`,
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
})}})
|
||||
}
|
||||
|
|
|
@ -508,6 +508,7 @@ func PrebuiltRootHostFactory() android.Module {
|
|||
// This module is host-only
|
||||
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
|
||||
android.InitDefaultableModule(module)
|
||||
android.InitBazelModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
|
@ -759,7 +760,7 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.Bp2buildMutatorContext) (*
|
|||
filename = *moduleProps.Filename
|
||||
} else if moduleProps.Filename_from_src != nil && *moduleProps.Filename_from_src {
|
||||
if moduleProps.Src != nil {
|
||||
filename = *moduleProps.Src
|
||||
filename = android.BazelLabelForModuleSrcSingle(ctx, *moduleProps.Src).Label
|
||||
}
|
||||
filenameFromSrc = true
|
||||
} else {
|
||||
|
@ -767,8 +768,8 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.Bp2buildMutatorContext) (*
|
|||
}
|
||||
|
||||
var dir = module.installDirBase
|
||||
if subDir := module.subdirProperties.Sub_dir; subDir != nil {
|
||||
dir = dir + "/" + *subDir
|
||||
if module.SubDir() != "" {
|
||||
dir = dir + "/" + module.SubDir()
|
||||
}
|
||||
|
||||
var installable bazel.BoolAttribute
|
||||
|
@ -796,8 +797,9 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.Bp2buildMutatorContext) (*
|
|||
// which we treat as *PrebuiltFile*
|
||||
func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||
var dir = module.installDirBase
|
||||
// prebuilt_file supports only `etc` or `usr/share`
|
||||
if !(dir == "etc" || dir == "usr/share") {
|
||||
// prebuilt_file only supports "etc" or "usr/share" or "." as module installDirBase
|
||||
if !(dir == "etc" || dir == "usr/share" || dir == ".") {
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue