Merge changes I0289d866,Ie7363524
* changes: Move stubs related methods out of LinkableInterface Don't create stubs variants of static libraries
This commit is contained in:
@@ -825,7 +825,7 @@ func TestApexWithStubs(t *testing.T) {
|
|||||||
ensureNotContains(t, mylib2Cflags, "-include ")
|
ensureNotContains(t, mylib2Cflags, "-include ")
|
||||||
|
|
||||||
// Ensure that genstub is invoked with --apex
|
// Ensure that genstub is invoked with --apex
|
||||||
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_3").Rule("genStubSrc").Args["flags"])
|
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_shared_3").Rule("genStubSrc").Args["flags"])
|
||||||
|
|
||||||
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
"lib64/mylib.so",
|
"lib64/mylib.so",
|
||||||
@@ -920,11 +920,11 @@ func TestApexWithStubsWithMinSdkVersion(t *testing.T) {
|
|||||||
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_29/mylib3.so")
|
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_29/mylib3.so")
|
||||||
|
|
||||||
// Ensure that stubs libs are built without -include flags
|
// Ensure that stubs libs are built without -include flags
|
||||||
mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
|
mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_shared_29").Rule("cc").Args["cFlags"]
|
||||||
ensureNotContains(t, mylib2Cflags, "-include ")
|
ensureNotContains(t, mylib2Cflags, "-include ")
|
||||||
|
|
||||||
// Ensure that genstub is invoked with --apex
|
// Ensure that genstub is invoked with --apex
|
||||||
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_29").Rule("genStubSrc").Args["flags"])
|
ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_shared_29").Rule("genStubSrc").Args["flags"])
|
||||||
|
|
||||||
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
"lib64/mylib.so",
|
"lib64/mylib.so",
|
||||||
|
137
cc/cc.go
137
cc/cc.go
@@ -377,8 +377,6 @@ type ModuleContextIntf interface {
|
|||||||
isForPlatform() bool
|
isForPlatform() bool
|
||||||
apexVariationName() string
|
apexVariationName() string
|
||||||
apexSdkVersion() android.ApiLevel
|
apexSdkVersion() android.ApiLevel
|
||||||
hasStubsVariants() bool
|
|
||||||
isStubs() bool
|
|
||||||
bootstrap() bool
|
bootstrap() bool
|
||||||
mustUseVendorVariant() bool
|
mustUseVendorVariant() bool
|
||||||
nativeCoverage() bool
|
nativeCoverage() bool
|
||||||
@@ -623,6 +621,8 @@ type Module struct {
|
|||||||
lto *lto
|
lto *lto
|
||||||
pgo *pgo
|
pgo *pgo
|
||||||
|
|
||||||
|
library libraryInterface
|
||||||
|
|
||||||
outputFile android.OptionalPath
|
outputFile android.OptionalPath
|
||||||
|
|
||||||
cachedToolchain config.Toolchain
|
cachedToolchain config.Toolchain
|
||||||
@@ -731,13 +731,6 @@ func (c *Module) AlwaysSdk() bool {
|
|||||||
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) StubsVersions(ctx android.BaseMutatorContext) []string {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
return versioned.stubsVersions(ctx)
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) CcLibrary() bool {
|
func (c *Module) CcLibrary() bool {
|
||||||
if c.linker != nil {
|
if c.linker != nil {
|
||||||
if _, ok := c.linker.(*libraryDecorator); ok {
|
if _, ok := c.linker.(*libraryDecorator); ok {
|
||||||
@@ -761,53 +754,6 @@ func (c *Module) NonCcVariants() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) SetBuildStubs() {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
versioned.setBuildStubs()
|
|
||||||
c.Properties.HideFromMake = true
|
|
||||||
c.sanitize = nil
|
|
||||||
c.stl = nil
|
|
||||||
c.Properties.PreventInstall = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) BuildStubs() bool {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
return versioned.buildStubs()
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) SetAllStubsVersions(versions []string) {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
versioned.setAllStubsVersions(versions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) AllStubsVersions() []string {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
return versioned.allStubsVersions()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) SetStubsVersion(version string) {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
versioned.setStubsVersion(version)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("SetStubsVersion called on non-library module: %q", c.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) StubsVersion() string {
|
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
|
||||||
return versioned.stubsVersion()
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("StubsVersion called on non-library module: %q", c.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Module) SetStatic() {
|
func (c *Module) SetStatic() {
|
||||||
if c.linker != nil {
|
if c.linker != nil {
|
||||||
if library, ok := c.linker.(libraryInterface); ok {
|
if library, ok := c.linker.(libraryInterface); ok {
|
||||||
@@ -1041,15 +987,15 @@ func (c *Module) getVndkExtendsModuleName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) IsStubs() bool {
|
func (c *Module) IsStubs() bool {
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
if lib := c.library; lib != nil {
|
||||||
return versioned.buildStubs()
|
return lib.buildStubs()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) HasStubsVariants() bool {
|
func (c *Module) HasStubsVariants() bool {
|
||||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
if lib := c.library; lib != nil {
|
||||||
return versioned.hasStubsVariants()
|
return lib.hasStubsVariants()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -1240,10 +1186,15 @@ func (ctx *moduleContextImpl) shouldCreateSourceAbiDump() bool {
|
|||||||
// Host modules do not need ABI dumps.
|
// Host modules do not need ABI dumps.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if ctx.isStubs() || ctx.isNDKStubLibrary() {
|
if ctx.isNDKStubLibrary() {
|
||||||
// Stubs do not need ABI dumps.
|
// Stubs do not need ABI dumps.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lib := ctx.mod.library; lib != nil && lib.buildStubs() {
|
||||||
|
// Stubs do not need ABI dumps.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1278,14 +1229,6 @@ func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel {
|
|||||||
return ctx.mod.apexSdkVersion
|
return ctx.mod.apexSdkVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) hasStubsVariants() bool {
|
|
||||||
return ctx.mod.HasStubsVariants()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) isStubs() bool {
|
|
||||||
return ctx.mod.IsStubs()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) bootstrap() bool {
|
func (ctx *moduleContextImpl) bootstrap() bool {
|
||||||
return ctx.mod.bootstrap()
|
return ctx.mod.bootstrap()
|
||||||
}
|
}
|
||||||
@@ -2078,18 +2021,20 @@ func checkLinkType(ctx android.BaseModuleContext, from LinkableInterface, to Lin
|
|||||||
// Recovery code is not NDK
|
// Recovery code is not NDK
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if to.ToolchainLibrary() {
|
if c, ok := to.(*Module); ok {
|
||||||
// These are always allowed
|
if c.ToolchainLibrary() {
|
||||||
return
|
// These are always allowed
|
||||||
}
|
return
|
||||||
if to.NdkPrebuiltStl() {
|
}
|
||||||
// These are allowed, but they don't set sdk_version
|
if c.NdkPrebuiltStl() {
|
||||||
return
|
// These are allowed, but they don't set sdk_version
|
||||||
}
|
return
|
||||||
if to.StubDecorator() {
|
}
|
||||||
// These aren't real libraries, but are the stub shared libraries that are included in
|
if c.StubDecorator() {
|
||||||
// the NDK.
|
// These aren't real libraries, but are the stub shared libraries that are included in
|
||||||
return
|
// the NDK.
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Module().Name() == "libc++" {
|
if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Module().Name() == "libc++" {
|
||||||
@@ -2337,12 +2282,17 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if depTag == reuseObjTag {
|
if depTag == reuseObjTag {
|
||||||
// reusing objects only make sense for cc.Modules.
|
// Skip reused objects for stub libraries, they use their own stub object file instead.
|
||||||
staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
|
// The reuseObjTag dependency still exists because the LinkageMutator runs before the
|
||||||
objs := staticAnalogue.ReuseObjects
|
// version mutator, so the stubs variant is created from the shared variant that
|
||||||
depPaths.Objs = depPaths.Objs.Append(objs)
|
// already has the reuseObjTag dependency on the static variant.
|
||||||
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
if !c.library.buildStubs() {
|
||||||
reexportExporter(depExporterInfo)
|
staticAnalogue := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
|
||||||
|
objs := staticAnalogue.ReuseObjects
|
||||||
|
depPaths.Objs = depPaths.Objs.Append(objs)
|
||||||
|
depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||||
|
reexportExporter(depExporterInfo)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2378,7 +2328,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
|
|
||||||
if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedLibraryStubsInfos) > 0 {
|
if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedLibraryStubsInfos) > 0 {
|
||||||
useStubs := false
|
useStubs := false
|
||||||
if m, ok := ccDep.(*Module); ok && m.IsStubs() && c.UseVndk() { // LLNDK
|
|
||||||
|
if lib := moduleLibraryInterface(dep); lib.buildStubs() && c.UseVndk() { // LLNDK
|
||||||
if !apexInfo.IsForPlatform() {
|
if !apexInfo.IsForPlatform() {
|
||||||
// For platform libraries, use current version of LLNDK
|
// For platform libraries, use current version of LLNDK
|
||||||
// If this is for use_vendor apex we will apply the same rules
|
// If this is for use_vendor apex we will apply the same rules
|
||||||
@@ -2547,8 +2498,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
c.Properties.AndroidMkHeaderLibs = append(
|
c.Properties.AndroidMkHeaderLibs = append(
|
||||||
c.Properties.AndroidMkHeaderLibs, makeLibName)
|
c.Properties.AndroidMkHeaderLibs, makeLibName)
|
||||||
case libDepTag.shared():
|
case libDepTag.shared():
|
||||||
if ccDep.CcLibrary() {
|
if lib := moduleLibraryInterface(dep); lib != nil {
|
||||||
if ccDep.BuildStubs() && dep.(android.ApexModule).InAnyApex() {
|
if lib.buildStubs() && dep.(android.ApexModule).InAnyApex() {
|
||||||
// Add the dependency to the APEX(es) providing the library so that
|
// Add the dependency to the APEX(es) providing the library so that
|
||||||
// m <module> can trigger building the APEXes as well.
|
// m <module> can trigger building the APEXes as well.
|
||||||
depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
|
depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
@@ -2850,12 +2801,10 @@ func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
|
|||||||
// Overrides ApexModule.IsInstallabeToApex()
|
// Overrides ApexModule.IsInstallabeToApex()
|
||||||
// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
|
// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
|
||||||
func (c *Module) IsInstallableToApex() bool {
|
func (c *Module) IsInstallableToApex() bool {
|
||||||
if shared, ok := c.linker.(interface {
|
if lib := c.library; lib != nil {
|
||||||
shared() bool
|
|
||||||
}); ok {
|
|
||||||
// Stub libs and prebuilt libs in a versioned SDK are not
|
// Stub libs and prebuilt libs in a versioned SDK are not
|
||||||
// installable to APEX even though they are shared libs.
|
// installable to APEX even though they are shared libs.
|
||||||
return shared.shared() && !c.IsStubs() && c.ContainingSdk().Unversioned()
|
return lib.shared() && !lib.buildStubs() && c.ContainingSdk().Unversioned()
|
||||||
} else if _, ok := c.linker.(testPerSrc); ok {
|
} else if _, ok := c.linker.(testPerSrc); ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
21
cc/fuzz.go
21
cc/fuzz.go
@@ -174,12 +174,25 @@ func isValidSharedDependency(dependency android.Module) bool {
|
|||||||
// TODO(b/144090547): We should be parsing these modules using
|
// TODO(b/144090547): We should be parsing these modules using
|
||||||
// ModuleDependencyTag instead of the current brute-force checking.
|
// ModuleDependencyTag instead of the current brute-force checking.
|
||||||
|
|
||||||
if linkable, ok := dependency.(LinkableInterface); !ok || // Discard non-linkables.
|
linkable, ok := dependency.(LinkableInterface)
|
||||||
!linkable.CcLibraryInterface() || !linkable.Shared() || // Discard static libs.
|
if !ok || !linkable.CcLibraryInterface() {
|
||||||
linkable.UseVndk() || // Discard vendor linked libraries.
|
// Discard non-linkables.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !linkable.Shared() {
|
||||||
|
// Discard static libs.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if linkable.UseVndk() {
|
||||||
|
// Discard vendor linked libraries.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if lib := moduleLibraryInterface(dependency); lib != nil && lib.buildStubs() && linkable.CcLibrary() {
|
||||||
// Discard stubs libs (only CCLibrary variants). Prebuilt libraries should not
|
// Discard stubs libs (only CCLibrary variants). Prebuilt libraries should not
|
||||||
// be excluded on the basis of they're not CCLibrary()'s.
|
// be excluded on the basis of they're not CCLibrary()'s.
|
||||||
(linkable.CcLibrary() && linkable.BuildStubs()) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -587,7 +587,7 @@ func (library *libraryDecorator) classifySourceAbiDump(ctx ModuleContext) string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if Bool(enabled) || ctx.hasStubsVariants() {
|
if Bool(enabled) || library.hasStubsVariants() {
|
||||||
return "PLATFORM"
|
return "PLATFORM"
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -598,7 +598,7 @@ func (library *libraryDecorator) shouldCreateSourceAbiDump(ctx ModuleContext) bo
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !ctx.isForPlatform() {
|
if !ctx.isForPlatform() {
|
||||||
if !ctx.hasStubsVariants() {
|
if !library.hasStubsVariants() {
|
||||||
// Skip ABI checks if this library is for APEX but isn't exported.
|
// Skip ABI checks if this library is for APEX but isn't exported.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -1060,7 +1060,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
|||||||
stubInfo := ctx.OtherModuleProvider(stub, SharedLibraryInfoProvider).(SharedLibraryInfo)
|
stubInfo := ctx.OtherModuleProvider(stub, SharedLibraryInfoProvider).(SharedLibraryInfo)
|
||||||
flagInfo := ctx.OtherModuleProvider(stub, FlagExporterInfoProvider).(FlagExporterInfo)
|
flagInfo := ctx.OtherModuleProvider(stub, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||||
stubsInfo = append(stubsInfo, SharedLibraryStubsInfo{
|
stubsInfo = append(stubsInfo, SharedLibraryStubsInfo{
|
||||||
Version: stub.(*Module).StubsVersion(),
|
Version: moduleLibraryInterface(stub).stubsVersion(),
|
||||||
SharedLibraryInfo: stubInfo,
|
SharedLibraryInfo: stubInfo,
|
||||||
FlagExporterInfo: flagInfo,
|
FlagExporterInfo: flagInfo,
|
||||||
})
|
})
|
||||||
@@ -1384,7 +1384,7 @@ func (library *libraryDecorator) symbolFileForAbiCheck(ctx ModuleContext) *strin
|
|||||||
if library.Properties.Header_abi_checker.Symbol_file != nil {
|
if library.Properties.Header_abi_checker.Symbol_file != nil {
|
||||||
return library.Properties.Header_abi_checker.Symbol_file
|
return library.Properties.Header_abi_checker.Symbol_file
|
||||||
}
|
}
|
||||||
if ctx.hasStubsVariants() && library.Properties.Stubs.Symbol_file != nil {
|
if library.hasStubsVariants() && library.Properties.Stubs.Symbol_file != nil {
|
||||||
return library.Properties.Stubs.Symbol_file
|
return library.Properties.Stubs.Symbol_file
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -1483,6 +1483,7 @@ func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator)
|
|||||||
module.compiler = library
|
module.compiler = library
|
||||||
module.linker = library
|
module.linker = library
|
||||||
module.installer = library
|
module.installer = library
|
||||||
|
module.library = library
|
||||||
|
|
||||||
return module, library
|
return module, library
|
||||||
}
|
}
|
||||||
@@ -1620,8 +1621,14 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
|
|||||||
modules := mctx.CreateLocalVariations(variants...)
|
modules := mctx.CreateLocalVariations(variants...)
|
||||||
for i, m := range modules {
|
for i, m := range modules {
|
||||||
if variants[i] != "" {
|
if variants[i] != "" {
|
||||||
m.(LinkableInterface).SetBuildStubs()
|
c := m.(*Module)
|
||||||
m.(LinkableInterface).SetStubsVersion(variants[i])
|
c.Properties.HideFromMake = true
|
||||||
|
c.sanitize = nil
|
||||||
|
c.stl = nil
|
||||||
|
c.Properties.PreventInstall = true
|
||||||
|
lib := moduleLibraryInterface(m)
|
||||||
|
lib.setBuildStubs()
|
||||||
|
lib.setStubsVersion(variants[i])
|
||||||
// The implementation depends on the stubs
|
// The implementation depends on the stubs
|
||||||
mctx.AddInterVariantDependency(stubImplDepTag, modules[len(modules)-1], modules[i])
|
mctx.AddInterVariantDependency(stubImplDepTag, modules[len(modules)-1], modules[i])
|
||||||
}
|
}
|
||||||
@@ -1665,18 +1672,24 @@ func CanBeVersionVariant(module interface {
|
|||||||
InRecovery() bool
|
InRecovery() bool
|
||||||
CcLibraryInterface() bool
|
CcLibraryInterface() bool
|
||||||
Shared() bool
|
Shared() bool
|
||||||
Static() bool
|
|
||||||
}) bool {
|
}) bool {
|
||||||
return CanBeOrLinkAgainstVersionVariants(module) &&
|
return CanBeOrLinkAgainstVersionVariants(module) &&
|
||||||
module.CcLibraryInterface() && (module.Shared() || module.Static())
|
module.CcLibraryInterface() && module.Shared()
|
||||||
|
}
|
||||||
|
|
||||||
|
func moduleLibraryInterface(module android.Module) libraryInterface {
|
||||||
|
if m, ok := module.(*Module); ok {
|
||||||
|
return m.library
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// versionSelector normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions,
|
// versionSelector normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions,
|
||||||
// and propagates the value from implementation libraries to llndk libraries with the same name.
|
// and propagates the value from implementation libraries to llndk libraries with the same name.
|
||||||
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
if library := moduleLibraryInterface(mctx.Module()); library != nil && CanBeVersionVariant(mctx.Module().(*Module)) {
|
||||||
if library.CcLibraryInterface() && library.BuildSharedVariant() {
|
if library.buildShared() {
|
||||||
versions := library.StubsVersions(mctx)
|
versions := library.stubsVersions(mctx)
|
||||||
if len(versions) > 0 {
|
if len(versions) > 0 {
|
||||||
normalizeVersions(mctx, versions)
|
normalizeVersions(mctx, versions)
|
||||||
if mctx.Failed() {
|
if mctx.Failed() {
|
||||||
@@ -1684,7 +1697,7 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
// Set the versions on the pre-mutated module so they can be read by any llndk modules that
|
// Set the versions on the pre-mutated module so they can be read by any llndk modules that
|
||||||
// depend on the implementation library and haven't been mutated yet.
|
// depend on the implementation library and haven't been mutated yet.
|
||||||
library.SetAllStubsVersions(versions)
|
library.setAllStubsVersions(versions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1694,8 +1707,8 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
// versionMutator splits a module into the mandatory non-stubs variant
|
// versionMutator splits a module into the mandatory non-stubs variant
|
||||||
// (which is unnamed) and zero or more stubs variants.
|
// (which is unnamed) and zero or more stubs variants.
|
||||||
func versionMutator(mctx android.BottomUpMutatorContext) {
|
func versionMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
if library := moduleLibraryInterface(mctx.Module()); library != nil && CanBeVersionVariant(mctx.Module().(*Module)) {
|
||||||
createVersionVariations(mctx, library.AllStubsVersions())
|
createVersionVariations(mctx, library.allStubsVersions())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,10 +86,6 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont
|
|||||||
if mctx.Device() {
|
if mctx.Device() {
|
||||||
variations = append(variations,
|
variations = append(variations,
|
||||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||||
if mt.linkTypes != nil {
|
|
||||||
variations = append(variations,
|
|
||||||
blueprint.Variation{Mutator: "version", Variation: version})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if mt.linkTypes == nil {
|
if mt.linkTypes == nil {
|
||||||
mctx.AddFarVariationDependencies(variations, dependencyTag, name)
|
mctx.AddFarVariationDependencies(variations, dependencyTag, name)
|
||||||
@@ -97,6 +93,10 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont
|
|||||||
for _, linkType := range mt.linkTypes {
|
for _, linkType := range mt.linkTypes {
|
||||||
libVariations := append(variations,
|
libVariations := append(variations,
|
||||||
blueprint.Variation{Mutator: "link", Variation: linkType})
|
blueprint.Variation{Mutator: "link", Variation: linkType})
|
||||||
|
if mctx.Device() && linkType == "shared" {
|
||||||
|
libVariations = append(libVariations,
|
||||||
|
blueprint.Variation{Mutator: "version", Variation: version})
|
||||||
|
}
|
||||||
mctx.AddFarVariationDependencies(libVariations, dependencyTag, name)
|
mctx.AddFarVariationDependencies(libVariations, dependencyTag, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,22 +428,22 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte
|
|||||||
specifiedDeps := specifiedDeps{}
|
specifiedDeps := specifiedDeps{}
|
||||||
specifiedDeps = ccModule.linker.linkerSpecifiedDeps(specifiedDeps)
|
specifiedDeps = ccModule.linker.linkerSpecifiedDeps(specifiedDeps)
|
||||||
|
|
||||||
if !ccModule.HasStubsVariants() {
|
if lib := ccModule.library; lib != nil {
|
||||||
// Propagate dynamic dependencies for implementation libs, but not stubs.
|
if !lib.hasStubsVariants() {
|
||||||
p.SharedLibs = specifiedDeps.sharedLibs
|
// Propagate dynamic dependencies for implementation libs, but not stubs.
|
||||||
|
p.SharedLibs = specifiedDeps.sharedLibs
|
||||||
|
} else {
|
||||||
|
// TODO(b/169373910): 1. Only output the specific version (from
|
||||||
|
// ccModule.StubsVersion()) if the module is versioned. 2. Ensure that all
|
||||||
|
// the versioned stub libs are retained in the prebuilt tree; currently only
|
||||||
|
// the stub corresponding to ccModule.StubsVersion() is.
|
||||||
|
p.StubsVersions = lib.allStubsVersions()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p.SystemSharedLibs = specifiedDeps.systemSharedLibs
|
p.SystemSharedLibs = specifiedDeps.systemSharedLibs
|
||||||
}
|
}
|
||||||
p.exportedGeneratedHeaders = exportedInfo.GeneratedHeaders
|
p.exportedGeneratedHeaders = exportedInfo.GeneratedHeaders
|
||||||
|
|
||||||
if ccModule.HasStubsVariants() {
|
|
||||||
// TODO(b/169373910): 1. Only output the specific version (from
|
|
||||||
// ccModule.StubsVersion()) if the module is versioned. 2. Ensure that all
|
|
||||||
// the versioned stub libs are retained in the prebuilt tree; currently only
|
|
||||||
// the stub corresponding to ccModule.StubsVersion() is.
|
|
||||||
p.StubsVersions = ccModule.AllStubsVersions()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !p.memberType.noOutputFiles && addOutputFile {
|
if !p.memberType.noOutputFiles && addOutputFile {
|
||||||
p.outputFile = getRequiredMemberOutputFile(ctx, ccModule)
|
p.outputFile = getRequiredMemberOutputFile(ctx, ccModule)
|
||||||
}
|
}
|
||||||
|
@@ -16,16 +16,7 @@ type LinkableInterface interface {
|
|||||||
|
|
||||||
NonCcVariants() bool
|
NonCcVariants() bool
|
||||||
|
|
||||||
StubsVersions(android.BaseMutatorContext) []string
|
|
||||||
BuildStubs() bool
|
|
||||||
SetBuildStubs()
|
|
||||||
SetStubsVersion(string)
|
|
||||||
StubsVersion() string
|
|
||||||
SetAllStubsVersions([]string)
|
|
||||||
AllStubsVersions() []string
|
|
||||||
HasStubsVariants() bool
|
|
||||||
SelectedStl() string
|
SelectedStl() string
|
||||||
ApiLevel() string
|
|
||||||
|
|
||||||
BuildStaticVariant() bool
|
BuildStaticVariant() bool
|
||||||
BuildSharedVariant() bool
|
BuildSharedVariant() bool
|
||||||
@@ -56,10 +47,6 @@ type LinkableInterface interface {
|
|||||||
AlwaysSdk() bool
|
AlwaysSdk() bool
|
||||||
IsSdkVariant() bool
|
IsSdkVariant() bool
|
||||||
|
|
||||||
ToolchainLibrary() bool
|
|
||||||
NdkPrebuiltStl() bool
|
|
||||||
StubDecorator() bool
|
|
||||||
|
|
||||||
SplitPerApiLevel() bool
|
SplitPerApiLevel() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -185,7 +185,7 @@ func (stub *llndkStubDecorator) stubsVersions(ctx android.BaseMutatorContext) []
|
|||||||
if len(impls) > 1 {
|
if len(impls) > 1 {
|
||||||
panic(fmt.Errorf("Expected single implmenetation library, got %d", len(impls)))
|
panic(fmt.Errorf("Expected single implmenetation library, got %d", len(impls)))
|
||||||
} else if len(impls) == 1 {
|
} else if len(impls) == 1 {
|
||||||
return impls[0].(*Module).AllStubsVersions()
|
return moduleLibraryInterface(impls[0]).allStubsVersions()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -204,6 +204,7 @@ func NewLLndkStubLibrary() *Module {
|
|||||||
module.compiler = stub
|
module.compiler = stub
|
||||||
module.linker = stub
|
module.linker = stub
|
||||||
module.installer = nil
|
module.installer = nil
|
||||||
|
module.library = stub
|
||||||
|
|
||||||
module.AddProperties(
|
module.AddProperties(
|
||||||
&module.Properties,
|
&module.Properties,
|
||||||
@@ -251,6 +252,7 @@ func llndkHeadersFactory() android.Module {
|
|||||||
module.compiler = nil
|
module.compiler = nil
|
||||||
module.linker = decorator
|
module.linker = decorator
|
||||||
module.installer = nil
|
module.installer = nil
|
||||||
|
module.library = decorator
|
||||||
|
|
||||||
module.AddProperties(
|
module.AddProperties(
|
||||||
&module.Properties,
|
&module.Properties,
|
||||||
|
@@ -333,6 +333,7 @@ func newStubLibrary() *Module {
|
|||||||
module.compiler = stub
|
module.compiler = stub
|
||||||
module.linker = stub
|
module.linker = stub
|
||||||
module.installer = stub
|
module.installer = stub
|
||||||
|
module.library = stub
|
||||||
|
|
||||||
module.Properties.AlwaysSdk = true
|
module.Properties.AlwaysSdk = true
|
||||||
module.Properties.Sdk_version = StringPtr("current")
|
module.Properties.Sdk_version = StringPtr("current")
|
||||||
|
@@ -131,7 +131,7 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m, ok := module.(*Module); ok {
|
if m, ok := module.(*Module); ok {
|
||||||
if installer, ok := m.installer.(*stubDecorator); ok && m.BuildStubs() {
|
if installer, ok := m.installer.(*stubDecorator); ok && m.library.buildStubs() {
|
||||||
if ctx.Config().ExcludeDraftNdkApis() &&
|
if ctx.Config().ExcludeDraftNdkApis() &&
|
||||||
installer.properties.Draft {
|
installer.properties.Draft {
|
||||||
return
|
return
|
||||||
|
@@ -228,6 +228,7 @@ func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDec
|
|||||||
libraryDecorator: library,
|
libraryDecorator: library,
|
||||||
}
|
}
|
||||||
module.linker = prebuilt
|
module.linker = prebuilt
|
||||||
|
module.library = prebuilt
|
||||||
|
|
||||||
module.AddProperties(&prebuilt.properties)
|
module.AddProperties(&prebuilt.properties)
|
||||||
|
|
||||||
|
@@ -66,6 +66,7 @@ func ToolchainLibraryFactory() android.Module {
|
|||||||
module.stl = nil
|
module.stl = nil
|
||||||
module.sanitize = nil
|
module.sanitize = nil
|
||||||
module.installer = nil
|
module.installer = nil
|
||||||
|
module.library = toolchainLibrary
|
||||||
module.Properties.Sdk_version = StringPtr("current")
|
module.Properties.Sdk_version = StringPtr("current")
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
@@ -313,7 +313,7 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.HasStubsVariants() && name != "libz" {
|
if lib := m.library; lib != nil && lib.hasStubsVariants() && name != "libz" {
|
||||||
// b/155456180 libz is the ONLY exception here. We don't want to make
|
// b/155456180 libz is the ONLY exception here. We don't want to make
|
||||||
// libz an LLNDK library because we in general can't guarantee that
|
// libz an LLNDK library because we in general can't guarantee that
|
||||||
// libz will behave consistently especially about the compression.
|
// libz will behave consistently especially about the compression.
|
||||||
|
54
rust/rust.go
54
rust/rust.go
@@ -133,14 +133,6 @@ func (mod *Module) ExtraImageVariations(android.BaseModuleContext) []string {
|
|||||||
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
|
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) BuildStubs() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) HasStubsVariants() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) SelectedStl() string {
|
func (mod *Module) SelectedStl() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -154,10 +146,6 @@ func (mod *Module) NonCcVariants() bool {
|
|||||||
panic(fmt.Errorf("NonCcVariants called on non-library module: %q", mod.BaseModuleName()))
|
panic(fmt.Errorf("NonCcVariants called on non-library module: %q", mod.BaseModuleName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) ApiLevel() string {
|
|
||||||
panic(fmt.Errorf("Called ApiLevel on Rust module %q; stubs libraries are not yet supported.", mod.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) Static() bool {
|
func (mod *Module) Static() bool {
|
||||||
if mod.compiler != nil {
|
if mod.compiler != nil {
|
||||||
if library, ok := mod.compiler.(libraryInterface); ok {
|
if library, ok := mod.compiler.(libraryInterface); ok {
|
||||||
@@ -233,18 +221,6 @@ func (mod *Module) SplitPerApiLevel() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) ToolchainLibrary() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) NdkPrebuiltStl() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) StubDecorator() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
Dylibs []string
|
Dylibs []string
|
||||||
Rlibs []string
|
Rlibs []string
|
||||||
@@ -466,26 +442,6 @@ func (mod *Module) SetShared() {
|
|||||||
panic(fmt.Errorf("SetShared called on non-library module: %q", mod.BaseModuleName()))
|
panic(fmt.Errorf("SetShared called on non-library module: %q", mod.BaseModuleName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) SetBuildStubs() {
|
|
||||||
panic("SetBuildStubs not yet implemented for rust modules")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) SetStubsVersion(string) {
|
|
||||||
panic("SetStubsVersion not yet implemented for rust modules")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) StubsVersion() string {
|
|
||||||
panic("StubsVersion not yet implemented for rust modules")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) SetAllStubsVersions([]string) {
|
|
||||||
panic("SetAllStubsVersions not yet implemented for rust modules")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) AllStubsVersions() []string {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) BuildStaticVariant() bool {
|
func (mod *Module) BuildStaticVariant() bool {
|
||||||
if mod.compiler != nil {
|
if mod.compiler != nil {
|
||||||
if library, ok := mod.compiler.(libraryInterface); ok {
|
if library, ok := mod.compiler.(libraryInterface); ok {
|
||||||
@@ -508,16 +464,6 @@ func (mod *Module) Module() android.Module {
|
|||||||
return mod
|
return mod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) StubsVersions(ctx android.BaseMutatorContext) []string {
|
|
||||||
// For now, Rust has no stubs versions.
|
|
||||||
if mod.compiler != nil {
|
|
||||||
if _, ok := mod.compiler.(libraryInterface); ok {
|
|
||||||
return []string{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("StubsVersions called on non-library module: %q", mod.BaseModuleName()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *Module) OutputFile() android.OptionalPath {
|
func (mod *Module) OutputFile() android.OptionalPath {
|
||||||
return mod.outputFile
|
return mod.outputFile
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user