Revert "Revert "Enforce min_sdk_version of apex(use_vendor:true)""

This reverts commit bacf34d986.

Reason for revert: reland with fix

Change-Id: Ia03f2808353f5640597ae7ecbf2e06fc903c6977
This commit is contained in:
Jooyung Han
2020-03-21 14:21:46 +00:00
parent b1eb4d4a94
commit 61b66e9b34
6 changed files with 189 additions and 63 deletions

View File

@@ -622,6 +622,10 @@ func (c *Module) SetBuildStubs() {
c.Properties.PreventInstall = true
return
}
if _, ok := c.linker.(*llndkStubDecorator); ok {
c.Properties.HideFromMake = true
return
}
}
panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName()))
}
@@ -641,6 +645,10 @@ func (c *Module) SetStubsVersions(version string) {
library.MutatedProperties.StubsVersion = version
return
}
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
llndk.libraryDecorator.MutatedProperties.StubsVersion = version
return
}
}
panic(fmt.Errorf("SetStubsVersions called on non-library module: %q", c.BaseModuleName()))
}
@@ -650,6 +658,9 @@ func (c *Module) StubsVersion() string {
if library, ok := c.linker.(*libraryDecorator); ok {
return library.MutatedProperties.StubsVersion
}
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
return llndk.libraryDecorator.MutatedProperties.StubsVersion
}
}
panic(fmt.Errorf("StubsVersion called on non-library module: %q", c.BaseModuleName()))
}
@@ -1851,7 +1862,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
var variations []blueprint.Variation
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
versionVariantAvail := !ctx.useVndk() && !c.InRecovery() && !c.InRamdisk()
versionVariantAvail := !c.InRecovery() && !c.InRamdisk()
if version != "" && versionVariantAvail {
// Version is explicitly specified. i.e. libFoo#30
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
@@ -2186,13 +2197,17 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if depTag == android.ProtoPluginDepTag {
return
}
if depTag == llndkImplDep {
return
}
if dep.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
return
}
if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
ctx.ModuleErrorf("Arch mismatch between %q(%v) and %q(%v)",
ctx.ModuleName(), ctx.Arch().ArchType, depName, dep.Target().Arch.ArchType)
return
}
@@ -2287,6 +2302,27 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return // stop processing this dep
}
}
if c.UseVndk() {
if m, ok := ccDep.(*Module); ok && m.IsStubs() { // LLNDK
// by default, use current version of LLNDK
versionToUse := ""
versions := stubsVersionsFor(ctx.Config())[depName]
if c.ApexName() != "" && len(versions) > 0 {
// if this is for use_vendor apex && dep has stubsVersions
// apply the same rule of apex sdk enforcement to choose right version
var err error
useLatest := c.ShouldSupportAndroid10() && !ctx.Config().UnbundledBuild()
versionToUse, err = c.ChooseSdkVersion(versions, useLatest)
if err != nil {
ctx.OtherModuleErrorf(dep, err.Error())
return
}
}
if versionToUse != ccDep.StubsVersion() {
return
}
}
}
depPaths.IncludeDirs = append(depPaths.IncludeDirs, ccDep.IncludeDirs()...)