hostdex:true modules are available for platform
Java libraries with hostdex: true are available for the platform even if it doesn't have "//apex_available:platform" in the apex_available property. Note that the java libraries are still prevented from being installed to the device. Bug: 128708192 Test: m Change-Id: I6463ebc59cf7fd861b812999d7a79c387bbb3335
This commit is contained in:
@@ -138,7 +138,7 @@ func (m *ApexModuleBase) IsInstallableToApex() bool {
|
||||
}
|
||||
|
||||
const (
|
||||
availableToPlatform = "//apex_available:platform"
|
||||
AvailableToPlatform = "//apex_available:platform"
|
||||
availableToAnyApex = "//apex_available:anyapex"
|
||||
)
|
||||
|
||||
@@ -149,7 +149,7 @@ func CheckAvailableForApex(what string, apex_available []string) bool {
|
||||
return true
|
||||
}
|
||||
return InList(what, apex_available) ||
|
||||
(what != availableToPlatform && InList(availableToAnyApex, apex_available))
|
||||
(what != AvailableToPlatform && InList(availableToAnyApex, apex_available))
|
||||
}
|
||||
|
||||
func (m *ApexModuleBase) AvailableFor(what string) bool {
|
||||
@@ -165,7 +165,7 @@ func (m *ApexModuleBase) DepIsInSameApex(ctx BaseModuleContext, dep Module) bool
|
||||
|
||||
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
|
||||
for _, n := range m.ApexProperties.Apex_available {
|
||||
if n == availableToPlatform || n == availableToAnyApex {
|
||||
if n == AvailableToPlatform || n == availableToAnyApex {
|
||||
continue
|
||||
}
|
||||
if !mctx.OtherModuleExists(n) && !mctx.Config().AllowMissingDependencies() {
|
||||
@@ -179,7 +179,7 @@ func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Mod
|
||||
m.checkApexAvailableProperty(mctx)
|
||||
sort.Strings(m.apexVariations)
|
||||
variations := []string{}
|
||||
availableForPlatform := mctx.Module().(ApexModule).AvailableFor(availableToPlatform) || mctx.Host()
|
||||
availableForPlatform := mctx.Module().(ApexModule).AvailableFor(AvailableToPlatform) || mctx.Host()
|
||||
if availableForPlatform {
|
||||
variations = append(variations, "") // Original variation for platform
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import (
|
||||
func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
|
||||
hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
|
||||
if !library.IsForPlatform() {
|
||||
// If the platform variant is available, don't emit hostdex modules from the APEX variants
|
||||
// Don't emit hostdex modules from the APEX variants
|
||||
hostDexNeeded = false
|
||||
}
|
||||
|
||||
@@ -62,8 +62,14 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
var entriesList []android.AndroidMkEntries
|
||||
|
||||
mainEntries := android.AndroidMkEntries{Disabled: true}
|
||||
|
||||
// For a java library built for an APEX, we don't need Make module
|
||||
if library.IsForPlatform() {
|
||||
hideFromMake := !library.IsForPlatform()
|
||||
// If not available for platform, don't emit to make.
|
||||
if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
|
||||
hideFromMake = true
|
||||
}
|
||||
if !hideFromMake {
|
||||
mainEntries = android.AndroidMkEntries{
|
||||
Class: "JAVA_LIBRARIES",
|
||||
OutputFile: android.OptionalPathForPath(library.outputFile),
|
||||
|
10
java/java.go
10
java/java.go
@@ -559,6 +559,16 @@ func (j *Module) targetSdkVersion() string {
|
||||
return j.sdkVersion()
|
||||
}
|
||||
|
||||
func (j *Module) AvailableFor(what string) bool {
|
||||
if what == android.AvailableToPlatform && Bool(j.deviceProperties.Hostdex) {
|
||||
// Exception: for hostdex: true libraries, the platform variant is created
|
||||
// even if it's not marked as available to platform. In that case, the platform
|
||||
// variant is used only for the hostdex and not installed to the device.
|
||||
return true
|
||||
}
|
||||
return j.ApexModuleBase.AvailableFor(what)
|
||||
}
|
||||
|
||||
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
if ctx.Device() {
|
||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||
|
Reference in New Issue
Block a user