Merge "Add version suffix for stub modules' Android.mk" am: 7423398025
Change-Id: I2d800d9f86b7d3f76ffad4f2ead4b8a4d48565f0
This commit is contained in:
@@ -244,6 +244,9 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
|
|||||||
if library.shared() && !library.buildStubs() {
|
if library.shared() && !library.buildStubs() {
|
||||||
ctx.subAndroidMk(entries, library.baseInstaller)
|
ctx.subAndroidMk(entries, library.baseInstaller)
|
||||||
} else {
|
} else {
|
||||||
|
if library.buildStubs() {
|
||||||
|
entries.SubName = "." + library.stubsVersion()
|
||||||
|
}
|
||||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||||
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
|
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
|
||||||
if library.buildStubs() {
|
if library.buildStubs() {
|
||||||
@@ -254,6 +257,10 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
|
|||||||
if len(library.Properties.Stubs.Versions) > 0 &&
|
if len(library.Properties.Stubs.Versions) > 0 &&
|
||||||
android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
|
android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
|
||||||
!ctx.static() {
|
!ctx.static() {
|
||||||
|
if library.buildStubs() && library.isLatestStubVersion() {
|
||||||
|
// reference the latest version via its name without suffix when it is provided by apex
|
||||||
|
entries.SubName = ""
|
||||||
|
}
|
||||||
if !library.buildStubs() {
|
if !library.buildStubs() {
|
||||||
entries.SubName = ".bootstrap"
|
entries.SubName = ".bootstrap"
|
||||||
}
|
}
|
||||||
|
@@ -1273,6 +1273,11 @@ func (library *libraryDecorator) stubsVersion() string {
|
|||||||
return library.MutatedProperties.StubsVersion
|
return library.MutatedProperties.StubsVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) isLatestStubVersion() bool {
|
||||||
|
versions := library.Properties.Stubs.Versions
|
||||||
|
return versions[len(versions)-1] == library.stubsVersion()
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) availableFor(what string) bool {
|
func (library *libraryDecorator) availableFor(what string) bool {
|
||||||
var list []string
|
var list []string
|
||||||
if library.static() {
|
if library.static() {
|
||||||
@@ -1444,30 +1449,35 @@ func LatestStubsVersionFor(config android.Config, name string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkVersions(ctx android.BaseModuleContext, versions []string) {
|
||||||
|
numVersions := make([]int, len(versions))
|
||||||
|
for i, v := range versions {
|
||||||
|
numVer, err := strconv.Atoi(v)
|
||||||
|
if err != nil {
|
||||||
|
ctx.PropertyErrorf("versions", "%q is not a number", v)
|
||||||
|
}
|
||||||
|
numVersions[i] = numVer
|
||||||
|
}
|
||||||
|
if !sort.IsSorted(sort.IntSlice(numVersions)) {
|
||||||
|
ctx.PropertyErrorf("versions", "not sorted: %v", versions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Version mutator splits a module into the mandatory non-stubs variant
|
// Version mutator 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 && !library.InRecovery() {
|
if library, ok := mctx.Module().(LinkableInterface); ok && !library.InRecovery() {
|
||||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
|
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
|
||||||
versions := []string{}
|
versions := library.StubsVersions()
|
||||||
for _, v := range library.StubsVersions() {
|
checkVersions(mctx, versions)
|
||||||
if _, err := strconv.Atoi(v); err != nil {
|
if mctx.Failed() {
|
||||||
mctx.PropertyErrorf("versions", "%q is not a number", v)
|
return
|
||||||
}
|
}
|
||||||
versions = append(versions, v)
|
|
||||||
}
|
|
||||||
sort.Slice(versions, func(i, j int) bool {
|
|
||||||
left, _ := strconv.Atoi(versions[i])
|
|
||||||
right, _ := strconv.Atoi(versions[j])
|
|
||||||
return left < right
|
|
||||||
})
|
|
||||||
|
|
||||||
// save the list of versions for later use
|
// save the list of versions for later use
|
||||||
copiedVersions := make([]string, len(versions))
|
|
||||||
copy(copiedVersions, versions)
|
|
||||||
stubsVersionsLock.Lock()
|
stubsVersionsLock.Lock()
|
||||||
defer stubsVersionsLock.Unlock()
|
defer stubsVersionsLock.Unlock()
|
||||||
stubsVersionsFor(mctx.Config())[mctx.ModuleName()] = copiedVersions
|
stubsVersionsFor(mctx.Config())[mctx.ModuleName()] = versions
|
||||||
|
|
||||||
// "" is for the non-stubs variant
|
// "" is for the non-stubs variant
|
||||||
versions = append([]string{""}, versions...)
|
versions = append([]string{""}, versions...)
|
||||||
|
Reference in New Issue
Block a user