Don't install sdk variants, not platform variants

Background: if a lib has `sdk_version` set, it is mutated into two
variants: platform and sdk. The latter is for the inclusion into
unbundled APKs which can be installed on older platforms. The former is
what is installed to the platform.

So far, for unbundled app builds, (1) the platform variant was marked as
uninstallable, (2) while the sdk variant was left installable. (1) is
causing a problem (b/339262059) when an APEX containing a filesystem
module is built as unbundled. The filesystem skips installing the
platform variant. (2) is not causing a problem, but is unnecessary
because the sdk variant is not something to be installed (on the
platform). It is built into the APK via the jni_libs property. It's not
considered an installation.

This change fixes (1) and (2). For (1), the platform variant is always
marked installable even for unbundled build. For (2), the sdk variant is
always marked non-installable.. because, again, it's not designed to be
installed to the platform.

Bug: 339262059
Test: banchan com.android.virt aosp_arm64
UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true m apps_only dist
check libc++.so, libcrypto.so are in the microdroid image in the APEX.

Change-Id: I8999b724926cd9ab6d56796133e218fefcc1910b
This commit is contained in:
Jiyong Park 2024-05-08 11:22:38 +09:00
parent 0d4a9ca792
commit acd5f590af
2 changed files with 9 additions and 7 deletions

View file

@ -119,16 +119,15 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
} else if c.InProduct() {
entries.SetBool("LOCAL_IN_PRODUCT", true)
}
if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
// Make the SDK variant uninstallable so that there are not two rules to install
// to the same location.
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
if c.Properties.SdkAndPlatformVariantVisibleToMake {
// Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
// dependencies to the .sdk suffix when building a module that uses the SDK.
entries.SetString("SOONG_SDK_VARIANT_MODULES",
"$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
}
android.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", c.IsSkipInstall())
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{

View file

@ -49,15 +49,18 @@ func sdkMutator(ctx android.BottomUpMutatorContext) {
modules[1].(*Module).Properties.IsSdkVariant = true
if ctx.Config().UnbundledBuildApps() {
// For an unbundled apps build, hide the platform variant from Make.
// For an unbundled apps build, hide the platform variant from Make
// so that other Make modules don't link against it, but against the
// SDK variant.
modules[0].(*Module).Properties.HideFromMake = true
modules[0].(*Module).Properties.PreventInstall = true
} else {
// For a platform build, mark the SDK variant so that it gets a ".sdk" suffix when
// exposed to Make.
modules[1].(*Module).Properties.SdkAndPlatformVariantVisibleToMake = true
modules[1].(*Module).Properties.PreventInstall = true
}
// SDK variant never gets installed because the variant is to be embedded in
// APKs, not to be installed to the platform.
modules[1].(*Module).Properties.PreventInstall = true
ctx.AliasVariation("")
} else {
if isCcModule {