From cfff924ef9feaad5bed932b9e353b0f91f9dfbba Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 25 Mar 2024 20:31:32 +0000 Subject: [PATCH] Drop host variant of lidbexfile in >=V snapshots The host variant of libdexfile and its deps were added to module sdk to support the use case of building platform tests without art's source code. This use case is not very relevant today, so we can drop the host variant of these modules from the module sdk. We still need to keep them in <= U snapshots, so this CL uses a hack to drop these libraries only if `SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE` is greater than UDC Test: SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=UpsideDownCake m out/soong/mainline-sdks/art-module-host-exports-current.zip # verified that libartbase is in the generated Android.bp Test: m out/soong/mainline-sdks/art-module-host-exports-current.zip # verified that libartbase is not in the generated Android.bp Test: In `main`, deleted the host variants from prebuilts/module_sdk locally; enabled art prebuilts; Test: atest --host --no-bazel-mode libunwindstack_unit_test Bug: 329830257 Change-Id: Iab23853ef5e96661a5f5c2989add1be32fb07fbc --- sdk/update.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sdk/update.go b/sdk/update.go index b8ae38a33..afecf9fe2 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -163,6 +163,20 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) { }) } +// A denylist of modules whose host variants will be removed from the generated snapshots above the ApiLevel +// even if they are listed in the corresponding `sdk`. +// The key is the module name +// The value is the _last_ dessert where the host variant of the module will be present +// This is a workaround to ensure that these modules are generated in <=$ApiLevel, but not in in >=$ApiLevel +var ignoreHostModuleVariantsAboveDessert = map[string]android.ApiLevel{ + // ignore host variant of libdexfile and its transitive dependencies. + // The platform test that depends on them (`libunwindstack_unit_test` at the time of writing) + // no longer requires a prebuilt variant of libdexfile. + "libdexfile": android.ApiLevelUpsideDownCake, + "libartpalette": android.ApiLevelUpsideDownCake, + "libartbase": android.ApiLevelUpsideDownCake, +} + // groupMemberVariantsByMemberThenType groups the member variant dependencies so that all the // variants of each member are grouped together within an sdkMember instance. // @@ -181,6 +195,14 @@ func (s *sdk) groupMemberVariantsByMemberThenType(ctx android.ModuleContext, tar variant := memberVariantDep.variant name := ctx.OtherModuleName(variant) + targetApiLevel, err := android.ApiLevelFromUser(ctx, targetBuildRelease.name) + if err != nil { + targetApiLevel = android.FutureApiLevel + } + if lastApiLevel, exists := ignoreHostModuleVariantsAboveDessert[name]; exists && targetApiLevel.GreaterThan(lastApiLevel) && memberVariantDep.Host() { + // ignore host variant of this module if the targetApiLevel is V and above. + continue + } member := byName[name] if member == nil { member = &sdkMember{memberType: memberType, name: name}