From 1c9f3e3a43d01fc231d981c13ad21278ea50f842 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Wed, 19 Mar 2025 12:42:04 -0700 Subject: Revert^2 "Block new Android.mk added to all directories except the directories for partners" This reverts commit a60960b3684abdbd505f8a64e2ab9cc5f68eddd6. Reason for revert: reland Add "bootable/deprecated-ota/updater/Android.mk" in variable "androidmk_allowlist" instead of the file allowlist.txt since some branches might not have vendor/ so allowlist.txt is not availble. go/abtd/run/L32300030010515897 to test this CL with the broken branch. Change-Id: I4b0fb0628f3b995fac340a3e391940b7a6045246 --- ui/build/androidmk_denylist.go | 55 ++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-) 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{ -- cgit v1.2.3-59-g8ed1b From b790b9cb8f891bf21755ccc97a5405b2ed0687d2 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 19 Mar 2025 14:12:09 -0700 Subject: Clear as much of cc.Module as possible after GenerateBuildActions Reduce peak memory usage by adding a CleanupAfterBuildActions method that is called at the end GenerateBuidlActions, nad use it to clear as much of cc.Module as possible. This is a temporary measure, eventually the entire module should be released by blueprint once all interactions are performed through providers. Test: all soong tests pass Change-Id: Idc3390ae4506ff2eef3231691e1de7446067961a --- android/module.go | 12 ++++++++++++ android/module_proxy.go | 4 ++++ cc/cc.go | 21 +++++++++++++++++++++ rust/fuzz_test.go | 25 ++++++++++++++++--------- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/android/module.go b/android/module.go index ecd0f239c..c0abfd0a3 100644 --- a/android/module.go +++ b/android/module.go @@ -45,6 +45,14 @@ type Module interface { // For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go GenerateAndroidBuildActions(ModuleContext) + // CleanupAfterBuildActions is called after ModuleBase.GenerateBuildActions is finished. + // If all interactions with this module are handled via providers instead of direct access + // to the module then it can free memory attached to the module. + // This is a temporary measure to reduce memory usage, eventually blueprint's reference + // to the Module should be dropped after GenerateAndroidBuildActions once all accesses + // can be done through providers. + CleanupAfterBuildActions() + // Add dependencies to the components of a module, i.e. modules that are created // by the module and which are considered to be part of the creating module. // @@ -2387,8 +2395,12 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) }) } } + + m.module.CleanupAfterBuildActions() } +func (m *ModuleBase) CleanupAfterBuildActions() {} + func SetJarJarPrefixHandler(handler func(ModuleContext)) { if jarJarPrefixHandler != nil { panic("jarJarPrefixHandler already set") diff --git a/android/module_proxy.go b/android/module_proxy.go index 561c4770c..81d90e9a0 100644 --- a/android/module_proxy.go +++ b/android/module_proxy.go @@ -27,6 +27,10 @@ func (m ModuleProxy) GenerateAndroidBuildActions(context ModuleContext) { panic("method is not implemented on ModuleProxy") } +func (m ModuleProxy) CleanupAfterBuildActions() { + panic("method is not implemented on ModuleProxy") +} + func (m ModuleProxy) ComponentDepsMutator(ctx BottomUpMutatorContext) { panic("method is not implemented on ModuleProxy") } diff --git a/cc/cc.go b/cc/cc.go index 85d2ebfbb..c616165c5 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -2438,6 +2438,27 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } +func (c *Module) CleanupAfterBuildActions() { + // Clear as much of Module as possible to reduce memory usage. + c.generators = nil + c.compiler = nil + c.installer = nil + c.features = nil + c.coverage = nil + c.fuzzer = nil + c.sabi = nil + c.lto = nil + c.afdo = nil + c.orderfile = nil + + // TODO: these can be cleared after nativeBinaryInfoProperties and nativeLibInfoProperties are switched to + // using providers. + // c.linker = nil + // c.stl = nil + // c.sanitize = nil + // c.library = nil +} + func CreateCommonLinkableInfo(ctx android.ModuleContext, mod VersionedLinkableInterface) *LinkableInfo { info := &LinkableInfo{ StaticExecutable: mod.StaticExecutable(), diff --git a/rust/fuzz_test.go b/rust/fuzz_test.go index bdcfbbba1..f462795aa 100644 --- a/rust/fuzz_test.go +++ b/rust/fuzz_test.go @@ -134,17 +134,24 @@ func TestCCFuzzDepBundling(t *testing.T) { } `) - fuzz_shared_libtest := ctx.ModuleForTests(t, "fuzz_shared_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface) - fuzz_static_libtest := ctx.ModuleForTests(t, "fuzz_static_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface) - fuzz_staticffi_libtest := ctx.ModuleForTests(t, "fuzz_staticffi_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface) + fuzz_shared_libtest := ctx.ModuleForTests(t, "fuzz_shared_libtest", "android_arm64_armv8-a_fuzzer").Module() + fuzz_static_libtest := ctx.ModuleForTests(t, "fuzz_static_libtest", "android_arm64_armv8-a_fuzzer").Module() + fuzz_staticffi_libtest := ctx.ModuleForTests(t, "fuzz_staticffi_libtest", "android_arm64_armv8-a_fuzzer").Module() - if !strings.Contains(fuzz_shared_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") { - t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_shared ('libcc_transitive_dep'): %#v", fuzz_shared_libtest.FuzzSharedLibraries().String()) + fuzzSharedLibraries := func(module android.Module) string { + if info, ok := android.OtherModuleProvider(ctx, module, cc.LinkableInfoProvider); ok { + return info.FuzzSharedLibraries.String() + } + return "" } - if !strings.Contains(fuzz_static_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") { - t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_static_libtest.FuzzSharedLibraries().String()) + + if libs := fuzzSharedLibraries(fuzz_shared_libtest); !strings.Contains(libs, ":libcc_transitive_dep.so") { + t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_shared ('libcc_transitive_dep'): %#v", libs) + } + if libs := fuzzSharedLibraries(fuzz_static_libtest); !strings.Contains(libs, ":libcc_transitive_dep.so") { + t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", libs) } - if !strings.Contains(fuzz_staticffi_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") { - t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_staticffi_libtest.FuzzSharedLibraries().String()) + if libs := fuzzSharedLibraries(fuzz_staticffi_libtest); !strings.Contains(libs, ":libcc_transitive_dep.so") { + t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", libs) } } -- cgit v1.2.3-59-g8ed1b From 670efb65fe0e535d889c5e37e91f2ae6af5d0ad5 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 20 Mar 2025 02:37:25 +0000 Subject: Print the default SOONG_ONLY value of the product in lunch output SOONG_ONLY=false is currently printed as the output of lunch even for enabled products such as `aosp_cf_x86_64_phone`. config.soongOnlyRequested evaluates to true during the main build (it invokes `runMakeProductConfig), but is currently always false when used in report_config. Test: lunch aosp_cf_x86_64_phone-trunk_staging-userdebug # SOONG_ONLY=true (previously false) Test: lunch cf_x86_64_phone-trunk_staging-userdebug # SOONG_ONLY=false Bug: 402519768 Change-Id: If859695a583c6627af05fb62eb0f8b3fa93aeec8 --- cmd/soong_ui/main.go | 4 ++-- ui/build/dumpvars.go | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) 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/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() -- cgit v1.2.3-59-g8ed1b From 373f04120d1482ee3ee6d743d3a453f0032bed23 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Wed, 19 Mar 2025 21:21:04 +0100 Subject: fsgen: Use prebuilt_{root,any} in case install_in_root is set If any of the other modules relative dir matches (eg lib/) it would hit a neverallow as installing in the root directory is allowlisted. Test: m --no-skip-soong-tests Test: m on tegra device with PRODUCT_COPY_FILES += \ tegra21x_xusb_firmware:recovery/root/tegra21x_xusb_firmware \ Change-Id: I157826703974544614f0049b8fa157358e7b17a7 --- fsgen/filesystem_creator_test.go | 139 ++++++++++++++++++++++++++++++++++++++ fsgen/prebuilt_etc_modules_gen.go | 4 ++ 2 files changed, 143 insertions(+) diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go index 651d2d1a9..8f6b4b896 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) @@ -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 -- cgit v1.2.3-59-g8ed1b From 7fbc13d6b23a970df5a2665770075201d6502928 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Wed, 19 Mar 2025 23:20:53 +0100 Subject: Panic prebuilt etc module gen test if module isn't PrebuiltEtc Test: m --no-skip-soong-tests Change-Id: Idda28cf77d9f95fde5542a73dbbe633b1f55fcf9 --- fsgen/filesystem_creator_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go index 8f6b4b896..2c4d3c817 100644 --- a/fsgen/filesystem_creator_test.go +++ b/fsgen/filesystem_creator_test.go @@ -329,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", @@ -347,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", @@ -495,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", @@ -530,7 +530,7 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { 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) + etcModule = generatedModule0.(*etc.PrebuiltEtc) android.AssertStringEquals( t, "module expected to have . install path", @@ -562,7 +562,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", @@ -597,7 +597,7 @@ func TestPrebuiltEtcModuleGen(t *testing.T) { 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) + etcModule = generatedModule0.(*etc.PrebuiltEtc) android.AssertStringEquals( t, "module expected to have . install path", @@ -629,7 +629,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", -- cgit v1.2.3-59-g8ed1b From 761504986f77360de49aeea124d2b8b00cfd8ec5 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Thu, 20 Mar 2025 10:46:06 +0900 Subject: Fix overridden deps to be skipped correctly Current implementation only checks the name of the direct child and the owner of the packaging spec. But this can cause unintentionally installing unnecessary dependencies of overridden modules. This can be fixed by 1) gathering all overridden modules, 2) walking deps with skipping overridden modules, and 3) installing packages from visitied modules only. Bug: 330141242 Test: TH Test: try building pixel system image Change-Id: I4a646941b61e890b5cd2c9aa137e74c80777f837 --- android/packaging.go | 41 ++++++++++++++++++++++++++--------------- filesystem/filesystem_test.go | 33 +++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 25 deletions(-) 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/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) { -- cgit v1.2.3-59-g8ed1b From 39c88e6ba39cc30a5e685d5d93f86bb1845fa98c Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 20 Mar 2025 10:15:24 -0700 Subject: Fix depfile in otatoolsPackageCertRule The depfile dependencies must all be on the same line as the output file. (or escape the newlines with backslashes) Bug: 395988167 Test: m otatools_package_cert_files(-soong if on soong+make builds), observe it builds. Rerun command, observe it doesn't build. touch packages/modules/adb/apex/com.android.adbd.avbpubkey and rerun command, observe it builds again. Change-Id: I2b2ee397b406488797e16b04880d0396784029fe --- android/otatools_package_cert_zip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/otatools_package_cert_zip.go b/android/otatools_package_cert_zip.go index 03265cad3..3a654cfe5 100644 --- a/android/otatools_package_cert_zip.go +++ b/android/otatools_package_cert_zip.go @@ -39,7 +39,7 @@ func OtatoolsPackageFactory() Module { var ( otatoolsPackageCertRule = pctx.AndroidStaticRule("otatools_package_cert_files", blueprint.RuleParams{ - Command: "echo $out: > ${out}.d && cat $in >> ${out}.d && ${SoongZipCmd} -o $out -l $in", + Command: "echo '$out : ' $$(cat $in) > ${out}.d && ${SoongZipCmd} -o $out -l $in", CommandDeps: []string{"${SoongZipCmd}"}, Depfile: "${out}.d", Description: "Zip otatools-package cert files", -- cgit v1.2.3-59-g8ed1b From 865c01484ae4d898400a57608af5361d98322f6c Mon Sep 17 00:00:00 2001 From: Zhi Dou Date: Thu, 20 Mar 2025 10:32:38 -0700 Subject: This change add exported flags to droidcore This change adds exported flag check to droidcore. Then when build the cf image, it will trigger the exported flag check. Test: m Bug: 336800305 Ignore-AOSP-First: need to submit with other change, will cherry pick to aosp once submitted (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:aa9cafa688b7d4cd43125bae041b1be15d71e58e) Merged-In: Iff6e95784ba17c7c2f4d563a4940bcf934558acc Change-Id: Iff6e95784ba17c7c2f4d563a4940bcf934558acc --- aconfig/all_aconfig_declarations.go | 1 + 1 file changed, 1 insertion(+) 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) } } -- cgit v1.2.3-59-g8ed1b From 6ef0d742df8fac26be3d4396b60c4332cf371b44 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Thu, 20 Mar 2025 18:31:54 +0000 Subject: Use provider to get outpath in getRequiredMemberOutputFile. Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: Iae0d301db244f9543e4da2d6bae01b3320e3a9e4 --- cc/library_sdk_member.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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) } -- cgit v1.2.3-59-g8ed1b From 91e05ea05655e9a8d7c1e661f82ce0f71bc57117 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 20 Mar 2025 15:09:04 -0700 Subject: Make d8-on-eng a per-module opt-out Several modules use defaults that set `enabled`, rather than relying on the defaults. With this change, eng builds no use d8 instead of r8, with the exception of unit tests in prebuilts/r8. Bug: b/374975543 Test: manual, TH Change-Id: I377d354f005529d04fb9d9255afa73979935f091 --- java/dex.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3-59-g8ed1b From b9a83f1de48de2520b00611c7cf0c373d8f714b9 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 20 Mar 2025 23:35:47 +0000 Subject: Use Source_apex_name for LOCAL_MODULE in Soong gen Android.mk For versioned mainline prebuilts, the version is getting written to `LOCAL_MODULE` property in the generated Android.mk file, even when they set Source_apex_name. This CL uses Source_apex_name as the LOCAL_MODULE so that the versioned prebuilt does not get elided from product packaging. Test: m nothing --no-skip-soong-tests Bug: 405153030 Change-Id: I15a6c6d8a3906cced87771ddde05563209c26bc2 --- android/androidmk.go | 3 +++ apex/apex_test.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/android/androidmk.go b/android/androidmk.go index 694f5d66b..5adc84982 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/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) + } } } -- cgit v1.2.3-59-g8ed1b From b6b93c28fa1dd941b1fb2a4bb3f8db32df0354a0 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Fri, 21 Mar 2025 11:03:10 -0700 Subject: Set symbols related make variables in apexBundle's androidMkForType() ALL_MODULES.$(my_register_name).SYMBOLIC_OUTPUT_PATH and ALL_MODULES.$(my_register_name).ELF_SYMBOL_MAPPING_PATH variables are used in generating symbols.zip and the elf mapping proto file. Setting these variables in the apex bundle allows the symbols of the modules included in the apex to be collected properly. Test: build mainline && inspect symbols.zip Change-Id: I08715a278e5fe508793ebee0f1e6feee1c234970 --- apex/androidmk.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/apex/androidmk.go b/apex/androidmk.go index 3a81ee4e6..0a5644ae3 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -75,7 +75,7 @@ func (a *apexBundle) fullModuleName(apexBundleName string, linkToSystemLib bool, // populated by Soong for unconverted APEXes, or Bazel in mixed mode. Use // apexFile#isBazelPrebuilt to differentiate. func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir string, - apexAndroidMkData android.AndroidMkData) []string { + apexAndroidMkData android.AndroidMkData) (archSpecificModuleNames []string, moduleNames []string) { // apexBundleName comes from the 'name' property or soong module. // apexName comes from 'name' property of apex_manifest. @@ -84,11 +84,12 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir st // However, symbol files for apex files are installed under /apex/ to avoid // conflicts between two apexes with the same apexName. - moduleNames := []string{} - for _, fi := range a.filesInfo { linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform() moduleName := a.fullModuleName(apexBundleName, linkToSystemLib, &fi) + if !android.InList(moduleName, moduleNames) { + moduleNames = append(moduleNames, moduleName) + } // This name will be added to LOCAL_REQUIRED_MODULES of the APEX. We need to be // arch-specific otherwise we will end up installing both ABIs even when only @@ -100,8 +101,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir st case "lib64": aName = aName + ":64" } - if !android.InList(aName, moduleNames) { - moduleNames = append(moduleNames, aName) + if !android.InList(aName, archSpecificModuleNames) { + archSpecificModuleNames = append(archSpecificModuleNames, aName) } if linkToSystemLib { @@ -216,7 +217,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir st fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName) } } - return moduleNames + return } func (a *apexBundle) writeRequiredModules(w io.Writer, moduleNames []string) { @@ -235,9 +236,10 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { return android.AndroidMkData{ // While we do not provide a value for `Extra`, AconfigUpdateAndroidMkData may add some, which we must honor. Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { + archSpecificModuleNames := []string{} moduleNames := []string{} if a.installable() { - moduleNames = a.androidMkForFiles(w, name, moduleDir, data) + archSpecificModuleNames, moduleNames = a.androidMkForFiles(w, name, moduleDir, data) } fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle") @@ -274,7 +276,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { } android.AndroidMkEmitAssignList(w, "LOCAL_OVERRIDES_MODULES", a.overridableProperties.Overrides) - a.writeRequiredModules(w, moduleNames) + a.writeRequiredModules(w, archSpecificModuleNames) // AconfigUpdateAndroidMkData may have added elements to Extra. Process them here. for _, extra := range data.Extra { extra(w, a.outputFile) @@ -296,6 +298,9 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintln(w, dist) } + fmt.Fprintf(w, "ALL_MODULES.$(my_register_name).SYMBOLIC_OUTPUT_PATH := $(foreach m,%s,$(ALL_MODULES.$(m).SYMBOLIC_OUTPUT_PATH))\n", strings.Join(moduleNames, " ")) + fmt.Fprintf(w, "ALL_MODULES.$(my_register_name).ELF_SYMBOL_MAPPING_PATH := $(foreach m,%s,$(ALL_MODULES.$(m).ELF_SYMBOL_MAPPING_PATH))\n", strings.Join(moduleNames, " ")) + distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisUsedByModuleFile.String()) distCoverageFiles(w, "ndk_apis_backedby_apex", a.nativeApisBackedByModuleFile.String()) distCoverageFiles(w, "java_apis_used_by_apex", a.javaApisUsedByModuleFile.String()) -- cgit v1.2.3-59-g8ed1b From a9e6b29feef1d0a1ffc56931f2632087677073d9 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 20 Mar 2025 18:26:03 +0000 Subject: Create avb_recovery_add_hash_footer_args entry in misc_info.txt This CL creates an additional avb_recovery_add_hash_footer_args entry for bootimages with a ramdisk that contains a recovery partition. strings.ReplaceAll will be used to convert ``` --prop com.android.build.vendor_boot.fingerprint:generic/aosp_cf_x86_64_phone/vsoc_x86_64:Baklava/MAIN/eng.spanda:userdebug/test-keys ``` to ``` --prop com.android.build.recovery.fingerprint:generic/aosp_cf_x86_64_phone/vsoc_x86_64:Baklava/MAIN/eng.spanda:userdebug/test-keys ``` Test: Built and diff'd locally Bug: 398036609 Change-Id: I0caa8aa9e2e86b9c78352d3038951e00f689dc1a --- filesystem/bootimg.go | 8 ++++++++ filesystem/filesystem.go | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index 5ab0c6899..485eae47c 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -539,6 +539,14 @@ func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Pa bootImgType := proptools.String(b.properties.Boot_image_type) addStr("avb_"+bootImgType+"_add_hash_footer_args", b.getAvbHashFooterArgs(ctx)) + if ramdisk := proptools.String(b.properties.Ramdisk_module); ramdisk != "" { + ramdiskModule := ctx.GetDirectDepWithTag(ramdisk, bootimgRamdiskDep) + fsInfo, _ := android.OtherModuleProvider(ctx, ramdiskModule, FilesystemProvider) + if fsInfo.HasOrIsRecovery { + // Create a dup entry for recovery + addStr("avb_recovery_add_hash_footer_args", strings.ReplaceAll(b.getAvbHashFooterArgs(ctx), bootImgType, "recovery")) + } + } if b.properties.Avb_private_key != nil { addStr("avb_"+bootImgType+"_algorithm", proptools.StringDefault(b.properties.Avb_algorithm, "SHA256_RSA4096")) addStr("avb_"+bootImgType+"_key_path", android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key)).String()) diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 411770be9..ad4366b2e 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -463,6 +463,9 @@ type FilesystemInfo struct { AvbAlgorithm string AvbHashAlgorithm string AvbKey android.Path + PartitionName string + // HasOrIsRecovery returns true for recovery and for ramdisks with a recovery partition. + HasOrIsRecovery bool } // FullInstallPathInfo contains information about the "full install" paths of all the files @@ -720,6 +723,8 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { HasFsverity: f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) != nil, PropFileForMiscInfo: propFileForMiscInfo, PartitionSize: f.properties.Partition_size, + PartitionName: f.partitionName(), + HasOrIsRecovery: f.hasOrIsRecovery(ctx), } if proptools.Bool(f.properties.Use_avb) { fsInfo.UseAvb = true @@ -1307,6 +1312,19 @@ func includeFilesInstalledFiles(ctx android.ModuleContext) (ret []depset.DepSet[ return } +func (f *filesystem) hasOrIsRecovery(ctx android.ModuleContext) bool { + if f.partitionName() == "recovery" { + return true + } + ret := false + ctx.VisitDirectDepsWithTag(interPartitionInstallDependencyTag, func(m android.Module) { + if fsProvider, ok := android.OtherModuleProvider(ctx, m, FilesystemProvider); ok && fsProvider.PartitionName == "recovery" { + ret = true + } + }) + return ret +} + func (f *filesystem) buildCpioImage( ctx android.ModuleContext, builder *android.RuleBuilder, -- cgit v1.2.3-59-g8ed1b From 1bf169a34ce865e686feae2a239ac6c099b56f00 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 21 Mar 2025 16:56:06 +0000 Subject: Add `avb_custom_vbmeta_images_partition_list` to misc_info.txt Make generates this from `BOARD_AVB_VBMETA_CUSTOM_PARTITIONS`. To generate this in Soong, a new Filesytem_partition_type is added to vbmeta modules. For the chained vbmeta partitions for cuttlefish, this will be - system - vendor - system_dlkm - vendor_dlkm android_device will query this information from its vbmeta partitions, and filter out system and vendor. Bug: 398036609 Test: Built and diff'd misc_info.txt locally Change-Id: I8ff3fe5e5e50504e49abbf89f7d50be472e64e30 --- filesystem/android_device.go | 11 +++++++++++ filesystem/vbmeta.go | 18 +++++++++++++----- fsgen/vbmeta_partitions.go | 16 +++++++++------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 02bad0a3c..18276d43e 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -840,14 +840,25 @@ 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) + + var allChainedVbmetaPartitionTypes []string 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) + if provider.FilesystemPartitionType != "" { // the top-level vbmeta.img + allChainedVbmetaPartitionTypes = append(allChainedVbmetaPartitionTypes, provider.FilesystemPartitionType) + } } else { ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", vbmetaPartitionName) } } + // Determine the custom vbmeta partitions by removing system and vendor + customVbmetaPartitionTypes := android.RemoveListFromList(allChainedVbmetaPartitionTypes, []string{"system", "vendor"}) + builder.Command().Textf("echo avb_custom_vbmeta_images_partition_list=%s >> %s", + strings.Join(android.SortedUniqueStrings(customVbmetaPartitionTypes), " "), + miscInfo, + ) } if a.partitionProps.Boot_partition_name != nil { diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go index d59a2aec5..e7a39bef7 100644 --- a/filesystem/vbmeta.go +++ b/filesystem/vbmeta.go @@ -55,6 +55,10 @@ type VbmetaProperties struct { // Name of the partition stored in vbmeta desc. Defaults to the name of this module. Partition_name *string + // Type of the `android_filesystem` for which the vbmeta.img is created. + // Examples are system, vendor, product. + Filesystem_partition_type *string + // Set the name of the output. Defaults to .img. Stem *string @@ -118,6 +122,9 @@ type vbmetaPartitionInfo struct { // Name of the partition Name string + // Partition type of the correspdonding android_filesystem. + FilesystemPartitionType string + // Rollback index location, non-negative int RollbackIndexLocation int @@ -305,11 +312,12 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { }) android.SetProvider(ctx, vbmetaPartitionProvider, vbmetaPartitionInfo{ - Name: v.partitionName(), - RollbackIndexLocation: ril, - PublicKey: extractedPublicKey, - Output: output, - PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx), + Name: v.partitionName(), + FilesystemPartitionType: proptools.String(v.properties.Filesystem_partition_type), + RollbackIndexLocation: ril, + PublicKey: extractedPublicKey, + Output: output, + PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx), }) ctx.SetOutputFiles([]android.Path{output}, "") diff --git a/fsgen/vbmeta_partitions.go b/fsgen/vbmeta_partitions.go index 11f4bd013..594c40482 100644 --- a/fsgen/vbmeta_partitions.go +++ b/fsgen/vbmeta_partitions.go @@ -76,6 +76,7 @@ func (f *filesystemCreator) createVbmetaPartitions(ctx android.LoadHookContext, var chainedPartitionTypes []string for _, chainedName := range android.SortedKeys(partitionVars.ChainedVbmetaPartitions) { props := partitionVars.ChainedVbmetaPartitions[chainedName] + filesystemPartitionType := chainedName chainedName = "vbmeta_" + chainedName if len(props.Partitions) == 0 { continue @@ -123,13 +124,14 @@ func (f *filesystemCreator) createVbmetaPartitions(ctx android.LoadHookContext, filesystem.VbmetaFactory, ".", // Create in the root directory for now so its easy to get the key &filesystem.VbmetaProperties{ - Partition_name: proptools.StringPtr(chainedName), - Stem: proptools.StringPtr(chainedName + ".img"), - Private_key: proptools.StringPtr(props.Key), - Algorithm: &props.Algorithm, - Rollback_index: rollbackIndex, - Rollback_index_location: &ril, - Partitions: proptools.NewSimpleConfigurable(partitionModules), + Partition_name: proptools.StringPtr(chainedName), + Filesystem_partition_type: proptools.StringPtr(filesystemPartitionType), + Stem: proptools.StringPtr(chainedName + ".img"), + Private_key: proptools.StringPtr(props.Key), + Algorithm: &props.Algorithm, + Rollback_index: rollbackIndex, + Rollback_index_location: &ril, + Partitions: proptools.NewSimpleConfigurable(partitionModules), }, &struct { Name *string }{ -- cgit v1.2.3-59-g8ed1b From a85dbb2bef1f34f0c08d1b418ca699aed43e91f9 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 21 Mar 2025 17:49:52 +0000 Subject: Add some OTA related properties to android_device These will be used to create misc_info.txt Bug: 398036609 Test: Built and diff'd Make and Soong misc_info.txt Change-Id: I53cd4f409c9a3a706165119c0d01f1ced5542a2b --- android/variable.go | 4 ++++ filesystem/android_device.go | 12 ++++++++++++ fsgen/filesystem_creator.go | 17 ++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/android/variable.go b/android/variable.go index c59857ad9..7eb08a08a 100644 --- a/android/variable.go +++ b/android/variable.go @@ -721,6 +721,10 @@ type PartitionVariables struct { ReleaseToolsExtensionDir string `json:",omitempty"` + BoardPartialOtaUpdatePartitionsList []string `json:",omitempty"` + BoardFlashBlockSize string `json:",omitempty"` + BootloaderInUpdatePackage bool `json:",omitempty"` + BoardFastbootInfoFile string `json:",omitempty"` } diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 18276d43e..8af0fdff6 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -90,6 +90,10 @@ type DeviceProperties struct { Releasetools_extension *string `android:"path"` FastbootInfo *string `android:"path"` + Partial_ota_update_partitions []string + Flash_block_size *string + Bootloader_in_update_package *bool + // The kernel version in the build. Will be verified against the actual kernel. // If not provided, will attempt to extract it from the loose kernel or the kernel inside // the boot image. The version is later used to decide whether or not to enable uffd_gc @@ -894,6 +898,14 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { builder.Command().Text("cat").Input(bootImgInfo.PropFileForMiscInfo).Textf(" >> %s", miscInfo) } + builder.Command().Textf("echo blocksize=%s >> %s", proptools.String(a.deviceProps.Flash_block_size), miscInfo) + if proptools.Bool(a.deviceProps.Bootloader_in_update_package) { + builder.Command().Textf("echo bootloader_in_update_package=true >> %s", miscInfo) + } + if len(a.deviceProps.Partial_ota_update_partitions) > 0 { + builder.Command().Textf("echo partial_ota_update_partitions_list=%s >> %s", strings.Join(a.deviceProps.Partial_ota_update_partitions, " "), miscInfo) + } + // Sort and dedup builder.Command().Textf("sort -u %s -o %s", miscInfo, miscInfo) diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go index b73fb219f..14aa062fc 100644 --- a/fsgen/filesystem_creator.go +++ b/fsgen/filesystem_creator.go @@ -419,13 +419,16 @@ func (f *filesystemCreator) createDeviceModule( partitionProps.Vbmeta_partitions = vbmetaPartitions deviceProps := &filesystem.DeviceProperties{ - Main_device: proptools.BoolPtr(true), - Ab_ota_updater: proptools.BoolPtr(ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaUpdater), - Ab_ota_partitions: ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaPartitions, - Ab_ota_postinstall_config: ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaPostInstallConfig, - Ramdisk_node_list: proptools.StringPtr(":ramdisk_node_list"), - Android_info: proptools.StringPtr(":" + generatedModuleName(ctx.Config(), "android_info.prop{.txt}")), - Kernel_version: ctx.Config().ProductVariables().BoardKernelVersion, + Main_device: proptools.BoolPtr(true), + Ab_ota_updater: proptools.BoolPtr(ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaUpdater), + Ab_ota_partitions: ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaPartitions, + Ab_ota_postinstall_config: ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.AbOtaPostInstallConfig, + Ramdisk_node_list: proptools.StringPtr(":ramdisk_node_list"), + Android_info: proptools.StringPtr(":" + generatedModuleName(ctx.Config(), "android_info.prop{.txt}")), + Kernel_version: ctx.Config().ProductVariables().BoardKernelVersion, + Partial_ota_update_partitions: ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BoardPartialOtaUpdatePartitionsList, + Flash_block_size: proptools.StringPtr(ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BoardFlashBlockSize), + Bootloader_in_update_package: proptools.BoolPtr(ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BootloaderInUpdatePackage), } if bootloader, ok := f.createBootloaderFilegroup(ctx); ok { -- cgit v1.2.3-59-g8ed1b From f68322e3286becff1d006f557e5dc71afadcf26f Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 21 Mar 2025 21:02:46 +0000 Subject: Do not write avb_*_key_path of android_filesystem to misc_info.txt This matches the make packaging system implementaton. avb_*_key_path of bootimg, vbmeta and system_other will continue to be written to Soong built misc_info.txt Bug: 398036609 Test: Built and diff'd locally Change-Id: Ie2d4ad8362ce7f44d473ef185562c60718e173b3 --- filesystem/filesystem.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index ad4366b2e..61b731ab2 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -1182,10 +1182,6 @@ func (f *filesystem) buildPropFileForMiscInfo(ctx android.ModuleContext) android if proptools.Bool(f.properties.Use_avb) { addStr("avb_"+f.partitionName()+"_hashtree_enable", "true") - if f.properties.Avb_private_key != nil { - key := android.PathForModuleSrc(ctx, *f.properties.Avb_private_key) - addStr("avb_"+f.partitionName()+"_key_path", key.String()) - } addStr("avb_"+f.partitionName()+"_add_hashtree_footer_args", strings.TrimSpace(f.getAvbAddHashtreeFooterArgs(ctx))) } -- cgit v1.2.3-59-g8ed1b From 9329c67e4535f7545529aeae96064c1fbbc887dd Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 21 Mar 2025 21:04:29 +0000 Subject: Dist Soong built misc_info.txt in Soong only builds Soong built misc_info.txt for aosp_cf_x86_64_phone is not bit-identical to Make built misc_info.txt, but I think the diffs are not meaningful. b/398036609#comment14 has some additional information on the diffs. Bug: 398036609 Test: m dist dist_files Change-Id: I32e163b9dfd55c18db6f88531653ff35167bd399 --- filesystem/android_device.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 8af0fdff6..a2181c1a1 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -395,6 +395,13 @@ func (a *androidDevice) distFiles(ctx android.ModuleContext) { if a.deviceProps.Android_info != nil { ctx.DistForGoal("droidcore-unbundled", android.PathForModuleSrc(ctx, *a.deviceProps.Android_info)) } + if a.miscInfo != nil { + ctx.DistForGoal("droidcore-unbundled", a.miscInfo) + if a.partitionProps.Super_partition_name != nil { + ctx.DistForGoalWithFilename("dist_files", a.miscInfo, "super_misc_info.txt") + } + } + } } -- cgit v1.2.3-59-g8ed1b From 124aa20524fddba054c671904598478dc346620e Mon Sep 17 00:00:00 2001 From: Jeff Hamilton Date: Fri, 14 Mar 2025 01:44:16 -0400 Subject: Quote zip2zip arg with a *. Test: m out/soong/.intermediates/vendor/unbundled_google/packages/MapsPrebuilt/Maps/android_common/jnis-stripped/Maps.apk Flag: EXEMPT build system change Change-Id: I8d4db4cb18c5e96e9fec7cd2abd3f3a4b611b1b1 --- java/app_import.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/app_import.go b/java/app_import.go index 37c673ca0..c63c3367f 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -338,7 +338,7 @@ func (a *AndroidAppImport) stripEmbeddedJniLibsUnusedArch( for _, target := range ctx.MultiTargets() { supported_abis := target.Arch.Abi for _, arch := range supported_abis { - wantedJniLibSlice = append(wantedJniLibSlice, " -X lib/"+arch+"/*.so") + wantedJniLibSlice = append(wantedJniLibSlice, " -X 'lib/"+arch+"/*.so'") } } wantedJniLibString := strings.Join(wantedJniLibSlice, " ") -- cgit v1.2.3-59-g8ed1b