Merge "Add filegroup_defaults module"
This commit is contained in:
commit
a8c1cacaf9
2 changed files with 44 additions and 2 deletions
|
@ -26,13 +26,18 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
RegisterModuleType("filegroup", FileGroupFactory)
|
||||
RegisterFilegroupBuildComponents(InitRegistrationContext)
|
||||
}
|
||||
|
||||
var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||
RegisterFilegroupBuildComponents(ctx)
|
||||
})
|
||||
|
||||
func RegisterFilegroupBuildComponents(ctx RegistrationContext) {
|
||||
ctx.RegisterModuleType("filegroup", FileGroupFactory)
|
||||
ctx.RegisterModuleType("filegroup_defaults", FileGroupDefaultsFactory)
|
||||
}
|
||||
|
||||
var convertedProtoLibrarySuffix = "_bp2build_converted"
|
||||
|
||||
// IsFilegroup checks that a module is a filegroup type
|
||||
|
@ -178,6 +183,7 @@ type fileGroupProperties struct {
|
|||
type fileGroup struct {
|
||||
ModuleBase
|
||||
BazelModuleBase
|
||||
DefaultableModuleBase
|
||||
FileGroupAsLibrary
|
||||
properties fileGroupProperties
|
||||
srcs Paths
|
||||
|
@ -195,6 +201,7 @@ func FileGroupFactory() Module {
|
|||
module.AddProperties(&module.properties)
|
||||
InitAndroidModule(module)
|
||||
InitBazelModule(module)
|
||||
InitDefaultableModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
|
@ -326,3 +333,17 @@ func ToFileGroupAsLibrary(ctx BazelConversionPathContext, name string) (FileGrou
|
|||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Defaults
|
||||
type FileGroupDefaults struct {
|
||||
ModuleBase
|
||||
DefaultsModuleBase
|
||||
}
|
||||
|
||||
func FileGroupDefaultsFactory() Module {
|
||||
module := &FileGroupDefaults{}
|
||||
module.AddProperties(&fileGroupProperties{})
|
||||
InitDefaultsModule(module)
|
||||
|
||||
return module
|
||||
}
|
||||
|
|
|
@ -58,3 +58,24 @@ func TestFileGroupWithPathProp(t *testing.T) {
|
|||
AssertStringEquals(t, "src full path", expectedOutputfile, fg.srcs[0].String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilegroupDefaults(t *testing.T) {
|
||||
bp := FixtureAddTextFile("p/Android.bp", `
|
||||
filegroup_defaults {
|
||||
name: "defaults",
|
||||
visibility: ["//x"],
|
||||
}
|
||||
filegroup {
|
||||
name: "foo",
|
||||
defaults: ["defaults"],
|
||||
visibility: ["//y"],
|
||||
}
|
||||
`)
|
||||
result := GroupFixturePreparers(
|
||||
PrepareForTestWithFilegroup,
|
||||
PrepareForTestWithDefaults,
|
||||
PrepareForTestWithVisibility,
|
||||
bp).RunTest(t)
|
||||
rules := effectiveVisibilityRules(result.Config, qualifiedModuleName{pkg: "p", name: "foo"})
|
||||
AssertDeepEquals(t, "visibility", []string{"//x", "//y"}, rules.Strings())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue