From b114234f6b00ba00ad7cac5f172a2e54f36a8ca6 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Tue, 23 Jul 2024 13:39:54 +0900 Subject: [PATCH] Make some apex properties configurable This allows using select statements with these. * androidManifest * canned_fs_config * systemserverclasspath_fragments Bug: 354824866 Test: m Change-Id: I4c2182944ec14d99332f437c39a19ba0dc6b7731 --- apex/apex.go | 13 ++++++++----- apex/builder.go | 10 ++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index c1a9d7430..61bd8d02d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -86,7 +86,7 @@ type apexBundleProperties struct { // AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified, // a default one is automatically generated. - AndroidManifest *string `android:"path"` + AndroidManifest proptools.Configurable[string] `android:"path,replace_instead_of_append"` // Determines the file contexts file for setting the security contexts to files in this APEX // bundle. For platform APEXes, this should points to a file under /system/sepolicy Default: @@ -104,7 +104,7 @@ type apexBundleProperties struct { // path_or_glob is a path or glob pattern for a file or set of files, // uid/gid are numerial values of user ID and group ID, mode is octal value // for the file mode, and cap is hexadecimal value for the capability. - Canned_fs_config *string `android:"path"` + Canned_fs_config proptools.Configurable[string] `android:"path,replace_instead_of_append"` ApexNativeDependencies @@ -117,7 +117,8 @@ type apexBundleProperties struct { Bootclasspath_fragments []string // List of systemserverclasspath fragments that are embedded inside this APEX bundle. - Systemserverclasspath_fragments []string + Systemserverclasspath_fragments proptools.Configurable[[]string] + ResolvedSystemserverclasspathFragments []string `blueprint:"mutated"` // List of java libraries that are embedded inside this APEX bundle. Java_libs []string @@ -840,11 +841,13 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { } } + a.properties.ResolvedSystemserverclasspathFragments = a.properties.Systemserverclasspath_fragments.GetOrDefault(a.ConfigurableEvaluator(ctx), nil) + // Common-arch dependencies come next commonVariation := ctx.Config().AndroidCommonTarget.Variations() ctx.AddFarVariationDependencies(commonVariation, rroTag, a.properties.Rros...) ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...) - ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...) + ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.ResolvedSystemserverclasspathFragments...) ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...) ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...) ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...) @@ -2806,7 +2809,7 @@ func isStaticExecutableAllowed(apex string, exec string) bool { func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) { dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...) dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...) - dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments...) + dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...) } var ( diff --git a/apex/builder.go b/apex/builder.go index 763ce4d20..6f645ab04 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -704,8 +704,9 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) { optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName) } - if a.properties.AndroidManifest != nil { - androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest)) + androidManifest := a.properties.AndroidManifest.GetOrDefault(a.ConfigurableEvaluator(ctx), "") + if androidManifest != "" { + androidManifestFile := android.PathForModuleSrc(ctx, androidManifest) if a.testApex { androidManifestFile = markManifestTestOnly(ctx, androidManifestFile) @@ -1195,8 +1196,9 @@ func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext, defaultReadO } // Custom fs_config is "appended" to the last so that entries from the file are preferred // over default ones set above. - if a.properties.Canned_fs_config != nil { - cmd.Text("cat").Input(android.PathForModuleSrc(ctx, *a.properties.Canned_fs_config)) + customFsConfig := a.properties.Canned_fs_config.GetOrDefault(a.ConfigurableEvaluator(ctx), "") + if customFsConfig != "" { + cmd.Text("cat").Input(android.PathForModuleSrc(ctx, customFsConfig)) } cmd.Text(")").FlagWithOutput("> ", cannedFsConfig) builder.Build("generateFsConfig", fmt.Sprintf("Generating canned fs config for %s", a.BaseModuleName()))