Merge "Propagate DirectlyInAnyApex to transitive dependencies" into main
This commit is contained in:
@@ -350,7 +350,8 @@ type SkipApexAllowedDependenciesCheck interface {
|
|||||||
// ApexModuleBase provides the default implementation for the ApexModule interface. APEX-aware
|
// ApexModuleBase provides the default implementation for the ApexModule interface. APEX-aware
|
||||||
// modules are expected to include this struct and call InitApexModule().
|
// modules are expected to include this struct and call InitApexModule().
|
||||||
type ApexModuleBase struct {
|
type ApexModuleBase struct {
|
||||||
ApexProperties ApexProperties
|
ApexProperties ApexProperties
|
||||||
|
apexPropertiesLock sync.Mutex // protects ApexProperties during parallel apexDirectlyInAnyMutator
|
||||||
|
|
||||||
canHaveApexVariants bool
|
canHaveApexVariants bool
|
||||||
|
|
||||||
@@ -761,18 +762,22 @@ func UpdateUniqueApexVariationsForDeps(mctx BottomUpMutatorContext, am ApexModul
|
|||||||
|
|
||||||
// UpdateDirectlyInAnyApex uses the final module to store if any variant of this module is directly
|
// UpdateDirectlyInAnyApex uses the final module to store if any variant of this module is directly
|
||||||
// in any APEX, and then copies the final value to all the modules. It also copies the
|
// in any APEX, and then copies the final value to all the modules. It also copies the
|
||||||
// DirectlyInAnyApex value to any direct dependencies with a CopyDirectlyInAnyApexTag dependency
|
// DirectlyInAnyApex value to any transitive dependencies with a CopyDirectlyInAnyApexTag
|
||||||
// tag.
|
// dependency tag.
|
||||||
func UpdateDirectlyInAnyApex(mctx BottomUpMutatorContext, am ApexModule) {
|
func UpdateDirectlyInAnyApex(mctx BottomUpMutatorContext, am ApexModule) {
|
||||||
base := am.apexModuleBase()
|
base := am.apexModuleBase()
|
||||||
// Copy DirectlyInAnyApex and InAnyApex from any direct dependencies with a
|
// Copy DirectlyInAnyApex and InAnyApex from any transitive dependencies with a
|
||||||
// CopyDirectlyInAnyApexTag dependency tag.
|
// CopyDirectlyInAnyApexTag dependency tag.
|
||||||
mctx.VisitDirectDeps(func(dep Module) {
|
mctx.WalkDeps(func(child, parent Module) bool {
|
||||||
if _, ok := mctx.OtherModuleDependencyTag(dep).(CopyDirectlyInAnyApexTag); ok {
|
if _, ok := mctx.OtherModuleDependencyTag(child).(CopyDirectlyInAnyApexTag); ok {
|
||||||
depBase := dep.(ApexModule).apexModuleBase()
|
depBase := child.(ApexModule).apexModuleBase()
|
||||||
|
depBase.apexPropertiesLock.Lock()
|
||||||
|
defer depBase.apexPropertiesLock.Unlock()
|
||||||
depBase.ApexProperties.DirectlyInAnyApex = base.ApexProperties.DirectlyInAnyApex
|
depBase.ApexProperties.DirectlyInAnyApex = base.ApexProperties.DirectlyInAnyApex
|
||||||
depBase.ApexProperties.InAnyApex = base.ApexProperties.InAnyApex
|
depBase.ApexProperties.InAnyApex = base.ApexProperties.InAnyApex
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
if base.ApexProperties.DirectlyInAnyApex {
|
if base.ApexProperties.DirectlyInAnyApex {
|
||||||
|
@@ -716,11 +716,7 @@ func (j *Module) shouldInstrumentInApex(ctx android.BaseModuleContext) bool {
|
|||||||
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||||
isJacocoAgent := ctx.ModuleName() == "jacocoagent"
|
isJacocoAgent := ctx.ModuleName() == "jacocoagent"
|
||||||
|
|
||||||
isApexVariantSdkLibImplLib := j.SdkLibraryName() != nil &&
|
if j.DirectlyInAnyApex() && !isJacocoAgent && !apexInfo.IsForPlatform() {
|
||||||
strings.HasSuffix(j.Name(), ".impl") &&
|
|
||||||
len(apexInfo.InApexVariants) > 0
|
|
||||||
|
|
||||||
if (j.DirectlyInAnyApex() || isApexVariantSdkLibImplLib) && !isJacocoAgent && !apexInfo.IsForPlatform() {
|
|
||||||
if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
|
if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
|
||||||
return true
|
return true
|
||||||
} else if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
} else if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
||||||
|
@@ -1506,6 +1506,12 @@ var implLibraryTag = sdkLibraryComponentTag{name: "impl-library"}
|
|||||||
|
|
||||||
var _ android.InstallNeededDependencyTag = sdkLibraryComponentTag{}
|
var _ android.InstallNeededDependencyTag = sdkLibraryComponentTag{}
|
||||||
|
|
||||||
|
// To satisfy the CopyDirectlyInAnyApexTag interface. Implementation library of the sdk library
|
||||||
|
// in an apex is considered to be directly in the apex, as if it was listed in java_libs.
|
||||||
|
func (t sdkLibraryComponentTag) CopyDirectlyInAnyApex() {}
|
||||||
|
|
||||||
|
var _ android.CopyDirectlyInAnyApexTag = implLibraryTag
|
||||||
|
|
||||||
func (t sdkLibraryComponentTag) InstallDepNeeded() bool {
|
func (t sdkLibraryComponentTag) InstallDepNeeded() bool {
|
||||||
return t.name == "xml-permissions-file" || t.name == "impl-library"
|
return t.name == "xml-permissions-file" || t.name == "impl-library"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user