Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 386afeb2 authored by Colin Cross's avatar Colin Cross
Browse files

Don't use ctx.directlyInAnyApex for bootstrap libraries

The check for directlyInAnyApex is redundant for bootstrap libraries,
they are already explicitly enumerated in InstallToBootstrap, and
they are all directly in an apex.  Replace the check with
!ctx.isSdkVariant(), since ctx.directlyInAnyApex() was returning
false for the sdk variants.

Bug: 372543712
Test: no change to build.ninja
Test: all Soong tests pass
Change-Id: I00f63757bc93e50affcc54577393e34a5625154e
parent 4169898d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
	// The original path becomes a symlink to the corresponding file in the
	// runtime APEX.
	translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
	if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && ctx.directlyInAnyApex() &&
	if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && !ctx.isSdkVariant() &&
		!translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() &&
		!ctx.inVendorRamdisk() {

+0 −5
Original line number Diff line number Diff line
@@ -548,7 +548,6 @@ type ModuleContextIntf interface {
	apexSdkVersion() android.ApiLevel
	bootstrap() bool
	nativeCoverage() bool
	directlyInAnyApex() bool
	isPreventInstall() bool
	isCfiAssemblySupportEnabled() bool
	getSharedFlags() *SharedFlags
@@ -1692,10 +1691,6 @@ func (ctx *moduleContextImpl) nativeCoverage() bool {
	return ctx.mod.nativeCoverage()
}

func (ctx *moduleContextImpl) directlyInAnyApex() bool {
	return ctx.mod.DirectlyInAnyApex()
}

func (ctx *moduleContextImpl) isPreventInstall() bool {
	return ctx.mod.Properties.PreventInstall
}
+7 −11
Original line number Diff line number Diff line
@@ -1750,22 +1750,18 @@ func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext,

func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
	if library.shared() {
		if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
		translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
		if library.hasStubsVariants() && !ctx.Host() && !ctx.isSdkVariant() &&
			InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() &&
			!translatedArch && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() {
			// Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory.
			// The original path becomes a symlink to the corresponding file in the
			// runtime APEX.
			translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
			if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() &&
				!translatedArch && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() {
			if ctx.Device() {
				library.installSymlinkToRuntimeApex(ctx, file)
			}
			library.baseInstaller.subDir = "bootstrap"
		}
		} else if ctx.directlyInAnyApex() && ctx.IsLlndk() && !isBionic(ctx.baseModuleName()) {
			// Skip installing LLNDK (non-bionic) libraries moved to APEX.
			ctx.Module().HideFromMake()
		}

		library.baseInstaller.install(ctx, file)
	}
+6 −2
Original line number Diff line number Diff line
@@ -666,7 +666,9 @@ func TestUseSharedVariationOfNativeLib(t *testing.T) {

	partition := result.ModuleForTests("myfilesystem", "android_common")
	fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
	android.AssertDeepEquals(t, "cc_library listed in deps", "lib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo.so\nlib64/libm.so\n", fileList)
	android.AssertDeepEquals(t, "cc_library listed in deps",
		"lib64/bootstrap/libc.so\nlib64/bootstrap/libdl.so\nlib64/bootstrap/libm.so\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo.so\nlib64/libm.so\n",
		fileList)
}

// binfoo1 overrides binbar. transitive deps of binbar should not be installed.
@@ -701,7 +703,9 @@ cc_library {

	partition := result.ModuleForTests("myfilesystem", "android_common")
	fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
	android.AssertDeepEquals(t, "Shared library dep of overridden binary should not be installed", fileList, "bin/binfoo1\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo2.so\nlib64/libm.so\n")
	android.AssertDeepEquals(t, "Shared library dep of overridden binary should not be installed",
		"bin/binfoo1\nlib64/bootstrap/libc.so\nlib64/bootstrap/libdl.so\nlib64/bootstrap/libm.so\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo2.so\nlib64/libm.so\n",
		fileList)
}

func TestInstallLinkerConfigFile(t *testing.T) {