diff options
author | 2025-03-04 04:11:55 -0800 | |
---|---|---|
committer | 2025-03-04 04:11:55 -0800 | |
commit | bc917d9f15858dbf8d7d936173a5c767215e74b8 (patch) | |
tree | d1a788f253a48ea82f5d0ecf9eccc795be1dcfab | |
parent | 570a6d2c5ad018e10df3c8d0f8e7d9ec70ecf7af (diff) | |
parent | d5df518597aaa1a7e7d8ad44c854c1e4e73dc05d (diff) |
Merge changes from topic "revive_system_ext_aconfig_container" into main
* changes:
Soong filesystem generates aconfig files for subpartitions
Revert "Treat system_ext as system container"
-rw-r--r-- | aconfig/aconfig_declarations.go | 9 | ||||
-rw-r--r-- | aconfig/codegen/java_aconfig_library_test.go | 2 | ||||
-rw-r--r-- | android/aconfig_providers.go | 6 | ||||
-rw-r--r-- | filesystem/aconfig_files.go | 169 | ||||
-rw-r--r-- | filesystem/filesystem.go | 8 | ||||
-rw-r--r-- | fsgen/filesystem_creator.go | 4 |
6 files changed, 90 insertions, 108 deletions
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index 9a9e5686a..b06839831 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -47,7 +47,7 @@ type DeclarationsModule struct { // are from RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS. ReleaseConfigValues []AconfigReleaseConfigValue - // Container(system/vendor/apex) that this module belongs to + // Container(system/system_ext/vendor/apex) that this module belongs to Container string // The flags will only be repackaged if this prop is true. @@ -88,13 +88,6 @@ func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext ctx.PropertyErrorf("container", "missing container property") } - // treating system_ext as system partition as we are combining them as one container - // TODO remove this logic once we start enforcing that system_ext cannot be specified as - // container in the container field. - if module.properties.Container == "system_ext" { - module.properties.Container = "system" - } - // Add a dependency on the aconfig_value_sets defined in // RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that // match our package. diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go index 8854369e2..b9455f77d 100644 --- a/aconfig/codegen/java_aconfig_library_test.go +++ b/aconfig/codegen/java_aconfig_library_test.go @@ -260,7 +260,7 @@ func TestMkEntriesMatchedContainer(t *testing.T) { aconfig_declarations { name: "my_aconfig_declarations_bar", package: "com.example.package.bar", - container: "vendor", + container: "system_ext", srcs: ["bar.aconfig"], } diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go index 205b85590..7185a8941 100644 --- a/android/aconfig_providers.go +++ b/android/aconfig_providers.go @@ -238,8 +238,7 @@ func getContainer(m Module) string { } else if base.ProductSpecific() { container = "product" } else if base.SystemExtSpecific() { - // system_ext and system partitions should be treated as one container - container = "system" + container = "system_ext" } return container @@ -255,8 +254,7 @@ func getContainerUsingProviders(ctx OtherModuleProviderContext, m Module) string } else if commonInfo.ProductSpecific { container = "product" } else if commonInfo.SystemExtSpecific { - // system_ext and system partitions should be treated as one container - container = "system" + container = "system_ext" } return container diff --git a/filesystem/aconfig_files.go b/filesystem/aconfig_files.go index b4173d784..20a195313 100644 --- a/filesystem/aconfig_files.go +++ b/filesystem/aconfig_files.go @@ -17,6 +17,7 @@ package filesystem import ( "android/soong/android" "strconv" + "strings" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -31,19 +32,12 @@ var ( Command: `$aconfig create-storage --container $container --file $fileType --out $out --cache $in --version $version`, CommandDeps: []string{"$aconfig"}, }, "container", "fileType", "version") -) - -type installedAconfigFlagsInfo struct { - aconfigFiles android.Paths -} - -var installedAconfigFlagsProvider = blueprint.NewProvider[installedAconfigFlagsInfo]() -type importAconfigDepDag struct { - blueprint.BaseDependencyTag -} - -var importAconfigDependencyTag = interPartitionDepTag{} + subPartitionsInPartition = map[string][]string{ + "system": {"system_ext", "product", "vendor"}, + "vendor": {"odm"}, + } +) func (f *filesystem) buildAconfigFlagsFiles( ctx android.ModuleContext, @@ -52,88 +46,97 @@ func (f *filesystem) buildAconfigFlagsFiles( dir android.OutputPath, fullInstallPaths *[]FullInstallPathInfo, ) { + if !proptools.Bool(f.properties.Gen_aconfig_flags_pb) { + return + } + + partition := f.PartitionType() + subPartitionsFound := map[string]bool{} + fullInstallPath := android.PathForModuleInPartitionInstall(ctx, partition) + + for _, subPartition := range subPartitionsInPartition[partition] { + subPartitionsFound[subPartition] = false + } + var caches []android.Path for _, ps := range specs { caches = append(caches, ps.GetAconfigPaths()...) + for subPartition, found := range subPartitionsFound { + if !found && strings.HasPrefix(ps.RelPathInPackage(), subPartition+"/") { + subPartitionsFound[subPartition] = true + break + } + } } + caches = android.SortedUniquePaths(caches) - ctx.VisitDirectDepsWithTag(importAconfigDependencyTag, func(m android.Module) { - info, ok := android.OtherModuleProvider(ctx, m, installedAconfigFlagsProvider) - if !ok { - ctx.ModuleErrorf("expected dependency %s to have an installedAconfigFlagsProvider", m.Name()) - return + buildAconfigFlagsFiles := func(container string, dir android.OutputPath, fullInstallPath android.InstallPath) { + aconfigFlagsPb := android.PathForModuleOut(ctx, "aconfig", container, "aconfig_flags.pb") + aconfigFlagsPbBuilder := android.NewRuleBuilder(pctx, ctx) + cmd := aconfigFlagsPbBuilder.Command(). + BuiltTool("aconfig"). + Text(" dump-cache --dedup --format protobuf --out"). + Output(aconfigFlagsPb). + Textf("--filter container:%s+state:ENABLED", container). + Textf("--filter container:%s+permission:READ_WRITE", container) + for _, cache := range caches { + cmd.FlagWithInput("--cache ", cache) } - caches = append(caches, info.aconfigFiles...) - }) - caches = android.SortedUniquePaths(caches) + aconfigFlagsPbBuilder.Build(container+"_aconfig_flags_pb", "build aconfig_flags.pb") - android.SetProvider(ctx, installedAconfigFlagsProvider, installedAconfigFlagsInfo{ - aconfigFiles: caches, - }) + installEtcDir := dir.Join(ctx, "etc") + installAconfigFlagsPath := installEtcDir.Join(ctx, "aconfig_flags.pb") + builder.Command().Text("mkdir -p ").Text(installEtcDir.String()) + builder.Command().Text("cp").Input(aconfigFlagsPb).Text(installAconfigFlagsPath.String()) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: fullInstallPath.Join(ctx, "etc/aconfig_flags.pb"), + SourcePath: aconfigFlagsPb, + }) + f.appendToEntry(ctx, installAconfigFlagsPath) - if !proptools.Bool(f.properties.Gen_aconfig_flags_pb) { - return - } + // To enable fingerprint, we need to have v2 storage files. The default version is 1. + storageFilesVersion := 1 + if ctx.Config().ReleaseFingerprintAconfigPackages() { + storageFilesVersion = 2 + } - container := f.PartitionType() - - aconfigFlagsPb := android.PathForModuleOut(ctx, "aconfig", "aconfig_flags.pb") - aconfigFlagsPbBuilder := android.NewRuleBuilder(pctx, ctx) - cmd := aconfigFlagsPbBuilder.Command(). - BuiltTool("aconfig"). - Text(" dump-cache --dedup --format protobuf --out"). - Output(aconfigFlagsPb). - Textf("--filter container:%s+state:ENABLED", container). - Textf("--filter container:%s+permission:READ_WRITE", container) - for _, cache := range caches { - cmd.FlagWithInput("--cache ", cache) - } - aconfigFlagsPbBuilder.Build("aconfig_flags_pb", "build aconfig_flags.pb") - - installAconfigFlagsPath := dir.Join(ctx, "etc", "aconfig_flags.pb") - builder.Command().Text("mkdir -p ").Text(dir.Join(ctx, "etc").String()) - builder.Command().Text("cp").Input(aconfigFlagsPb).Text(installAconfigFlagsPath.String()) - *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ - FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc/aconfig_flags.pb"), - SourcePath: aconfigFlagsPb, - }) - f.appendToEntry(ctx, installAconfigFlagsPath) - - // To enable fingerprint, we need to have v2 storage files. The default version is 1. - storageFilesVersion := 1 - if ctx.Config().ReleaseFingerprintAconfigPackages() { - storageFilesVersion = 2 - } + installAconfigStorageDir := installEtcDir.Join(ctx, "aconfig") + builder.Command().Text("mkdir -p").Text(installAconfigStorageDir.String()) + + generatePartitionAconfigStorageFile := func(fileType, fileName string) { + outPath := android.PathForModuleOut(ctx, "aconfig", container, fileName) + installPath := installAconfigStorageDir.Join(ctx, fileName) + ctx.Build(pctx, android.BuildParams{ + Rule: aconfigCreateStorage, + Input: aconfigFlagsPb, + Output: outPath, + Args: map[string]string{ + "container": container, + "fileType": fileType, + "version": strconv.Itoa(storageFilesVersion), + }, + }) + builder.Command(). + Text("cp").Input(outPath).Text(installPath.String()) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + SourcePath: outPath, + FullInstallPath: fullInstallPath.Join(ctx, "etc/aconfig", fileName), + }) + f.appendToEntry(ctx, installPath) + } - installAconfigStorageDir := dir.Join(ctx, "etc", "aconfig") - builder.Command().Text("mkdir -p").Text(installAconfigStorageDir.String()) - - generatePartitionAconfigStorageFile := func(fileType, fileName string) { - outPath := android.PathForModuleOut(ctx, "aconfig", fileName) - installPath := installAconfigStorageDir.Join(ctx, fileName) - ctx.Build(pctx, android.BuildParams{ - Rule: aconfigCreateStorage, - Input: aconfigFlagsPb, - Output: outPath, - Args: map[string]string{ - "container": container, - "fileType": fileType, - "version": strconv.Itoa(storageFilesVersion), - }, - }) - builder.Command(). - Text("cp").Input(outPath).Text(installPath.String()) - *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ - SourcePath: outPath, - FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc/aconfig", fileName), - }) - f.appendToEntry(ctx, installPath) + if ctx.Config().ReleaseCreateAconfigStorageFile() { + generatePartitionAconfigStorageFile("package_map", "package.map") + generatePartitionAconfigStorageFile("flag_map", "flag.map") + generatePartitionAconfigStorageFile("flag_val", "flag.val") + generatePartitionAconfigStorageFile("flag_info", "flag.info") + } } - if ctx.Config().ReleaseCreateAconfigStorageFile() { - generatePartitionAconfigStorageFile("package_map", "package.map") - generatePartitionAconfigStorageFile("flag_map", "flag.map") - generatePartitionAconfigStorageFile("flag_val", "flag.val") - generatePartitionAconfigStorageFile("flag_info", "flag.info") + buildAconfigFlagsFiles(partition, dir, fullInstallPath) + for _, subPartition := range android.SortedKeys(subPartitionsFound) { + if subPartitionsFound[subPartition] { + buildAconfigFlagsFiles(subPartition, dir.Join(ctx, subPartition), fullInstallPath.Join(ctx, subPartition)) + } } } diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 725786897..fc480e6f0 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -208,11 +208,6 @@ type FilesystemProperties struct { // Install aconfig_flags.pb file for the modules installed in this partition. Gen_aconfig_flags_pb *bool - // List of names of other filesystem partitions to import their aconfig flags from. - // This is used for the system partition to import system_ext's aconfig flags, as currently - // those are considered one "container": aosp/3261300 - Import_aconfig_flags_from []string - Fsverity fsverityProperties // If this property is set to true, the filesystem will call ctx.UncheckedModule(), causing @@ -359,9 +354,6 @@ func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) { if f.properties.Android_filesystem_deps.System_ext != nil { ctx.AddDependency(ctx.Module(), interPartitionDependencyTag, proptools.String(f.properties.Android_filesystem_deps.System_ext)) } - for _, partition := range f.properties.Import_aconfig_flags_from { - ctx.AddDependency(ctx.Module(), importAconfigDependencyTag, partition) - } for _, partition := range f.properties.Include_files_of { ctx.AddDependency(ctx.Module(), interPartitionInstallDependencyTag, partition) } diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go index 937882236..f00e491cc 100644 --- a/fsgen/filesystem_creator.go +++ b/fsgen/filesystem_creator.go @@ -493,10 +493,6 @@ func partitionSpecificFsProps(ctx android.EarlyModuleContext, partitions allGene fsProps.Base_dir = proptools.StringPtr("system") fsProps.Dirs = proptools.NewSimpleConfigurable(commonPartitionDirs) fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch()) - - if systemExtName := partitions.nameForType("system_ext"); systemExtName != "" { - fsProps.Import_aconfig_flags_from = []string{systemExtName} - } fsProps.Stem = proptools.StringPtr("system.img") case "system_ext": if partitionVars.ProductFsverityGenerateMetadata { |