From bd930bc6c4ff8539da60d6cda69f484a817a31ed Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 3 Feb 2025 12:17:42 -0800 Subject: Add explicitlyImpl to shared library dependency tags Instead of testing that explicit implementation libraries are not incorrectly used in an apex after the fact add the explicitlyImpl flag to dependency tags and use it in cc.DepIsInSameApex and rust.DepIsInSameApex to require that explicit implementation dependencies are in the same apex. Bug: 372543712 Test: go test ./... Change-Id: Ia968e06b578d5ab886a965c3981565d4895dddcd --- cc/cc.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cc/cc.go') diff --git a/cc/cc.go b/cc/cc.go index 027992868..ad6468d6c 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -839,6 +839,7 @@ type libraryDependencyTag struct { reexportFlags bool explicitlyVersioned bool + explicitlyImpl bool dataLib bool ndk bool @@ -934,6 +935,11 @@ var ( llndkHeaderLibTag = dependencyTag{name: "llndk_header_lib"} ) +func IsExplicitImplSharedDepTag(depTag blueprint.DependencyTag) bool { + ccLibDepTag, ok := depTag.(libraryDependencyTag) + return ok && ccLibDepTag.shared() && ccLibDepTag.explicitlyImpl +} + func IsSharedDepTag(depTag blueprint.DependencyTag) bool { ccLibDepTag, ok := depTag.(libraryDependencyTag) return ok && ccLibDepTag.shared() @@ -2699,6 +2705,9 @@ func AddSharedLibDependenciesWithVersions(ctx android.BottomUpMutatorContext, mo variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version}) if tag, ok := depTag.(libraryDependencyTag); ok { tag.explicitlyVersioned = true + if version == "" { + tag.explicitlyImpl = true + } // depTag is an interface that contains a concrete non-pointer struct. That makes the local // tag variable a copy of the contents of depTag, and updating it doesn't change depTag. Reassign // the modified copy to depTag. @@ -4074,7 +4083,7 @@ func (c *Module) OutgoingDepIsInSameApex(depTag blueprint.DependencyTag) bool { func (c *Module) IncomingDepIsInSameApex(depTag blueprint.DependencyTag) bool { if c.HasStubsVariants() { - if IsSharedDepTag(depTag) { + if IsSharedDepTag(depTag) && !IsExplicitImplSharedDepTag(depTag) { // dynamic dep to a stubs lib crosses APEX boundary return false } -- cgit v1.2.3-59-g8ed1b