diff options
-rw-r--r-- | aconfig/all_aconfig_declarations.go | 1 | ||||
-rw-r--r-- | android/Android.bp | 1 | ||||
-rw-r--r-- | android/androidmk.go | 3 | ||||
-rw-r--r-- | android/configurable_properties.go | 3 | ||||
-rw-r--r-- | android/otatools_package_cert_zip.go | 62 | ||||
-rw-r--r-- | android/packaging.go | 41 | ||||
-rw-r--r-- | apex/apex_test.go | 10 | ||||
-rw-r--r-- | cc/fdo_profile.go | 9 | ||||
-rw-r--r-- | cc/library_sdk_member.go | 5 | ||||
-rw-r--r-- | cmd/soong_ui/main.go | 4 | ||||
-rw-r--r-- | filesystem/android_device.go | 25 | ||||
-rw-r--r-- | filesystem/android_device_product_out.go | 2 | ||||
-rw-r--r-- | filesystem/filesystem_test.go | 33 | ||||
-rw-r--r-- | filesystem/system_other.go | 7 | ||||
-rw-r--r-- | filesystem/vbmeta.go | 54 | ||||
-rw-r--r-- | fsgen/filesystem_creator_test.go | 145 | ||||
-rw-r--r-- | fsgen/prebuilt_etc_modules_gen.go | 4 | ||||
-rw-r--r-- | java/app.go | 1 | ||||
-rw-r--r-- | java/app_set.go | 7 | ||||
-rw-r--r-- | java/dex.go | 8 | ||||
-rw-r--r-- | ui/build/androidmk_denylist.go | 55 | ||||
-rw-r--r-- | ui/build/dumpvars.go | 7 | ||||
-rw-r--r-- | ui/build/finder.go | 33 |
23 files changed, 460 insertions, 60 deletions
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go index f3c68c37a..5a5262485 100644 --- a/aconfig/all_aconfig_declarations.go +++ b/aconfig/all_aconfig_declarations.go @@ -129,6 +129,7 @@ func (this *allAconfigDeclarationsSingleton) GenerateAndroidBuildActions(ctx and invalidExportedFlags := android.PathForIntermediates(ctx, "invalid_exported_flags.txt") GenerateExportedFlagCheck(ctx, invalidExportedFlags, parsedFlagsFile, this.properties) depsFiles = append(depsFiles, invalidExportedFlags) + ctx.Phony("droidcore", invalidExportedFlags) } } diff --git a/android/Android.bp b/android/Android.bp index 00dc50ac2..71e674767 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -83,6 +83,7 @@ bootstrap_go_package { "nothing.go", "notices.go", "onceper.go", + "otatools_package_cert_zip.go", "override_module.go", "package.go", "package_ctx.go", diff --git a/android/androidmk.go b/android/androidmk.go index 784559312..7cc6aef00 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -510,6 +510,9 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod Module) { a.EntryMap = make(map[string][]string) base := mod.base() name := base.BaseModuleName() + if bmn, ok := mod.(baseModuleName); ok { + name = bmn.BaseModuleName() + } if a.OverrideName != "" { name = a.OverrideName } diff --git a/android/configurable_properties.go b/android/configurable_properties.go index 2c794a186..bde33e99b 100644 --- a/android/configurable_properties.go +++ b/android/configurable_properties.go @@ -7,7 +7,8 @@ import "github.com/google/blueprint/proptools" // to indicate a "default" case. func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] { var resultCases []proptools.ConfigurableCase[bool] - for pattern, value := range cases { + for _, pattern := range SortedKeys(cases) { + value := cases[pattern] if pattern == "" { resultCases = append(resultCases, proptools.NewConfigurableCase( []proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()}, diff --git a/android/otatools_package_cert_zip.go b/android/otatools_package_cert_zip.go new file mode 100644 index 000000000..3a654cfe5 --- /dev/null +++ b/android/otatools_package_cert_zip.go @@ -0,0 +1,62 @@ +// Copyright 2025 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package android + +import ( + "github.com/google/blueprint" +) + +func init() { + RegisterOtatoolsPackageBuildComponents(InitRegistrationContext) + pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") +} + +func RegisterOtatoolsPackageBuildComponents(ctx RegistrationContext) { + ctx.RegisterModuleType("otatools_package_cert_files", OtatoolsPackageFactory) +} + +type OtatoolsPackage struct { + ModuleBase +} + +func OtatoolsPackageFactory() Module { + module := &OtatoolsPackage{} + InitAndroidModule(module) + return module +} + +var ( + otatoolsPackageCertRule = pctx.AndroidStaticRule("otatools_package_cert_files", blueprint.RuleParams{ + Command: "echo '$out : ' $$(cat $in) > ${out}.d && ${SoongZipCmd} -o $out -l $in", + CommandDeps: []string{"${SoongZipCmd}"}, + Depfile: "${out}.d", + Description: "Zip otatools-package cert files", + }) +) + +func (fg *OtatoolsPackage) GenerateAndroidBuildActions(ctx ModuleContext) { + if ctx.ModuleDir() != "build/make/tools/otatools_package" { + ctx.ModuleErrorf("There can only be one otatools_package_cert_files module in build/make/tools/otatools_package") + return + } + fileListFile := PathForArbitraryOutput(ctx, ".module_paths", "OtaToolsCertFiles.list") + otatoolsPackageCertZip := PathForModuleOut(ctx, "otatools_package_cert_files.zip") + ctx.Build(pctx, BuildParams{ + Rule: otatoolsPackageCertRule, + Input: fileListFile, + Output: otatoolsPackageCertZip, + }) + ctx.SetOutputFiles([]Path{otatoolsPackageCertZip}, "") +} diff --git a/android/packaging.go b/android/packaging.go index bb1fe4e45..bf1840929 100644 --- a/android/packaging.go +++ b/android/packaging.go @@ -506,13 +506,11 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont // all packaging specs gathered from the high priority deps. var highPriorities []PackagingSpec - // Name of the dependency which requested the packaging spec. - // If this dep is overridden, the packaging spec will not be installed via this dependency chain. - // (the packaging spec might still be installed if there are some other deps which depend on it). - var depNames []string - // list of module names overridden - var overridden []string + overridden := make(map[string]bool) + + // all installed modules which are not overridden. + modulesToInstall := make(map[string]bool) var arches []ArchType for _, target := range getSupportedTargets(ctx) { @@ -529,6 +527,7 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont return false } + // find all overridden modules and packaging specs ctx.VisitDirectDepsProxy(func(child ModuleProxy) { depTag := ctx.OtherModuleDependencyTag(child) if pi, ok := depTag.(PackagingItem); !ok || !pi.IsPackagingItem() { @@ -556,20 +555,32 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont regularPriorities = append(regularPriorities, ps) } - depNames = append(depNames, child.Name()) - overridden = append(overridden, ps.overrides.ToSlice()...) + for o := range ps.overrides.Iter() { + overridden[o] = true + } + } + }) + + // gather modules to install, skipping overridden modules + ctx.WalkDeps(func(child, parent Module) bool { + owner := ctx.OtherModuleName(child) + if o, ok := child.(OverridableModule); ok { + if overriddenBy := o.GetOverriddenBy(); overriddenBy != "" { + owner = overriddenBy + } + } + if overridden[owner] { + return false } + modulesToInstall[owner] = true + return true }) filterOverridden := func(input []PackagingSpec) []PackagingSpec { - // input minus packaging specs that are overridden + // input minus packaging specs that are not installed var filtered []PackagingSpec - for index, ps := range input { - if ps.owner != "" && InList(ps.owner, overridden) { - continue - } - // The dependency which requested this packaging spec has been overridden. - if InList(depNames[index], overridden) { + for _, ps := range input { + if !modulesToInstall[ps.owner] { continue } filtered = append(filtered, ps) diff --git a/apex/apex_test.go b/apex/apex_test.go index 36a697487..327e018f4 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -11468,6 +11468,16 @@ func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) { // 1. The contents of the selected apex_contributions are visible to make // 2. The rest of the apexes in the mainline module family (source or other prebuilt) is hidden from make checkHideFromMake(t, ctx, tc.expectedVisibleModuleName, tc.expectedHiddenModuleNames) + + // Check that source_apex_name is written as LOCAL_MODULE for make packaging + if tc.expectedVisibleModuleName == "prebuilt_com.google.android.foo.v2" { + apex := ctx.ModuleForTests(t, "prebuilt_com.google.android.foo.v2", "android_common_prebuilt_com.android.foo").Module() + entries := android.AndroidMkEntriesForTest(t, ctx, apex)[0] + + expected := "com.google.android.foo" + actual := entries.EntryMap["LOCAL_MODULE"][0] + android.AssertStringEquals(t, "LOCAL_MODULE", expected, actual) + } } } diff --git a/cc/fdo_profile.go b/cc/fdo_profile.go index 1a3395773..c79ea1018 100644 --- a/cc/fdo_profile.go +++ b/cc/fdo_profile.go @@ -17,6 +17,8 @@ package cc import ( "android/soong/android" "github.com/google/blueprint" + + "github.com/google/blueprint/proptools" ) func init() { @@ -34,7 +36,7 @@ type fdoProfile struct { } type fdoProfileProperties struct { - Profile *string `android:"arch_variant"` + Profile proptools.Configurable[string] `android:"arch_variant,replace_instead_of_append"` } // FdoProfileInfo is provided by FdoProfileProvider @@ -47,8 +49,9 @@ var FdoProfileProvider = blueprint.NewProvider[FdoProfileInfo]() // GenerateAndroidBuildActions of fdo_profile does not have any build actions func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) { - if fp.properties.Profile != nil { - path := android.PathForModuleSrc(ctx, *fp.properties.Profile) + profile := fp.properties.Profile.GetOrDefault(ctx, "") + if profile != "" { + path := android.PathForModuleSrc(ctx, profile) android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{ Path: path, }) diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go index d1440eaad..46290300c 100644 --- a/cc/library_sdk_member.go +++ b/cc/library_sdk_member.go @@ -573,9 +573,8 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte func getRequiredMemberOutputFile(ctx android.SdkMemberContext, ccModule *Module) android.Path { var path android.Path - outputFile := ccModule.OutputFile() - if outputFile.Valid() { - path = outputFile.Path() + if info, ok := android.OtherModuleProvider(ctx.SdkModuleContext(), ccModule, LinkableInfoProvider); ok && info.OutputFile.Valid() { + path = info.OutputFile.Path() } else { ctx.SdkModuleContext().ModuleErrorf("member variant %s does not have a valid output file", ccModule) } diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index 4f6de82a2..584cc042d 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -333,7 +333,7 @@ func dumpVar(ctx build.Context, config build.Config, args []string) { varName := flags.Arg(0) if varName == "report_config" { - varData, err := build.DumpMakeVars(ctx, config, nil, build.BannerVars) + varData, err := build.DumpMakeVars(ctx, config, nil, append(build.BannerVars, "PRODUCT_SOONG_ONLY")) if err != nil { ctx.Fatal(err) } @@ -400,7 +400,7 @@ func dumpVars(ctx build.Context, config build.Config, args []string) { if i := indexList("report_config", allVars); i != -1 { allVars = append(allVars[:i], allVars[i+1:]...) - allVars = append(allVars, build.BannerVars...) + allVars = append(allVars, append(build.BannerVars, "PRODUCT_SOONG_ONLY")...) } if len(allVars) == 0 { diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 443e80e67..feb000dc4 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -840,6 +840,15 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { Textf("echo avb_enable=true >> %s", miscInfo). Textf("&& echo avb_building_vbmeta_image=true >> %s", miscInfo). Textf("&& echo avb_avbtool=avbtool >> %s", miscInfo) + for _, vbmetaPartitionName := range a.partitionProps.Vbmeta_partitions { + img := ctx.GetDirectDepProxyWithTag(vbmetaPartitionName, filesystemDepTag) + if provider, ok := android.OtherModuleProvider(ctx, img, vbmetaPartitionProvider); ok { + builder.Command().Text("cat").Input(provider.PropFileForMiscInfo).Textf(" >> %s", miscInfo) + } else { + ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", vbmetaPartitionName) + } + } + } if a.partitionProps.Boot_partition_name != nil { builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo) @@ -1046,6 +1055,7 @@ func (a *androidDevice) buildApkCertsInfo(ctx android.ModuleContext, allInstalle } apkCerts := []string{} + var apkCertsFiles android.Paths for _, installedModule := range allInstalledModules { partition := "" if commonInfo, ok := android.OtherModuleProvider(ctx, installedModule, android.CommonModuleInfoProvider); ok { @@ -1054,7 +1064,11 @@ func (a *androidDevice) buildApkCertsInfo(ctx android.ModuleContext, allInstalle ctx.ModuleErrorf("%s does not set CommonModuleInfoKey", installedModule.Name()) } if info, ok := android.OtherModuleProvider(ctx, installedModule, java.AppInfoProvider); ok { - apkCerts = append(apkCerts, formatLine(info.Certificate, info.InstallApkName+".apk", partition)) + if info.AppSet { + apkCertsFiles = append(apkCertsFiles, info.ApkCertsFile) + } else { + apkCerts = append(apkCerts, formatLine(info.Certificate, info.InstallApkName+".apk", partition)) + } } else if info, ok := android.OtherModuleProvider(ctx, installedModule, java.AppInfosProvider); ok { for _, certInfo := range info { // Partition information of apk-in-apex is not exported to the legacy Make packaging system. @@ -1075,7 +1089,14 @@ func (a *androidDevice) buildApkCertsInfo(ctx android.ModuleContext, allInstalle } } + apkCertsInfoWithoutAppSets := android.PathForModuleOut(ctx, "apkcerts_without_app_sets.txt") + android.WriteFileRuleVerbatim(ctx, apkCertsInfoWithoutAppSets, strings.Join(apkCerts, "\n")+"\n") apkCertsInfo := android.PathForModuleOut(ctx, "apkcerts.txt") - android.WriteFileRuleVerbatim(ctx, apkCertsInfo, strings.Join(apkCerts, "\n")+"\n") + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cat, + Description: "combine apkcerts.txt", + Output: apkCertsInfo, + Inputs: append(apkCertsFiles, apkCertsInfoWithoutAppSets), + }) return apkCertsInfo } diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go index 7d37f1ee7..aa06337ca 100644 --- a/filesystem/android_device_product_out.go +++ b/filesystem/android_device_product_out.go @@ -167,7 +167,7 @@ func (a *androidDevice) copyFilesToProductOutForSoongOnly(ctx android.ModuleCont } if proptools.String(a.deviceProps.Android_info) != "" { - installPath := android.PathForModuleInPartitionInstall(ctx, "", "android_info.txt") + installPath := android.PathForModuleInPartitionInstall(ctx, "", "android-info.txt") ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Input: android.PathForModuleSrc(ctx, *a.deviceProps.Android_info), diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index bf7f5b64b..e57e45cb6 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -736,15 +736,14 @@ func TestOverrideModulesInDeps(t *testing.T) { stl: "none", system_shared_libs: [], } - android_filesystem { - name: "myfilesystem", - deps: ["myapp"], + phony { + name: "myapp_phony", + required: ["myapp"], } - android_filesystem { - name: "myfilesystem_overridden", - deps: ["myapp", "myoverrideapp"], + phony { + name: "myoverrideapp_phony", + required: ["myoverrideapp"], } - android_app { name: "myapp", platform_apis: true, @@ -755,15 +754,29 @@ func TestOverrideModulesInDeps(t *testing.T) { base: "myapp", required: ["libbar"], } + android_filesystem { + name: "myfilesystem", + deps: ["myapp"], + } + android_filesystem { + name: "myfilesystem_overridden", + deps: ["myapp", "myoverrideapp"], + } + android_filesystem { + name: "myfilesystem_overridden_indirect", + deps: ["myapp_phony", "myoverrideapp_phony"], + } `) partition := result.ModuleForTests(t, "myfilesystem", "android_common") fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) android.AssertStringEquals(t, "filesystem without override app", "app/myapp/myapp.apk\nlib64/libfoo.so\n", fileList) - overriddenPartition := result.ModuleForTests(t, "myfilesystem_overridden", "android_common") - overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList")) - android.AssertStringEquals(t, "filesystem with override app", "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList) + for _, overridden := range []string{"myfilesystem_overridden", "myfilesystem_overridden_indirect"} { + overriddenPartition := result.ModuleForTests(t, overridden, "android_common") + overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList")) + android.AssertStringEquals(t, "filesystem with "+overridden, "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList) + } } func TestRamdiskPartitionSetsDevNodes(t *testing.T) { diff --git a/filesystem/system_other.go b/filesystem/system_other.go index 348c01035..32a6cc784 100644 --- a/filesystem/system_other.go +++ b/filesystem/system_other.go @@ -120,8 +120,11 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext // TOOD: CopySpecsToDir only exists on PackagingBase, but doesn't use any fields from it. Clean this up. (&android.PackagingBase{}).CopySpecsToDir(ctx, builder, specs, stagingDir) + fullInstallPaths := []string{} if len(m.properties.Preinstall_dexpreopt_files_from) > 0 { builder.Command().Textf("touch %s", filepath.Join(stagingDir.String(), "system-other-odex-marker")) + installPath := android.PathForModuleInPartitionInstall(ctx, "system_other", "system-other-odex-marker") + fullInstallPaths = append(fullInstallPaths, installPath.String()) } builder.Command().Textf("touch").Output(stagingDirTimestamp) builder.Build("assemble_filesystem_staging_dir", "Assemble filesystem staging dir") @@ -186,6 +189,10 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext ctx.SetOutputFiles(android.Paths{output}, "") ctx.CheckbuildFile(output) + + // Dump compliance metadata + complianceMetadataInfo := ctx.ComplianceMetadataInfo() + complianceMetadataInfo.SetFilesContained(fullInstallPaths) } func (s *systemOtherImage) generateFilesystemConfig(ctx android.ModuleContext, stagingDir, stagingDirTimestamp android.Path) android.Path { diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go index 01b453e25..d59a2aec5 100644 --- a/filesystem/vbmeta.go +++ b/filesystem/vbmeta.go @@ -16,7 +16,10 @@ package filesystem import ( "fmt" + "sort" "strconv" + "strings" + "time" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -124,6 +127,10 @@ type vbmetaPartitionInfo struct { // The output of the vbmeta module Output android.Path + + // Information about the vbmeta partition that will be added to misc_info.txt + // created by android_device + PropFileForMiscInfo android.Path } var vbmetaPartitionProvider = blueprint.NewProvider[vbmetaPartitionInfo]() @@ -302,6 +309,7 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { RollbackIndexLocation: ril, PublicKey: extractedPublicKey, Output: output, + PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx), }) ctx.SetOutputFiles([]android.Path{output}, "") @@ -310,6 +318,41 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { setCommonFilesystemInfo(ctx, v) } +func (v *vbmeta) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path { + var lines []string + addStr := func(name string, value string) { + lines = append(lines, fmt.Sprintf("%s=%s", name, value)) + } + + addStr(fmt.Sprintf("avb_%s_algorithm", v.partitionName()), proptools.StringDefault(v.properties.Algorithm, "SHA256_RSA4096")) + if v.properties.Private_key != nil { + addStr(fmt.Sprintf("avb_%s_key_path", v.partitionName()), android.PathForModuleSrc(ctx, proptools.String(v.properties.Private_key)).String()) + } + if v.properties.Rollback_index_location != nil { + addStr(fmt.Sprintf("avb_%s_rollback_index_location", v.partitionName()), strconv.FormatInt(*v.properties.Rollback_index_location, 10)) + } + + var partitionDepNames []string + ctx.VisitDirectDepsProxyWithTag(vbmetaPartitionDep, func(child android.ModuleProxy) { + if info, ok := android.OtherModuleProvider(ctx, child, vbmetaPartitionProvider); ok { + partitionDepNames = append(partitionDepNames, info.Name) + } else { + ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", child) + } + }) + if v.partitionName() != "vbmeta" { // skip for vbmeta to match Make's misc_info.txt + addStr(fmt.Sprintf("avb_%s", v.partitionName()), strings.Join(android.SortedUniqueStrings(partitionDepNames), " ")) + } + + addStr(fmt.Sprintf("avb_%s_args", v.partitionName()), fmt.Sprintf("--padding_size 4096 --rollback_index %s", v.rollbackIndexString(ctx))) + + sort.Strings(lines) + + propFile := android.PathForModuleOut(ctx, "prop_file_for_misc_info") + android.WriteFileRule(ctx, propFile, strings.Join(lines, "\n")) + return propFile +} + // Returns the embedded shell command that prints the rollback index func (v *vbmeta) rollbackIndexCommand(ctx android.ModuleContext) string { if v.properties.Rollback_index != nil { @@ -320,6 +363,17 @@ func (v *vbmeta) rollbackIndexCommand(ctx android.ModuleContext) string { } } +// Similar to rollbackIndexCommand, but guarantees that the rollback index is +// always computed during Soong analysis, even if v.properties.Rollback_index is nil +func (v *vbmeta) rollbackIndexString(ctx android.ModuleContext) string { + if v.properties.Rollback_index != nil { + return fmt.Sprintf("%d", *v.properties.Rollback_index) + } else { + t, _ := time.Parse(time.DateOnly, ctx.Config().PlatformSecurityPatch()) + return fmt.Sprintf("%d", t.Unix()) + } +} + var _ android.AndroidMkProviderInfoProducer = (*vbmeta)(nil) func (v *vbmeta) PrepareAndroidMKProviderInfo(config android.Config) *android.AndroidMkProviderInfo { diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go index 651d2d1a9..2c4d3c817 100644 --- a/fsgen/filesystem_creator_test.go +++ b/fsgen/filesystem_creator_test.go @@ -289,6 +289,10 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { "device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml", "device/sample/etc/apns-full-conf.xml:system/foo/file.txt", "device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml", + "device/sample/firmware/firmware.bin:recovery/root/firmware.bin", + "device/sample/firmware/firmware.bin:recovery/root/firmware-2.bin", + "device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware.bin", + "device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware-2.bin", } config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = map[string]android.PartitionQualifiedVariablesType{ @@ -309,6 +313,7 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { "frameworks/base/data/keyboards/Vendor_0079_Product_0011.kl": nil, "frameworks/base/data/keyboards/Vendor_0079_Product_18d4.kl": nil, "device/sample/etc/apns-full-conf.xml": nil, + "device/sample/firmware/firmware.bin": nil, }), ).RunTest(t) @@ -324,7 +329,7 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { // check generated prebuilt_* module type install path and install partition generatedModule := result.ModuleForTests(t, "system-frameworks_base_config-etc-0", "android_arm64_armv8-a").Module() - etcModule, _ := generatedModule.(*etc.PrebuiltEtc) + etcModule := generatedModule.(*etc.PrebuiltEtc) android.AssertStringEquals( t, "module expected to have etc install path", @@ -342,7 +347,7 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { // check generated prebuilt_* module specifies correct relative_install_path property generatedModule = result.ModuleForTests(t, "system-frameworks_base_data_keyboards-usr_keylayout_subdir-0", "android_arm64_armv8-a").Module() - etcModule, _ = generatedModule.(*etc.PrebuiltEtc) + etcModule = generatedModule.(*etc.PrebuiltEtc) android.AssertStringEquals( t, "module expected to set correct relative_install_path properties", @@ -490,7 +495,7 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { ) // check generated prebuilt_* module specifies correct install path and relative install path - etcModule, _ = generatedModule1.(*etc.PrebuiltEtc) + etcModule = generatedModule1.(*etc.PrebuiltEtc) android.AssertStringEquals( t, "module expected to have . install path", @@ -520,4 +525,138 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { return "" }), ) + + generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-0", "android_recovery_arm64_armv8-a").Module() + generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-1", "android_recovery_common").Module() + + // check generated prebuilt_* module specifies correct install path and relative install path + etcModule = generatedModule0.(*etc.PrebuiltEtc) + android.AssertStringEquals( + t, + "module expected to have . install path", + ".", + etcModule.BaseDir(), + ) + android.AssertStringEquals( + t, + "module expected to set empty relative_install_path properties", + "", + etcModule.SubDir(), + ) + + // check that generated prebuilt_* module don't set dsts + eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) + android.AssertStringEquals( + t, + "module expected to not set dsts property", + "", + getModuleProp(generatedModule0, func(actual interface{}) string { + if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { + dsts := p.Dsts.GetOrDefault(eval, nil) + if len(dsts) != 0 { + return dsts[0] + } + } + return "" + }), + ) + + // check generated prebuilt_* module specifies correct install path and relative install path + etcModule = generatedModule1.(*etc.PrebuiltEtc) + android.AssertStringEquals( + t, + "module expected to have . install path", + ".", + etcModule.BaseDir(), + ) + android.AssertStringEquals( + t, + "module expected to set empty relative_install_path properties", + "", + etcModule.SubDir(), + ) + + // check that generated prebuilt_* module sets correct dsts + eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) + android.AssertStringEquals( + t, + "module expected to set correct dsts property", + "firmware-2.bin", + getModuleProp(generatedModule1, func(actual interface{}) string { + if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { + dsts := p.Dsts.GetOrDefault(eval, nil) + if len(dsts) == 1 { + return dsts[0] + } + } + return "" + }), + ) + + generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-0", "android_recovery_common").Module() + generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-1", "android_recovery_common").Module() + + // check generated prebuilt_* module specifies correct install path and relative install path + etcModule = generatedModule0.(*etc.PrebuiltEtc) + android.AssertStringEquals( + t, + "module expected to have . install path", + ".", + etcModule.BaseDir(), + ) + android.AssertStringEquals( + t, + "module expected to set correct relative_install_path properties", + "lib/firmware", + etcModule.SubDir(), + ) + + // check that generated prebuilt_* module sets correct srcs + eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) + android.AssertStringEquals( + t, + "module expected to not set dsts property", + "", + getModuleProp(generatedModule0, func(actual interface{}) string { + if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { + dsts := p.Dsts.GetOrDefault(eval, nil) + if len(dsts) != 0 { + return dsts[0] + } + } + return "" + }), + ) + + // check generated prebuilt_* module specifies correct install path and relative install path + etcModule = generatedModule1.(*etc.PrebuiltEtc) + android.AssertStringEquals( + t, + "module expected to have . install path", + ".", + etcModule.BaseDir(), + ) + android.AssertStringEquals( + t, + "module expected to set empty relative_install_path properties", + "", + etcModule.SubDir(), + ) + + // check that generated prebuilt_* module sets correct srcs + eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext)) + android.AssertStringEquals( + t, + "module expected to set correct dsts property", + "lib/firmware/firmware-2.bin", + getModuleProp(generatedModule1, func(actual interface{}) string { + if p, ok := actual.(*etc.PrebuiltDstsProperties); ok { + dsts := p.Dsts.GetOrDefault(eval, nil) + if len(dsts) == 1 { + return dsts[0] + } + } + return "" + }), + ) } diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go index e9dabe44c..c0f114caf 100644 --- a/fsgen/prebuilt_etc_modules_gen.go +++ b/fsgen/prebuilt_etc_modules_gen.go @@ -337,6 +337,10 @@ func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition, propsList = append(propsList, &prebuiltInstallInRootProperties{ Install_in_root: proptools.BoolPtr(true), }) + // Discard any previously picked module and force it to prebuilt_{root,any} as + // they are the only modules allowed to specify the `install_in_root` property. + etcInstallPathKey = "" + relDestDirFromInstallDirBase = destDir } // Set appropriate srcs, dsts, and releative_install_path based on diff --git a/java/app.go b/java/app.go index 5c0a9a6ba..05b4a9664 100644 --- a/java/app.go +++ b/java/app.go @@ -82,6 +82,7 @@ type AppInfo struct { Certificate Certificate PrivAppAllowlist android.OptionalPath OverriddenManifestPackageName *string + ApkCertsFile android.Path } var AppInfoProvider = blueprint.NewProvider[*AppInfo]() diff --git a/java/app_set.go b/java/app_set.go index 2e9d31410..6a2c678a8 100644 --- a/java/app_set.go +++ b/java/app_set.go @@ -193,9 +193,10 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) ) android.SetProvider(ctx, AppInfoProvider, &AppInfo{ - AppSet: true, - Privileged: as.Privileged(), - OutputFile: as.OutputFile(), + AppSet: true, + Privileged: as.Privileged(), + OutputFile: as.OutputFile(), + ApkCertsFile: as.apkcertsFile, }) } diff --git a/java/dex.go b/java/dex.go index dd6467546..f2406fb3c 100644 --- a/java/dex.go +++ b/java/dex.go @@ -42,6 +42,9 @@ type DexProperties struct { // True if the module containing this has it set by default. EnabledByDefault bool `blueprint:"mutated"` + // If true, then this module will be optimized on eng builds. + Enabled_on_eng *bool + // Whether to allow that library classes inherit from program classes. // Defaults to false. Ignore_library_extends_program *bool @@ -162,7 +165,10 @@ type dexer struct { } func (d *dexer) effectiveOptimizeEnabled(ctx android.EarlyModuleContext) bool { - return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault && !ctx.Config().Eng()) + if ctx.Config().Eng() { + return proptools.Bool(d.dexProperties.Optimize.Enabled_on_eng) + } + return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault) } func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool { diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go index cd49ec876..622aadb95 100644 --- a/ui/build/androidmk_denylist.go +++ b/ui/build/androidmk_denylist.go @@ -15,20 +15,29 @@ package build import ( + "os" + "slices" "strings" ) var androidmk_denylist []string = []string{ + "art/", "bionic/", - "chained_build_config/", + "bootable/", + "build/", "cts/", "dalvik/", "developers/", "development/", "device/common/", + "device/generic/", + "device/google/", "device/google_car/", "device/sample/", + "external/", "frameworks/", + "hardware/google/", + "hardware/interfaces/", "hardware/libhardware/", "hardware/libhardware_legacy/", "hardware/ril/", @@ -45,24 +54,38 @@ var androidmk_denylist []string = []string{ "sdk/", "system/", "test/", + "tools/", "trusty/", - // Add back toolchain/ once defensive Android.mk files are removed - //"toolchain/", - "vendor/google_contexthub/", - "vendor/google_data/", - "vendor/google_elmyra/", - "vendor/google_mhl/", - "vendor/google_pdk/", - "vendor/google_testing/", - "vendor/partner_testing/", - "vendor/partner_tools/", - "vendor/pdk/", + "toolchain/", +} + +var androidmk_allowlist []string = []string{ + "art/Android.mk", + "bootable/deprecated-ota/updater/Android.mk", +} + +func getAllLines(ctx Context, filename string) []string { + bytes, err := os.ReadFile(filename) + if err != nil { + if os.IsNotExist(err) { + return []string{} + } else { + ctx.Fatalf("Could not read %s: %v", filename, err) + } + } + return strings.Split(strings.Trim(string(bytes), " \n"), "\n") } func blockAndroidMks(ctx Context, androidMks []string) { + allowlist := getAllLines(ctx, "vendor/google/build/androidmk/allowlist.txt") + androidmk_allowlist = append(androidmk_allowlist, allowlist...) + + denylist := getAllLines(ctx, "vendor/google/build/androidmk/denylist.txt") + androidmk_denylist = append(androidmk_denylist, denylist...) + for _, mkFile := range androidMks { for _, d := range androidmk_denylist { - if strings.HasPrefix(mkFile, d) { + if strings.HasPrefix(mkFile, d) && !slices.Contains(androidmk_allowlist, mkFile) { ctx.Fatalf("Found blocked Android.mk file: %s. "+ "Please see androidmk_denylist.go for the blocked directories and contact build system team if the file should not be blocked.", mkFile) } @@ -86,6 +109,12 @@ var external_androidmks []string = []string{ // These directories hold the published Android SDK, used in Unbundled Gradle builds. "prebuilts/fullsdk-darwin", "prebuilts/fullsdk-linux", + // wpa_supplicant_8 has been converted to Android.bp and Android.mk files are kept for troubleshooting. + "external/wpa_supplicant_8/", + // Empty Android.mk in package's top directory + "external/proguard/", + "external/swig/", + "toolchain/", } var art_androidmks = []string{ diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index 16a3db8e6..710be8407 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -181,7 +181,12 @@ func Banner(config Config, make_vars map[string]string) string { fmt.Fprintf(b, "%s=%s\n", name, make_vars[name]) } } - fmt.Fprintf(b, "SOONG_ONLY=%t\n", config.soongOnlyRequested) + if config.skipKatiControlledByFlags { + fmt.Fprintf(b, "SOONG_ONLY=%t\n", config.soongOnlyRequested) + } else { // default for this product + fmt.Fprintf(b, "SOONG_ONLY=%t\n", make_vars["PRODUCT_SOONG_ONLY"] == "true") + } + fmt.Fprint(b, "============================================") return b.String() diff --git a/ui/build/finder.go b/ui/build/finder.go index 783b48863..ff8908b29 100644 --- a/ui/build/finder.go +++ b/ui/build/finder.go @@ -84,8 +84,14 @@ func NewSourceFinder(ctx Context, config Config) (f *finder.Finder) { // METADATA file of packages "METADATA", }, - // .mk files for product/board configuration. - IncludeSuffixes: []string{".mk"}, + IncludeSuffixes: []string{ + // .mk files for product/board configuration. + ".mk", + // otatools cert files + ".pk8", + ".pem", + ".avbpubkey", + }, } dumpDir := config.FileListDir() f, err = finder.New(cacheParams, filesystem, logger.New(ioutil.Discard), @@ -118,6 +124,18 @@ func findProductAndBoardConfigFiles(entries finder.DirEntries) (dirNames []strin return entries.DirNames, matches } +func findOtaToolsCertFiles(entries finder.DirEntries) (dirNames []string, fileNames []string) { + matches := []string{} + for _, foundName := range entries.FileNames { + if strings.HasSuffix(foundName, ".pk8") || + strings.HasSuffix(foundName, ".pem") || + strings.HasSuffix(foundName, ".avbpubkey") { + matches = append(matches, foundName) + } + } + return entries.DirNames, matches +} + // FindSources searches for source files known to <f> and writes them to the filesystem for // use later. func FindSources(ctx Context, config Config, f *finder.Finder) { @@ -184,6 +202,17 @@ func FindSources(ctx Context, config Config, f *finder.Finder) { ctx.Fatalf("Could not find TEST_MAPPING: %v", err) } + // Recursively look for all otatools cert files. + otatools_cert_files := f.FindMatching("build/make/target/product/security", findOtaToolsCertFiles) + otatools_cert_files = append(otatools_cert_files, f.FindMatching("device", findOtaToolsCertFiles)...) + otatools_cert_files = append(otatools_cert_files, f.FindMatching("external/avb/test/data", findOtaToolsCertFiles)...) + otatools_cert_files = append(otatools_cert_files, f.FindMatching("packages/modules", findOtaToolsCertFiles)...) + otatools_cert_files = append(otatools_cert_files, f.FindMatching("vendor", findOtaToolsCertFiles)...) + err = dumpListToFile(ctx, config, otatools_cert_files, filepath.Join(dumpDir, "OtaToolsCertFiles.list")) + if err != nil { + ctx.Fatalf("Could not find otatools cert files: %v", err) + } + // Recursively look for all Android.bp files androidBps := f.FindNamedAt(".", "Android.bp") if len(androidBps) == 0 { |