Merge "android_filesystem_defaults and visibility rule" into main
This commit is contained in:
commit
52a08486f3
3 changed files with 83 additions and 21 deletions
|
@ -36,8 +36,8 @@ func init() {
|
||||||
|
|
||||||
func registerBuildComponents(ctx android.RegistrationContext) {
|
func registerBuildComponents(ctx android.RegistrationContext) {
|
||||||
ctx.RegisterModuleType("android_filesystem", filesystemFactory)
|
ctx.RegisterModuleType("android_filesystem", filesystemFactory)
|
||||||
|
ctx.RegisterModuleType("android_filesystem_defaults", filesystemDefaultsFactory)
|
||||||
ctx.RegisterModuleType("android_system_image", systemImageFactory)
|
ctx.RegisterModuleType("android_system_image", systemImageFactory)
|
||||||
ctx.RegisterModuleType("android_system_image_defaults", systemImageDefaultsFactory)
|
|
||||||
ctx.RegisterModuleType("avb_add_hash_footer", avbAddHashFooterFactory)
|
ctx.RegisterModuleType("avb_add_hash_footer", avbAddHashFooterFactory)
|
||||||
ctx.RegisterModuleType("avb_add_hash_footer_defaults", avbAddHashFooterDefaultsFactory)
|
ctx.RegisterModuleType("avb_add_hash_footer_defaults", avbAddHashFooterDefaultsFactory)
|
||||||
ctx.RegisterModuleType("avb_gen_vbmeta_image", avbGenVbmetaImageFactory)
|
ctx.RegisterModuleType("avb_gen_vbmeta_image", avbGenVbmetaImageFactory)
|
||||||
|
@ -47,6 +47,7 @@ func registerBuildComponents(ctx android.RegistrationContext) {
|
||||||
type filesystem struct {
|
type filesystem struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
android.PackagingBase
|
android.PackagingBase
|
||||||
|
android.DefaultableModuleBase
|
||||||
|
|
||||||
properties filesystemProperties
|
properties filesystemProperties
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ func initFilesystemModule(module *filesystem) {
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
android.InitPackageModule(module)
|
android.InitPackageModule(module)
|
||||||
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
|
android.InitDefaultableModule(module)
|
||||||
}
|
}
|
||||||
|
|
||||||
var dependencyTag = struct {
|
var dependencyTag = struct {
|
||||||
|
@ -190,9 +192,7 @@ func (f *filesystem) partitionName() string {
|
||||||
var pctx = android.NewPackageContext("android/soong/filesystem")
|
var pctx = android.NewPackageContext("android/soong/filesystem")
|
||||||
|
|
||||||
func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
if !android.InList(f.PartitionType(), validPartitions) {
|
validatePartitionType(ctx, f)
|
||||||
ctx.PropertyErrorf("partition_type", "partition_type must be one of %s, found: %s", validPartitions, f.PartitionType())
|
|
||||||
}
|
|
||||||
switch f.fsType(ctx) {
|
switch f.fsType(ctx) {
|
||||||
case ext4Type:
|
case ext4Type:
|
||||||
f.output = f.buildImageUsingBuildImage(ctx)
|
f.output = f.buildImageUsingBuildImage(ctx)
|
||||||
|
@ -208,6 +208,22 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
ctx.InstallFile(f.installDir, f.installFileName(), f.output)
|
ctx.InstallFile(f.installDir, f.installFileName(), f.output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validatePartitionType(ctx android.ModuleContext, p partition) {
|
||||||
|
if !android.InList(p.PartitionType(), validPartitions) {
|
||||||
|
ctx.PropertyErrorf("partition_type", "partition_type must be one of %s, found: %s", validPartitions, p.PartitionType())
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.VisitDirectDepsWithTag(android.DefaultsDepTag, func(m android.Module) {
|
||||||
|
if fdm, ok := m.(*filesystemDefaults); ok {
|
||||||
|
if p.PartitionType() != fdm.PartitionType() {
|
||||||
|
ctx.PropertyErrorf("partition_type",
|
||||||
|
"%s doesn't match with the partition type %s of the filesystem default module %s",
|
||||||
|
p.PartitionType(), fdm.PartitionType(), m.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Copy extra files/dirs that are not from the `deps` property to `rootDir`, checking for conflicts with files
|
// Copy extra files/dirs that are not from the `deps` property to `rootDir`, checking for conflicts with files
|
||||||
// already in `rootDir`.
|
// already in `rootDir`.
|
||||||
func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.OutputPath) {
|
func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.OutputPath) {
|
||||||
|
@ -469,10 +485,16 @@ func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *andro
|
||||||
Text(android.PathForArbitraryOutput(ctx, stagingDir).String())
|
Text(android.PathForArbitraryOutput(ctx, stagingDir).String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type partition interface {
|
||||||
|
PartitionType() string
|
||||||
|
}
|
||||||
|
|
||||||
func (f *filesystem) PartitionType() string {
|
func (f *filesystem) PartitionType() string {
|
||||||
return proptools.StringDefault(f.properties.Partition_type, "system")
|
return proptools.StringDefault(f.properties.Partition_type, "system")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ partition = (*filesystem)(nil)
|
||||||
|
|
||||||
var _ android.AndroidMkEntriesProvider = (*filesystem)(nil)
|
var _ android.AndroidMkEntriesProvider = (*filesystem)(nil)
|
||||||
|
|
||||||
// Implements android.AndroidMkEntriesProvider
|
// Implements android.AndroidMkEntriesProvider
|
||||||
|
@ -546,3 +568,37 @@ var _ cc.UseCoverage = (*filesystem)(nil)
|
||||||
func (*filesystem) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
|
func (*filesystem) IsNativeCoverageNeeded(ctx android.IncomingTransitionContext) bool {
|
||||||
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
|
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// android_filesystem_defaults
|
||||||
|
|
||||||
|
type filesystemDefaults struct {
|
||||||
|
android.ModuleBase
|
||||||
|
android.DefaultsModuleBase
|
||||||
|
|
||||||
|
properties filesystemDefaultsProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
type filesystemDefaultsProperties struct {
|
||||||
|
// Identifies which partition this is for //visibility:any_system_image (and others) visibility
|
||||||
|
// checks, and will be used in the future for API surface checks.
|
||||||
|
Partition_type *string
|
||||||
|
}
|
||||||
|
|
||||||
|
// android_filesystem_defaults is a default module for android_filesystem and android_system_image
|
||||||
|
func filesystemDefaultsFactory() android.Module {
|
||||||
|
module := &filesystemDefaults{}
|
||||||
|
module.AddProperties(&module.properties)
|
||||||
|
module.AddProperties(&android.PackagingProperties{})
|
||||||
|
android.InitDefaultsModule(module)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *filesystemDefaults) PartitionType() string {
|
||||||
|
return proptools.StringDefault(f.properties.Partition_type, "system")
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ partition = (*filesystemDefaults)(nil)
|
||||||
|
|
||||||
|
func (f *filesystemDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
validatePartitionType(ctx, f)
|
||||||
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ func TestFileSystemWithCoverageVariants(t *testing.T) {
|
||||||
|
|
||||||
func TestSystemImageDefaults(t *testing.T) {
|
func TestSystemImageDefaults(t *testing.T) {
|
||||||
result := fixture.RunTestWithBp(t, `
|
result := fixture.RunTestWithBp(t, `
|
||||||
android_system_image_defaults {
|
android_filesystem_defaults {
|
||||||
name: "defaults",
|
name: "defaults",
|
||||||
multilib: {
|
multilib: {
|
||||||
common: {
|
common: {
|
||||||
|
@ -447,3 +447,25 @@ func TestSystemImageDefaults(t *testing.T) {
|
||||||
android.AssertStringListContains(t, "missing entry", fs.entries, e)
|
android.AssertStringListContains(t, "missing entry", fs.entries, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestInconsistentPartitionTypesInDefaults(t *testing.T) {
|
||||||
|
fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(
|
||||||
|
"doesn't match with the partition type")).
|
||||||
|
RunTestWithBp(t, `
|
||||||
|
android_filesystem_defaults {
|
||||||
|
name: "system_ext_def",
|
||||||
|
partition_type: "system_ext",
|
||||||
|
}
|
||||||
|
|
||||||
|
android_filesystem_defaults {
|
||||||
|
name: "system_def",
|
||||||
|
partition_type: "system",
|
||||||
|
defaults: ["system_ext_def"],
|
||||||
|
}
|
||||||
|
|
||||||
|
android_system_image {
|
||||||
|
name: "system",
|
||||||
|
defaults: ["system_def"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import (
|
||||||
|
|
||||||
type systemImage struct {
|
type systemImage struct {
|
||||||
filesystem
|
filesystem
|
||||||
android.DefaultableModuleBase
|
|
||||||
|
|
||||||
properties systemImageProperties
|
properties systemImageProperties
|
||||||
}
|
}
|
||||||
|
@ -40,7 +39,6 @@ func systemImageFactory() android.Module {
|
||||||
module.filesystem.buildExtraFiles = module.buildExtraFiles
|
module.filesystem.buildExtraFiles = module.buildExtraFiles
|
||||||
module.filesystem.filterPackagingSpec = module.filterPackagingSpec
|
module.filesystem.filterPackagingSpec = module.filterPackagingSpec
|
||||||
initFilesystemModule(&module.filesystem)
|
initFilesystemModule(&module.filesystem)
|
||||||
android.InitDefaultableModule(module)
|
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,17 +100,3 @@ func (s *systemImage) buildLinkerConfigFile(ctx android.ModuleContext, root andr
|
||||||
func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool {
|
func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool {
|
||||||
return ps.Partition() == "system"
|
return ps.Partition() == "system"
|
||||||
}
|
}
|
||||||
|
|
||||||
type systemImageDefaults struct {
|
|
||||||
android.ModuleBase
|
|
||||||
android.DefaultsModuleBase
|
|
||||||
}
|
|
||||||
|
|
||||||
// android_system_image_defaults is a default module for android_system_image module.
|
|
||||||
func systemImageDefaultsFactory() android.Module {
|
|
||||||
module := &systemImageDefaults{}
|
|
||||||
module.AddProperties(&android.PackagingProperties{})
|
|
||||||
module.AddProperties(&systemImageProperties{})
|
|
||||||
android.InitDefaultsModule(module)
|
|
||||||
return module
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue