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

Commit d48fe734 authored by Colin Cross's avatar Colin Cross
Browse files

Fix prebuilt library stubs

There were multiple stacked issues with prebuilt library stubs that
cancelled eachother out.  Prebuilts were never considered to be
DirectlyInAnyApex by the AndroidMk logic to handle stubs libraries
because it looked it up in the global list of modules in apexes
using the name with the "prebuilt_" prefix.  Fixing that to use
ctx.BaseModuleName() exposed a second issue, that stubs variants
for prebuilt libraries were never created, so there was no latest
version to expose to Make.

Making the *prebuiltLibraryLinker type work with all of the
methods that handle stubs should really be done with an interface
and methods implemented on *libraryDecorator, but that would
also cause other types like that embed libraryDecorator to
participate in stubs that may trigger more issues.  I'd like
to replace those methods anyways, so just manually handle
*prebuiltLibraryLinker for now.

Test: m checkbuild
Change-Id: I1267ee01659ad9ab11d75318c6c6bdbf8f72a061
parent 4e1f2bd0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ var (
)

type AndroidMkContext interface {
	Name() string
	BaseModuleName() string
	Target() android.Target
	subAndroidMk(*android.AndroidMkEntries, interface{})
	Arch() android.Arch
@@ -278,7 +278,7 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
		})
	}
	if len(library.Properties.Stubs.Versions) > 0 &&
		android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
		android.DirectlyInAnyApex(ctx, ctx.BaseModuleName()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
		!ctx.static() {
		if library.buildStubs() && library.isLatestStubVersion() {
			// reference the latest version via its name without suffix when it is provided by apex
+38 −0
Original line number Diff line number Diff line
@@ -740,6 +740,9 @@ func (c *Module) StubsVersions() []string {
		if library, ok := c.linker.(*libraryDecorator); ok {
			return library.Properties.Stubs.Versions
		}
		if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
			return library.Properties.Stubs.Versions
		}
	}
	panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
}
@@ -749,6 +752,9 @@ func (c *Module) CcLibrary() bool {
		if _, ok := c.linker.(*libraryDecorator); ok {
			return true
		}
		if _, ok := c.linker.(*prebuiltLibraryLinker); ok {
			return true
		}
	}
	return false
}
@@ -774,6 +780,14 @@ func (c *Module) SetBuildStubs() {
			c.Properties.PreventInstall = true
			return
		}
		if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
			library.MutatedProperties.BuildStubs = true
			c.Properties.HideFromMake = true
			c.sanitize = nil
			c.stl = nil
			c.Properties.PreventInstall = true
			return
		}
		if _, ok := c.linker.(*llndkStubDecorator); ok {
			c.Properties.HideFromMake = true
			return
@@ -787,6 +801,9 @@ func (c *Module) BuildStubs() bool {
		if library, ok := c.linker.(*libraryDecorator); ok {
			return library.buildStubs()
		}
		if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
			return library.buildStubs()
		}
	}
	panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
}
@@ -796,6 +813,10 @@ func (c *Module) SetAllStubsVersions(versions []string) {
		library.MutatedProperties.AllStubsVersions = versions
		return
	}
	if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
		library.MutatedProperties.AllStubsVersions = versions
		return
	}
	if llndk, ok := c.linker.(*llndkStubDecorator); ok {
		llndk.libraryDecorator.MutatedProperties.AllStubsVersions = versions
		return
@@ -806,6 +827,9 @@ func (c *Module) AllStubsVersions() []string {
	if library, ok := c.linker.(*libraryDecorator); ok {
		return library.MutatedProperties.AllStubsVersions
	}
	if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
		return library.MutatedProperties.AllStubsVersions
	}
	if llndk, ok := c.linker.(*llndkStubDecorator); ok {
		return llndk.libraryDecorator.MutatedProperties.AllStubsVersions
	}
@@ -818,6 +842,10 @@ func (c *Module) SetStubsVersion(version string) {
			library.MutatedProperties.StubsVersion = version
			return
		}
		if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
			library.MutatedProperties.StubsVersion = version
			return
		}
		if llndk, ok := c.linker.(*llndkStubDecorator); ok {
			llndk.libraryDecorator.MutatedProperties.StubsVersion = version
			return
@@ -831,6 +859,9 @@ func (c *Module) StubsVersion() string {
		if library, ok := c.linker.(*libraryDecorator); ok {
			return library.MutatedProperties.StubsVersion
		}
		if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
			return library.MutatedProperties.StubsVersion
		}
		if llndk, ok := c.linker.(*llndkStubDecorator); ok {
			return llndk.libraryDecorator.MutatedProperties.StubsVersion
		}
@@ -1073,6 +1104,8 @@ func (c *Module) getVndkExtendsModuleName() string {
func (c *Module) IsStubs() bool {
	if library, ok := c.linker.(*libraryDecorator); ok {
		return library.buildStubs()
	} else if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
		return library.buildStubs()
	} else if _, ok := c.linker.(*llndkStubDecorator); ok {
		return true
	}
@@ -1930,6 +1963,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
				buildStubs = true
			}
		}
		if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
			if library.buildStubs() {
				buildStubs = true
			}
		}
	}

	rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {