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
diff --git a/cc/cc.go b/cc/cc.go
index 0279928..ad6468d 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -839,6 +839,7 @@
reexportFlags bool
explicitlyVersioned bool
+ explicitlyImpl bool
dataLib bool
ndk bool
@@ -934,6 +935,11 @@
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 @@
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) 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
}