From e6ca3ff930bf29edf569956ad0223f69c8157ce6 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Mon, 17 Mar 2025 20:57:34 -0700 Subject: Remove host script(list_image) the script is not used anywhere. But: 399476012 Test: presubmit (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:bd1dda557e59e42da277da48db1181159889382d) Merged-In: I73b6b961e5b63fa01f926419aea42a6e2cfc1413 Change-Id: I73b6b961e5b63fa01f926419aea42a6e2cfc1413 --- scripts/Android.bp | 5 ----- scripts/list_image.sh | 51 --------------------------------------------------- 2 files changed, 56 deletions(-) delete mode 100755 scripts/list_image.sh diff --git a/scripts/Android.bp b/scripts/Android.bp index c0e13d52f..b6cac32f3 100644 --- a/scripts/Android.bp +++ b/scripts/Android.bp @@ -254,11 +254,6 @@ python_binary_host { ], } -sh_binary_host { - name: "list_image", - src: "list_image.sh", -} - filegroup { name: "rustfmt.toml", srcs: ["rustfmt.toml"], diff --git a/scripts/list_image.sh b/scripts/list_image.sh deleted file mode 100755 index 0542fa610..000000000 --- a/scripts/list_image.sh +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/bash - -# Recursively list Android image directory. -set -eu -set -o pipefail - -function die() { format=$1; shift; printf "$format\n" "$@"; exit 1; } - -# Figure out the filer utility. -declare filer= -[[ -z "${ANDROID_HOST_OUT:-}" ]] || filer=${ANDROID_HOST_OUT}/bin/debugfs_static -if [[ "${1:-}" =~ --debugfs_path=(.*) ]]; then - filer=${BASH_REMATCH[1]} - shift -fi -if [[ -z "${filer:-}" ]]; then - maybefiler="$(dirname $0)/debugfs_static" - [[ ! -x "$maybefiler" ]] || filer="$maybefiler" -fi - -(( $# >0 )) || die "%s [--debugfs_path=] IMAGE" "$0" - -[[ -n "${filer:-}" ]] || die "cannot locate 'debugfs' executable: \ ---debugfs_path= is missing, ANDROID_HOST_OUT is not set, \ -and 'debugfs_static' is not colocated with this script" -declare -r image="$1" - -function dolevel() { - printf "%s/\n" "$1" - # Each line of the file output consists of 6 fields separated with '/'. - # The second one contains the file's attributes, and the fifth its name. - $filer -R "ls -l -p $1" "$image" 2>/dev/null |\ - sed -nr 's|^/.*/(.*)/.*/.*/(.+)/.*/$|\2 \1|p' | LANG=C sort | \ - while read name attr; do - [[ "$name" != '.' && "$name" != '..' ]] || continue - path="$1/$name" - # If the second char of the attributes is '4', it is a directory. - if [[ $attr =~ ^.4 ]]; then - dolevel "$path" - else - printf "%s\n" "$path" - fi - done -} - -# The filer always prints its version on stderr, so we are going -# to redirect it to the bit bucket. On the other hand, the filer's -# return code on error is still 0. Let's run it once to without -# redirecting stderr to see that there is at least one entry. -$filer -R "ls -l -p" "$image" | grep -q -m1 -P '^/.*/.*/.*/.*/.+/.*/$' -dolevel . -- cgit v1.2.3-59-g8ed1b From fb4b996aa0d358326a9c105cc55735e66b8aa5b2 Mon Sep 17 00:00:00 2001 From: mrziwang Date: Tue, 18 Mar 2025 23:23:44 +0000 Subject: Add SupportFilesInfo provider This provider will be used to collect the SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES in device-tests mk code. Test: CI Bug: 388850000 Change-Id: I0e9d758eb83e289a806872f91515c5e5674cd4d0 --- android/test_suites.go | 6 ++++++ tradefed_modules/test_module_config.go | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/android/test_suites.go b/android/test_suites.go index 9eaf78549..dbcd48c79 100644 --- a/android/test_suites.go +++ b/android/test_suites.go @@ -42,6 +42,12 @@ type TestSuiteInfo struct { var TestSuiteInfoProvider = blueprint.NewProvider[TestSuiteInfo]() +type SupportFilesInfo struct { + SupportFiles InstallPaths +} + +var SupportFilesInfoProvider = blueprint.NewProvider[SupportFilesInfo]() + func (t *testSuiteFiles) GenerateBuildActions(ctx SingletonContext) { files := make(map[string]map[string]InstallPaths) diff --git a/tradefed_modules/test_module_config.go b/tradefed_modules/test_module_config.go index 2b341288a..e833df293 100644 --- a/tradefed_modules/test_module_config.go +++ b/tradefed_modules/test_module_config.go @@ -1,14 +1,15 @@ package tradefed_modules import ( - "android/soong/android" - "android/soong/tradefed" "encoding/json" "fmt" "io" "slices" "strings" + "android/soong/android" + "android/soong/tradefed" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -178,6 +179,10 @@ func (m *testModuleConfigModule) GenerateAndroidBuildActions(ctx android.ModuleC moduleInfoJSON.TestConfig = []string{m.testConfig.String()} moduleInfoJSON.AutoTestConfig = []string{"true"} moduleInfoJSON.TestModuleConfigBase = proptools.String(m.Base) + + android.SetProvider(ctx, android.SupportFilesInfoProvider, android.SupportFilesInfo{ + SupportFiles: m.supportFiles, + }) } // Ensure at least one test_suite is listed. Ideally it should be general-tests @@ -327,6 +332,9 @@ func (m *testModuleConfigHostModule) DepsMutator(ctx android.BottomUpMutatorCont func (m *testModuleConfigHostModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { m.validateBase(ctx, &testModuleConfigHostTag, "java_test_host", true) m.generateManifestAndConfig(ctx) + android.SetProvider(ctx, android.SupportFilesInfoProvider, android.SupportFilesInfo{ + SupportFiles: m.supportFiles, + }) } // Ensure the base listed is the right type by checking that we get the expected provider data. -- cgit v1.2.3-59-g8ed1b From 538df784137ec0cad1bc7d61c03697558a17d3c9 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 21 Mar 2025 16:40:41 +0000 Subject: Add services.impl to legacyCorePlatformApiModules Swap out services for services.impl in the legacy API allowlist, as the new intermediate target contains the referencing Java srcs that feed into services. Bug: 212737576 Test: m Flag: EXEMPT build refactor Ignore-AOSP-First: New target not yet in AOSP Change-Id: I319ba001eb1d5f16141397cc89cbbe3bfe2f6d21 --- java/legacy_core_platform_api_usage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go index 4be7d0470..21895d4cc 100644 --- a/java/legacy_core_platform_api_usage.go +++ b/java/legacy_core_platform_api_usage.go @@ -47,8 +47,8 @@ var legacyCorePlatformApiModules = []string{ "sam", "saminterfacelibrary", "sammanagerlibrary", - "services", "services.core.unboosted", + "services.impl", "Settings-core", "SettingsGoogle", "SettingsGoogleOverlayCoral", -- cgit v1.2.3-59-g8ed1b From 2d6bed512fb89332e0a10c3fca898619dc124761 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Thu, 20 Mar 2025 22:21:05 +0000 Subject: Move SyncMap to blueprint. Bug: 358427516 Test: Manually verified genereated ninja and mk files, unit tests. Change-Id: If2d347c39e4f2e4cae51fb5e6dcd407d79bd42df --- android/Android.bp | 1 + android/raw_files.go | 7 ++++--- android/util.go | 30 ------------------------------ 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/android/Android.bp b/android/Android.bp index 71e674767..97d634fb5 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -12,6 +12,7 @@ bootstrap_go_package { "blueprint-gobtools", "blueprint-metrics", "blueprint-pool", + "blueprint-syncmap", "sbox_proto", "soong", "soong-android_team_proto", diff --git a/android/raw_files.go b/android/raw_files.go index fd371965c..ebba4d145 100644 --- a/android/raw_files.go +++ b/android/raw_files.go @@ -26,6 +26,7 @@ import ( "testing" "github.com/google/blueprint" + "github.com/google/blueprint/syncmap" "github.com/google/blueprint/proptools" ) @@ -213,10 +214,10 @@ type rawFileInfo struct { var rawFileSetKey OnceKey = NewOnceKey("raw file set") -func getRawFileSet(config Config) *SyncMap[string, rawFileInfo] { +func getRawFileSet(config Config) *syncmap.SyncMap[string, rawFileInfo] { return config.Once(rawFileSetKey, func() any { - return &SyncMap[string, rawFileInfo]{} - }).(*SyncMap[string, rawFileInfo]) + return &syncmap.SyncMap[string, rawFileInfo]{} + }).(*syncmap.SyncMap[string, rawFileInfo]) } // ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use diff --git a/android/util.go b/android/util.go index 7b305b575..4520f400e 100644 --- a/android/util.go +++ b/android/util.go @@ -23,7 +23,6 @@ import ( "runtime" "sort" "strings" - "sync" "github.com/google/blueprint/proptools" ) @@ -646,35 +645,6 @@ func AddToStringSet(set map[string]bool, items []string) { } } -// SyncMap is a wrapper around sync.Map that provides type safety via generics. -type SyncMap[K comparable, V any] struct { - sync.Map -} - -// Load returns the value stored in the map for a key, or the zero value if no -// value is present. -// The ok result indicates whether value was found in the map. -func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) { - v, ok := m.Map.Load(key) - if !ok { - return *new(V), false - } - return v.(V), true -} - -// Store sets the value for a key. -func (m *SyncMap[K, V]) Store(key K, value V) { - m.Map.Store(key, value) -} - -// LoadOrStore returns the existing value for the key if present. -// Otherwise, it stores and returns the given value. -// The loaded result is true if the value was loaded, false if stored. -func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) { - v, loaded := m.Map.LoadOrStore(key, value) - return v.(V), loaded -} - // AppendIfNotZero append the given value to the slice if it is not the zero value // for its type. func AppendIfNotZero[T comparable](slice []T, value T) []T { -- cgit v1.2.3-59-g8ed1b From bfabbf08fd73e2e8ff0e09b7a95d05c46d30085b Mon Sep 17 00:00:00 2001 From: Wei Li Date: Fri, 21 Mar 2025 16:04:19 -0700 Subject: Add Android.mk allowlist for wearable partner branches Wearable partner branches don't have vendor/google/build/ Bug: 405307057 Test: presubmits Change-Id: Ifecd3c6861469ae887ba4b636050ba1094fbb8fc --- ui/build/androidmk_denylist.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go index 622aadb95..490e1327b 100644 --- a/ui/build/androidmk_denylist.go +++ b/ui/build/androidmk_denylist.go @@ -77,8 +77,16 @@ func getAllLines(ctx Context, filename string) []string { } func blockAndroidMks(ctx Context, androidMks []string) { - allowlist := getAllLines(ctx, "vendor/google/build/androidmk/allowlist.txt") - androidmk_allowlist = append(androidmk_allowlist, allowlist...) + allowlist_files := []string{ + "vendor/google/build/androidmk/allowlist.txt", + "device/google/clockwork/build/androidmk/allowlist.txt", + } + for _, allowlist_file := range allowlist_files { + allowlist := getAllLines(ctx, allowlist_file) + androidmk_allowlist = append(androidmk_allowlist, allowlist...) + } + slices.Sort(androidmk_allowlist) + androidmk_allowlist = slices.Compact(androidmk_allowlist) denylist := getAllLines(ctx, "vendor/google/build/androidmk/denylist.txt") androidmk_denylist = append(androidmk_denylist, denylist...) -- cgit v1.2.3-59-g8ed1b From 37eecea8bfa610f898c04981cbaa8a734b2cc5e0 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Wed, 19 Mar 2025 20:15:23 +0000 Subject: Declare apps of prebuilt_apex for apkcerts.txt Make built apkcerts.txt currently creates entries for every app in the tree. When this implementation was recently changed to be limited to only the list of installed apps, it caused b/403528876. The reason for this is that the signing process signs .apks inside .apex files as well. This works fine for `apex` module type. It worked fine for `prebuilt_apex` previously because it implicitly dependend on the global nature of apkcerts.txt, i.e. that the source `android_app` will create an entry for apkcerts.txt In preparation to limit apkcerts.txt to the list of installed apps and apk-in-apexes, introduce an explicit `apps` property in `prebuilt_apex`. Bug: 399788149 Test: With RELEASE_APKCERTS_INSTALL_ONLY=true reapplied (https://r.android.com/3552561), previously failed signing test now passes https://android-build.corp.google.com/builds/abtd/run/L03300030010481704 Test: presubmits Change-Id: Icd1e702b14e068fea0f08693e0e90e26d1ec27a2 --- apex/prebuilt.go | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 89b0091be..fdd9a75d7 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -15,7 +15,9 @@ package apex import ( + "fmt" "slices" + "sort" "strconv" "strings" @@ -80,6 +82,10 @@ type prebuiltCommon struct { // systemServerDexJars stores the list of dexjars for system server jars in the prebuilt for use when // dexpreopting system server jars that are later in the system server classpath. systemServerDexJars android.Paths + + // Certificate information of any apk packaged inside the prebuilt apex. + // This will be nil if the prebuilt apex does not contain any apk. + apkCertsFile android.WritablePath } type sanitizedPrebuilt interface { @@ -273,6 +279,10 @@ func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries { entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable()) entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.prebuiltCommonProperties.Overrides...) entries.SetString("LOCAL_APEX_KEY_PATH", p.apexKeysPath.String()) + if p.apkCertsFile != nil { + entries.SetString("LOCAL_APKCERTS_FILE", p.apkCertsFile.String()) + } + }, }, }, @@ -286,6 +296,14 @@ func (p *prebuiltCommon) hasExportedDeps() bool { len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0 } +type appInPrebuiltApexDepTag struct { + blueprint.BaseDependencyTag +} + +func (appInPrebuiltApexDepTag) ExcludeFromVisibilityEnforcement() {} + +var appInPrebuiltApexTag = appInPrebuiltApexDepTag{} + // prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents. func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { module := ctx.Module() @@ -432,6 +450,12 @@ type PrebuiltProperties struct { ApexFileProperties PrebuiltCommonProperties + + // List of apps that are bundled inside this prebuilt apex. + // This will be used to create the certificate info of those apps for apkcerts.txt + // This dependency will only be used for apkcerts.txt processing. + // Notably, building the prebuilt apex will not build the source app. + Apps []string } func (a *Prebuilt) hasSanitizedSource(sanitizer string) bool { @@ -545,6 +569,9 @@ var ( func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { p.prebuiltApexContentsDeps(ctx) + for _, app := range p.properties.Apps { + ctx.AddDependency(p, appInPrebuiltApexTag, app) + } } var _ ApexTransitionMutator = (*Prebuilt)(nil) @@ -677,11 +704,59 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile) } + p.addApkCertsInfo(ctx) + ctx.SetOutputFiles(android.Paths{p.outputApex}, "") android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{p.apexKeysPath}) } +// `addApkCertsInfo` sets a provider that will be used to create apkcerts.txt +func (p *Prebuilt) addApkCertsInfo(ctx android.ModuleContext) { + formatLine := func(cert java.Certificate, name, partition string) string { + pem := cert.AndroidMkString() + var key string + if cert.Key == nil { + key = "" + } else { + key = cert.Key.String() + } + return fmt.Sprintf(`name="%s" certificate="%s" private_key="%s" partition="%s"`, name, pem, key, partition) + } + + // Determine if this prebuilt_apex contains any .apks + var appInfos java.AppInfos + ctx.VisitDirectDepsProxyWithTag(appInPrebuiltApexTag, func(app android.ModuleProxy) { + if appInfo, ok := android.OtherModuleProvider(ctx, app, java.AppInfoProvider); ok { + appInfos = append(appInfos, *appInfo) + } else { + ctx.ModuleErrorf("App %s does not set AppInfoProvider\n", app.Name()) + } + }) + sort.Slice(appInfos, func(i, j int) bool { + return appInfos[i].InstallApkName < appInfos[j].InstallApkName + }) + + if len(appInfos) == 0 { + return + } + + // Set a provider for use by `android_device`. + // `android_device` will create an apkcerts.txt with the list of installed apps for that device. + android.SetProvider(ctx, java.AppInfosProvider, appInfos) + + // Set a Make variable for legacy apkcerts.txt creation + // p.apkCertsFile will become `LOCAL_APKCERTS_FILE` + var lines []string + for _, appInfo := range appInfos { + lines = append(lines, formatLine(appInfo.Certificate, appInfo.InstallApkName+".apk", p.PartitionTag(ctx.DeviceConfig()))) + } + if len(lines) > 0 { + p.apkCertsFile = android.PathForModuleOut(ctx, "apkcerts.txt") + android.WriteFileRule(ctx, p.apkCertsFile, strings.Join(lines, "\n")) + } +} + func (p *Prebuilt) ProvenanceMetaDataFile() android.Path { return p.provenanceMetaDataFile } -- cgit v1.2.3-59-g8ed1b From 870dbdc97b9ae3b1a1b8e221af1cbbb50d0bb041 Mon Sep 17 00:00:00 2001 From: Bill Yang Date: Thu, 20 Mar 2025 08:54:11 +0000 Subject: Add prepend_artifact_with_product attribute for dist Add the new attribute to feet what test_package's requirement, moving the dist output naming logic from test_package to dist. Also add 4 allowed module names for the rest of the continuous_* test packages. Ignore-AOSP-First: Because the platform_tests conversion is in internal branch currently. Bug: 399246722 Test: m dist platform_tests Change-Id: I96e690f23e801c22fe66f0f234be8a1f9a84062f --- android/androidmk.go | 15 ++++++++++----- android/module.go | 6 ++++++ ci_tests/ci_test_package_zip.go | 8 +------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 7cc6aef00..e32835946 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -435,13 +435,18 @@ func getDistContributions(ctx ConfigAndOtherModuleProviderContext, mod Module) * suffix = *dist.Suffix } - productString := "" - if dist.Append_artifact_with_product != nil && *dist.Append_artifact_with_product { - productString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct()) + prependProductString := "" + if proptools.Bool(dist.Prepend_artifact_with_product) { + prependProductString = fmt.Sprintf("%s-", ctx.Config().DeviceProduct()) } - if suffix != "" || productString != "" { - dest = strings.TrimSuffix(dest, ext) + suffix + productString + ext + appendProductString := "" + if proptools.Bool(dist.Append_artifact_with_product) { + appendProductString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct()) + } + + if suffix != "" || appendProductString != "" || prependProductString != "" { + dest = prependProductString + strings.TrimSuffix(dest, ext) + suffix + appendProductString + ext } if dist.Dir != nil { diff --git a/android/module.go b/android/module.go index c0abfd0a3..1538861d3 100644 --- a/android/module.go +++ b/android/module.go @@ -208,6 +208,12 @@ type Dist struct { // no change to the artifact file name. Append_artifact_with_product *bool `android:"arch_variant"` + // If true, then the artifact file will be prepended with -. For + // example, if the product is coral and the module is an android_app module + // of name foo, then the artifact would be coral-foo.apk. If false, there is + // no change to the artifact file name. + Prepend_artifact_with_product *bool `android:"arch_variant"` + // A string tag to select the OutputFiles associated with the tag. // // If no tag is specified then it will select the default dist paths provided diff --git a/ci_tests/ci_test_package_zip.go b/ci_tests/ci_test_package_zip.go index d7aaa6686..4cadffddc 100644 --- a/ci_tests/ci_test_package_zip.go +++ b/ci_tests/ci_test_package_zip.go @@ -68,7 +68,7 @@ var ( pctx = android.NewPackageContext("android/soong/ci_tests") // test_package module type should only be used for the following modules. // TODO: remove "_soong" from the module names inside when eliminating the corresponding make modules - moduleNamesAllowed = []string{"continuous_native_tests_soong", "continuous_instrumentation_tests_soong", "platform_tests"} + moduleNamesAllowed = []string{"continuous_instrumentation_tests_soong", "continuous_instrumentation_metric_tests_soong", "continuous_native_tests_soong", "continuous_native_metric_tests_soong", "platform_tests"} ) func (p *testPackageZip) DepsMutator(ctx android.BottomUpMutatorContext) { @@ -150,12 +150,6 @@ func (p *testPackageZip) GenerateAndroidBuildActions(ctx android.ModuleContext) p.output = createOutput(ctx, pctx) ctx.SetOutputFiles(android.Paths{p.output}, "") - - // dist the test output - if ctx.ModuleName() == "platform_tests" { - distedName := ctx.Config().Getenv("TARGET_PRODUCT") + "-tests-FILE_NAME_TAG_PLACEHOLDER.zip" - ctx.DistForGoalWithFilename("platform_tests", p.output, distedName) - } } func createOutput(ctx android.ModuleContext, pctx android.PackageContext) android.ModuleOutPath { -- cgit v1.2.3-59-g8ed1b From 5be47f763f9c555967349ba4f7c7be317026329f Mon Sep 17 00:00:00 2001 From: Bill Yang Date: Thu, 20 Mar 2025 08:54:11 +0000 Subject: Add prepend_artifact_with_product attribute for dist Add the new attribute to feet what test_package's requirement, moving the dist output naming logic from test_package to dist. Also add 4 allowed module names for the rest of the continuous_* test packages. Bug: 399246722 Test: m dist platform_tests Change-Id: I96e690f23e801c22fe66f0f234be8a1f9a84062f Merged-In: I96e690f23e801c22fe66f0f234be8a1f9a84062f --- android/androidmk.go | 15 ++++++++++----- android/module.go | 6 ++++++ ci_tests/ci_test_package_zip.go | 8 +------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 7cc6aef00..e32835946 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -435,13 +435,18 @@ func getDistContributions(ctx ConfigAndOtherModuleProviderContext, mod Module) * suffix = *dist.Suffix } - productString := "" - if dist.Append_artifact_with_product != nil && *dist.Append_artifact_with_product { - productString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct()) + prependProductString := "" + if proptools.Bool(dist.Prepend_artifact_with_product) { + prependProductString = fmt.Sprintf("%s-", ctx.Config().DeviceProduct()) } - if suffix != "" || productString != "" { - dest = strings.TrimSuffix(dest, ext) + suffix + productString + ext + appendProductString := "" + if proptools.Bool(dist.Append_artifact_with_product) { + appendProductString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct()) + } + + if suffix != "" || appendProductString != "" || prependProductString != "" { + dest = prependProductString + strings.TrimSuffix(dest, ext) + suffix + appendProductString + ext } if dist.Dir != nil { diff --git a/android/module.go b/android/module.go index c0abfd0a3..1538861d3 100644 --- a/android/module.go +++ b/android/module.go @@ -208,6 +208,12 @@ type Dist struct { // no change to the artifact file name. Append_artifact_with_product *bool `android:"arch_variant"` + // If true, then the artifact file will be prepended with -. For + // example, if the product is coral and the module is an android_app module + // of name foo, then the artifact would be coral-foo.apk. If false, there is + // no change to the artifact file name. + Prepend_artifact_with_product *bool `android:"arch_variant"` + // A string tag to select the OutputFiles associated with the tag. // // If no tag is specified then it will select the default dist paths provided diff --git a/ci_tests/ci_test_package_zip.go b/ci_tests/ci_test_package_zip.go index d7aaa6686..4cadffddc 100644 --- a/ci_tests/ci_test_package_zip.go +++ b/ci_tests/ci_test_package_zip.go @@ -68,7 +68,7 @@ var ( pctx = android.NewPackageContext("android/soong/ci_tests") // test_package module type should only be used for the following modules. // TODO: remove "_soong" from the module names inside when eliminating the corresponding make modules - moduleNamesAllowed = []string{"continuous_native_tests_soong", "continuous_instrumentation_tests_soong", "platform_tests"} + moduleNamesAllowed = []string{"continuous_instrumentation_tests_soong", "continuous_instrumentation_metric_tests_soong", "continuous_native_tests_soong", "continuous_native_metric_tests_soong", "platform_tests"} ) func (p *testPackageZip) DepsMutator(ctx android.BottomUpMutatorContext) { @@ -150,12 +150,6 @@ func (p *testPackageZip) GenerateAndroidBuildActions(ctx android.ModuleContext) p.output = createOutput(ctx, pctx) ctx.SetOutputFiles(android.Paths{p.output}, "") - - // dist the test output - if ctx.ModuleName() == "platform_tests" { - distedName := ctx.Config().Getenv("TARGET_PRODUCT") + "-tests-FILE_NAME_TAG_PLACEHOLDER.zip" - ctx.DistForGoalWithFilename("platform_tests", p.output, distedName) - } } func createOutput(ctx android.ModuleContext, pctx android.PackageContext) android.ModuleOutPath { -- cgit v1.2.3-59-g8ed1b From d7ae04065d993128fcb8b8331fcaf39692df502a Mon Sep 17 00:00:00 2001 From: Hugo Drumond Jacob Date: Mon, 24 Mar 2025 13:47:53 +0100 Subject: Add Android.mk allowlist for SDV partner branches SDV partner branches don't have vendor/google/build/ Bug: 405928541 Test: presubmits Change-Id: Id6acf64e0a3eb11344e865c0453b0153c88297de --- ui/build/androidmk_denylist.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go index 490e1327b..4134cf5de 100644 --- a/ui/build/androidmk_denylist.go +++ b/ui/build/androidmk_denylist.go @@ -80,6 +80,7 @@ func blockAndroidMks(ctx Context, androidMks []string) { allowlist_files := []string{ "vendor/google/build/androidmk/allowlist.txt", "device/google/clockwork/build/androidmk/allowlist.txt", + "device/google/sdv/androidmk/allowlist.txt", } for _, allowlist_file := range allowlist_files { allowlist := getAllLines(ctx, allowlist_file) -- cgit v1.2.3-59-g8ed1b From 514848766ccb565c9179bf4aaa231a20f6e74c37 Mon Sep 17 00:00:00 2001 From: Satish Yalla Date: Thu, 20 Mar 2025 21:57:26 -0700 Subject: Revert "Make d8-on-eng a per-module opt-out" Revert submission 3555366-eng-d8 Reason for revert: Droidmonitor created revert due to b/405397520. Will be verified through ABTD for standard investigation. Reverted changes: /q/submissionid:3555366-eng-d8 Change-Id: Idc27a646af8e726e74665fbbb80f6fc3e510625a --- java/dex.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/dex.go b/java/dex.go index f2406fb3c..dd6467546 100644 --- a/java/dex.go +++ b/java/dex.go @@ -42,9 +42,6 @@ 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 @@ -165,10 +162,7 @@ type dexer struct { } func (d *dexer) effectiveOptimizeEnabled(ctx android.EarlyModuleContext) bool { - if ctx.Config().Eng() { - return proptools.Bool(d.dexProperties.Optimize.Enabled_on_eng) - } - return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault) + return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault && !ctx.Config().Eng()) } func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool { -- cgit v1.2.3-59-g8ed1b From 27452ec5b4e8a0e6e5e82c281b091033b7152dd8 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 24 Mar 2025 17:22:55 +0000 Subject: Dist Soong built target_files.zip in Soong only builds Test: presubmits Bug: 385383524 Change-Id: Id89e2df5ef721756b5fd4d631cfb4f17eaf48392 --- filesystem/android_device.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/filesystem/android_device.go b/filesystem/android_device.go index a2181c1a1..a25194261 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -120,6 +120,7 @@ type androidDevice struct { rootDirForFsConfig string rootDirForFsConfigTimestamp android.Path apkCertsInfo android.Path + targetFilesZip android.Path } func AndroidDeviceFactory() android.Module { @@ -401,6 +402,9 @@ func (a *androidDevice) distFiles(ctx android.ModuleContext) { ctx.DistForGoalWithFilename("dist_files", a.miscInfo, "super_misc_info.txt") } } + if a.targetFilesZip != nil { + ctx.DistForGoalWithFilename("target-files-package", a.targetFilesZip, namePrefix+insertBeforeExtension(a.targetFilesZip.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) + } } } @@ -590,6 +594,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext, allInstal a.copyImagesToTargetZip(ctx, builder, targetFilesDir) a.copyMetadataToTargetZip(ctx, builder, targetFilesDir, allInstalledModules) + a.targetFilesZip = targetFilesZip builder.Command(). BuiltTool("soong_zip"). Text("-d"). -- cgit v1.2.3-59-g8ed1b From 3c3748a4fefa6c025d273220c8a347ce3ea1c440 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 24 Mar 2025 13:10:58 -0700 Subject: Update allowlist for partner branches Bug: 405307057 Test: presubmits Change-Id: I972e3e344e0e4d7b024acfc693879b8bb3ccff5e --- ui/build/androidmk_denylist.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go index 4134cf5de..82666548d 100644 --- a/ui/build/androidmk_denylist.go +++ b/ui/build/androidmk_denylist.go @@ -62,6 +62,7 @@ var androidmk_denylist []string = []string{ var androidmk_allowlist []string = []string{ "art/Android.mk", "bootable/deprecated-ota/updater/Android.mk", + "tools/vendor/google_prebuilts/arc/Android.mk", } func getAllLines(ctx Context, filename string) []string { -- cgit v1.2.3-59-g8ed1b From f1153bd2f8a150711b7bfbd54b96667861cc7382 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 24 Mar 2025 21:08:48 +0000 Subject: Build and dist updatepackage Equivalent make code: https://cs.android.com/android/_/android/platform/build/+/577341036beabe1cf4dcc479b254b878b8963b8d:core/Makefile;l=7593-7620;drc=577341036beabe1cf4dcc479b254b878b8963b8d;bpv=1;bpt=0 Some custom partitions are not included in the updatepackage. Make determines by looking at a board config variable. To implement this exclusion in Soong, a new `No_flashall` property has been added to `android_filesystem`. Bug: 383902856 Test: Built img.zip files for both make and soong Test: verified that they contain the same no. of files. Change-Id: If4df40a7ceb2ef68de27fb44f9e8db4503695e4e --- filesystem/android_device.go | 37 +++++++++++++++++++++++++++++++++++++ filesystem/filesystem.go | 6 ++++++ 2 files changed, 43 insertions(+) diff --git a/filesystem/android_device.go b/filesystem/android_device.go index a25194261..56a681f6d 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -121,6 +121,7 @@ type androidDevice struct { rootDirForFsConfigTimestamp android.Path apkCertsInfo android.Path targetFilesZip android.Path + updatePackage android.Path } func AndroidDeviceFactory() android.Module { @@ -200,6 +201,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.miscInfo = a.addMiscInfo(ctx) a.buildTargetFilesZip(ctx, allInstalledModules) a.buildProguardZips(ctx, allInstalledModules) + a.buildUpdatePackage(ctx) var deps []android.Path if proptools.String(a.partitionProps.Super_partition_name) != "" { @@ -405,6 +407,9 @@ func (a *androidDevice) distFiles(ctx android.ModuleContext) { if a.targetFilesZip != nil { ctx.DistForGoalWithFilename("target-files-package", a.targetFilesZip, namePrefix+insertBeforeExtension(a.targetFilesZip.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) } + if a.updatePackage != nil { + ctx.DistForGoalWithFilename("updatepackage", a.updatePackage, namePrefix+insertBeforeExtension(a.updatePackage.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) + } } } @@ -948,6 +953,38 @@ func (a *androidDevice) addImgToTargetFiles(ctx android.ModuleContext, builder * Text(targetFilesDir) } +func (a *androidDevice) buildUpdatePackage(ctx android.ModuleContext) { + var exclusions []string + fsInfos := a.getFsInfos(ctx) + // Exclude the partitions that are not supported by flashall + for _, partition := range android.SortedKeys(fsInfos) { + if fsInfos[partition].NoFlashall { + exclusions = append(exclusions, fmt.Sprintf("IMAGES/%s.img", partition)) + exclusions = append(exclusions, fmt.Sprintf("IMAGES/%s.map", partition)) + } + } + + updatePackage := android.PathForModuleOut(ctx, "img.zip") + rule := android.NewRuleBuilder(pctx, ctx) + + buildSuperImage := ctx.Config().HostToolPath(ctx, "build_super_image") + zip2zip := ctx.Config().HostToolPath(ctx, "zip2zip") + + rule.Command(). + BuiltTool("img_from_target_files"). + Text("--additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto"). + FlagForEachArg("--exclude ", exclusions). + FlagWithArg("--build_super_image ", buildSuperImage.String()). + Implicit(buildSuperImage). + Implicit(zip2zip). + Input(a.targetFilesZip). + Output(updatePackage) + + rule.Build("updatepackage", "Building updatepackage") + + a.updatePackage = updatePackage +} + type ApexKeyPathInfo struct { ApexKeyPath android.Path } diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 61b731ab2..0b17025b4 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -249,6 +249,10 @@ type FilesystemProperties struct { // Whether to enable per-file compression in f2fs Enable_compression *bool + + // Whether this partition is not supported by flashall. + // If true, this partition will not be included in the `updatedpackage` dist artifact. + No_flashall *bool } type AndroidFilesystemDeps struct { @@ -464,6 +468,7 @@ type FilesystemInfo struct { AvbHashAlgorithm string AvbKey android.Path PartitionName string + NoFlashall bool // HasOrIsRecovery returns true for recovery and for ramdisks with a recovery partition. HasOrIsRecovery bool } @@ -725,6 +730,7 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { PartitionSize: f.properties.Partition_size, PartitionName: f.partitionName(), HasOrIsRecovery: f.hasOrIsRecovery(ctx), + NoFlashall: proptools.Bool(f.properties.No_flashall), } if proptools.Bool(f.properties.Use_avb) { fsInfo.UseAvb = true -- cgit v1.2.3-59-g8ed1b