From f7bbd2fe40e43f7fda7e08d08eeb9c2a93552ad9 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 5 Dec 2024 13:57:10 -0800 Subject: Split DepIsInSameApex into outgoing and incoming Prepare for calling DepIsInSameApex from the apex transition mutator by splitting all the implementations in two, one that is called on the outgoing module and only takes the depTag, and one that is called on the incoming module and only takes the depTag. apexBundle.depVisitor was passing the child into android.IsDepInSameApex for both the parent and child paramters. The parent field was only used to find the type on which to call DepIsInSameApex, so this effectively used the child's implementation of DepIsInSameApex. That used to be necessary when the parent and child were of different module types, as the parent module type may not have been aware of the rules for the child module type, but is no longer necessary with split outgoing and incoming DepIsInSameApex. Bug: 372543712 Test: all soong tests pass Change-Id: If7c81ec3f7b1ea69d77e9ad7694e238820194e59 --- java/aar.go | 4 ++-- java/app.go | 11 +++++++---- java/app_import.go | 2 +- java/base.go | 12 ++++++------ java/bootclasspath_fragment.go | 8 +++----- java/java.go | 4 ++-- java/sdk_library.go | 12 +++++------- 7 files changed, 26 insertions(+), 27 deletions(-) (limited to 'java') diff --git a/java/aar.go b/java/aar.go index b66876663..d9a8c0e36 100644 --- a/java/aar.go +++ b/java/aar.go @@ -1603,8 +1603,8 @@ var _ UsesLibraryDependency = (*AARImport)(nil) var _ android.ApexModule = (*AARImport)(nil) // Implements android.ApexModule -func (a *AARImport) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { - return a.depIsInSameApex(ctx, dep) +func (a *AARImport) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { + return a.depIsInSameApex(tag) } // Implements android.ApexModule diff --git a/java/app.go b/java/app.go index 276e9606d..b8c85fb62 100644 --- a/java/app.go +++ b/java/app.go @@ -1209,7 +1209,10 @@ func collectJniDeps(ctx android.ModuleContext, func (a *AndroidApp) WalkPayloadDeps(ctx android.BaseModuleContext, do android.PayloadDepsCallback) { ctx.WalkDeps(func(child, parent android.Module) bool { - isExternal := !a.DepIsInSameApex(ctx, child) + // TODO(ccross): Should this use android.DepIsInSameApex? Right now it is applying the android app + // heuristics to every transitive dependency, when it should probably be using the heuristics of the + // immediate parent. + isExternal := !a.OutgoingDepIsInSameApex(ctx.OtherModuleDependencyTag(child)) if am, ok := child.(android.ApexModule); ok { if !do(ctx, parent, am, isExternal) { return false @@ -1286,11 +1289,11 @@ func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string { return a.overridableAppProperties.Certificate.GetOrDefault(ctx, "") } -func (a *AndroidApp) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { - if IsJniDepTag(ctx.OtherModuleDependencyTag(dep)) { +func (a *AndroidApp) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { + if IsJniDepTag(tag) { return true } - return a.Library.DepIsInSameApex(ctx, dep) + return a.Library.OutgoingDepIsInSameApex(tag) } func (a *AndroidApp) Privileged() bool { diff --git a/java/app_import.go b/java/app_import.go index 8951c7d9c..f593c0297 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -538,7 +538,7 @@ func (a *AndroidAppImport) Privileged() bool { return Bool(a.properties.Privileged) } -func (a *AndroidAppImport) DepIsInSameApex(_ android.BaseModuleContext, _ android.Module) bool { +func (a *AndroidAppImport) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { // android_app_import might have extra dependencies via uses_libs property. // Don't track the dependency as we don't automatically add those libraries // to the classpath. It should be explicitly added to java_libs property of APEX diff --git a/java/base.go b/java/base.go index b579a5d0f..215285fdb 100644 --- a/java/base.go +++ b/java/base.go @@ -365,13 +365,13 @@ func (e *embeddableInModuleAndImport) initModuleAndImport(module android.Module) e.initSdkLibraryComponent(module) } -// Module/Import's DepIsInSameApex(...) delegates to this method. +// Module/Import's OutgoingDepIsInSameApex(...) delegates to this method. // -// This cannot implement DepIsInSameApex(...) directly as that leads to ambiguity with +// This cannot implement OutgoingDepIsInSameApex(...) directly as that leads to ambiguity with // the one provided by ApexModuleBase. -func (e *embeddableInModuleAndImport) depIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { +func (e *embeddableInModuleAndImport) depIsInSameApex(tag blueprint.DependencyTag) bool { // dependencies other than the static linkage are all considered crossing APEX boundary - if staticLibTag == ctx.OtherModuleDependencyTag(dep) { + if tag == staticLibTag { return true } return false @@ -2214,8 +2214,8 @@ func (j *Module) hasCode(ctx android.ModuleContext) bool { } // Implements android.ApexModule -func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { - return j.depIsInSameApex(ctx, dep) +func (j *Module) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { + return j.depIsInSameApex(tag) } // Implements android.ApexModule diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 375a1aaf1..d6777e50e 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -393,11 +393,9 @@ func (i BootclasspathFragmentApexContentInfo) ProfileInstallPathInApex() string return i.profileInstallPathInApex } -func (b *BootclasspathFragmentModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { - tag := ctx.OtherModuleDependencyTag(dep) - +func (b *BootclasspathFragmentModule) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { // If the module is a default module, do not check the tag - if _, ok := dep.(*Defaults); ok { + if tag == android.DefaultsDepTag { return true } if IsBootclasspathFragmentContentDepTag(tag) { @@ -414,7 +412,7 @@ func (b *BootclasspathFragmentModule) DepIsInSameApex(ctx android.BaseModuleCont return false } - panic(fmt.Errorf("boot_image module %q should not have a dependency on %q via tag %s", b, dep, android.PrettyPrintTag(tag))) + panic(fmt.Errorf("boot_image module %q should not have a dependency tag %s", b, android.PrettyPrintTag(tag))) } func (b *BootclasspathFragmentModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { diff --git a/java/java.go b/java/java.go index ee112c1da..64bc9599c 100644 --- a/java/java.go +++ b/java/java.go @@ -2959,8 +2959,8 @@ func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap { var _ android.ApexModule = (*Import)(nil) // Implements android.ApexModule -func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { - return j.depIsInSameApex(ctx, dep) +func (j *Import) OutgoingDepIsInSameApex(tag blueprint.DependencyTag) bool { + return j.depIsInSameApex(tag) } // Implements android.ApexModule diff --git a/java/sdk_library.go b/java/sdk_library.go index 78917768b..991f84767 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1282,7 +1282,7 @@ func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) { func CheckMinSdkVersion(ctx android.ModuleContext, module *Library) { android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx), func(c android.BaseModuleContext, do android.PayloadDepsCallback) { ctx.WalkDeps(func(child android.Module, parent android.Module) bool { - isExternal := !module.depIsInSameApex(ctx, child) + isExternal := !android.IsDepInSameApex(ctx, module, child) if am, ok := child.(android.ApexModule); ok { if !do(ctx, parent, am, isExternal) { return false @@ -1636,15 +1636,14 @@ func (module *SdkLibrary) compareAgainstLatestApi(apiScope *apiScope) bool { } // Implements android.ApexModule -func (module *SdkLibrary) DepIsInSameApex(mctx android.BaseModuleContext, dep android.Module) bool { - depTag := mctx.OtherModuleDependencyTag(dep) +func (module *SdkLibrary) OutgoingDepIsInSameApex(depTag blueprint.DependencyTag) bool { if depTag == xmlPermissionsFileTag { return true } - if dep.Name() == module.implLibraryModuleName() { + if depTag == implLibraryTag { return true } - return module.Library.DepIsInSameApex(mctx, dep) + return module.Library.OutgoingDepIsInSameApex(depTag) } // Implements android.ApexModule @@ -2059,8 +2058,7 @@ func (module *SdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) var _ android.ApexModule = (*SdkLibraryImport)(nil) // Implements android.ApexModule -func (module *SdkLibraryImport) DepIsInSameApex(mctx android.BaseModuleContext, dep android.Module) bool { - depTag := mctx.OtherModuleDependencyTag(dep) +func (module *SdkLibraryImport) OutgoingDepIsInSameApex(depTag blueprint.DependencyTag) bool { if depTag == xmlPermissionsFileTag { return true } -- cgit v1.2.3-59-g8ed1b