Merge changes I177441bc,I32daefbd into main
* changes: Use BaseModuleName for LOCAL_MODULE Disable source javalib dexpreopt when using prebuilt apex
This commit is contained in:
@@ -693,6 +693,7 @@ func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
||||||
Class: "APPS",
|
Class: "APPS",
|
||||||
OutputFile: android.OptionalPathForPath(a.outputFile),
|
OutputFile: android.OptionalPathForPath(a.outputFile),
|
||||||
|
OverrideName: a.BaseModuleName(), // TODO (spandandas): Add a test
|
||||||
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
|
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
|
||||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||||
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
||||||
|
@@ -187,6 +187,33 @@ func forPrebuiltApex(ctx android.BaseModuleContext) bool {
|
|||||||
return apexInfo.ForPrebuiltApex
|
return apexInfo.ForPrebuiltApex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For apex variant of modules, this returns true on the source variant if the prebuilt apex
|
||||||
|
// has been selected using apex_contributions.
|
||||||
|
// The prebuilt apex will be responsible for generating the dexpreopt rules of the deapexed java lib.
|
||||||
|
func disableSourceApexVariant(ctx android.BaseModuleContext) bool {
|
||||||
|
if !isApexVariant(ctx) {
|
||||||
|
return false // platform variant
|
||||||
|
}
|
||||||
|
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||||
|
psi := android.PrebuiltSelectionInfoMap{}
|
||||||
|
ctx.VisitDirectDepsWithTag(android.PrebuiltDepTag, func(am android.Module) {
|
||||||
|
psi, _ = android.OtherModuleProvider(ctx, am, android.PrebuiltSelectionInfoProvider)
|
||||||
|
})
|
||||||
|
// Find the apex variant for this module
|
||||||
|
_, apexVariantsWithoutTestApexes, _ := android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes)
|
||||||
|
disableSource := false
|
||||||
|
// find the selected apexes
|
||||||
|
for _, apexVariant := range apexVariantsWithoutTestApexes {
|
||||||
|
for _, selected := range psi.GetSelectedModulesForApiDomain(apexVariant) {
|
||||||
|
// If the apex_contribution for this api domain contains a prebuilt apex, disable the source variant
|
||||||
|
if strings.HasPrefix(selected, "prebuilt_com.google.android") {
|
||||||
|
disableSource = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return disableSource
|
||||||
|
}
|
||||||
|
|
||||||
// Returns whether dexpreopt is applicable to the module.
|
// Returns whether dexpreopt is applicable to the module.
|
||||||
// When it returns true, neither profile nor dexpreopt artifacts will be generated.
|
// When it returns true, neither profile nor dexpreopt artifacts will be generated.
|
||||||
func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext, libName string) bool {
|
func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext, libName string) bool {
|
||||||
@@ -216,6 +243,10 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext, libName s
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if disableSourceApexVariant(ctx) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if _, isApex := android.ModuleProvider(ctx, android.ApexBundleInfoProvider); isApex {
|
if _, isApex := android.ModuleProvider(ctx, android.ApexBundleInfoProvider); isApex {
|
||||||
// dexpreopt rules for system server jars can be generated in the ModuleCtx of prebuilt apexes
|
// dexpreopt rules for system server jars can be generated in the ModuleCtx of prebuilt apexes
|
||||||
return false
|
return false
|
||||||
|
Reference in New Issue
Block a user