From 323a4c3ab34a6af4db7d0d99d22d64284b1570dc Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Sun, 1 Mar 2020 17:29:06 +0900 Subject: [PATCH] Runtime deps to a stubs lib crosses APEX boundary When there is a runtime depedency (via runtime_libs property) to a library providing stable C APIs, the dependency is considered as crossing APEX boundary. Therefore, the requested lib doesn't need to be made available to the APEX where the requesting lib is in. Bug: 147813447 Test: m Change-Id: I9cf8a5877850fb85b92c851e15fac921b8b7641b --- apex/apex_test.go | 11 ++++++++++- cc/cc.go | 12 +++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index bd53b1546..6d9ad2686 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -810,7 +810,6 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) { stubs: { versions: ["10", "20", "30"], }, - apex_available: [ "myapex" ], } cc_library { @@ -3175,6 +3174,7 @@ func TestApexAvailable(t *testing.T) { name: "libfoo", stl: "none", system_shared_libs: [], + runtime_libs: ["libbaz"], apex_available: ["myapex"], } @@ -3183,6 +3183,15 @@ func TestApexAvailable(t *testing.T) { stl: "none", system_shared_libs: [], apex_available: ["//apex_available:anyapex"], + } + + cc_library { + name: "libbaz", + stl: "none", + system_shared_libs: [], + stubs: { + versions: ["10", "20", "30"], + }, }`) // check that libfoo and libbar are created only for myapex, but not for the platform diff --git a/cc/cc.go b/cc/cc.go index 5af8459a2..76f1f9604 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -2631,9 +2631,15 @@ func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Write func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok { if cc, ok := dep.(*Module); ok { - if cc.HasStubsVariants() && depTag.Shared && depTag.Library { - // dynamic dep to a stubs lib crosses APEX boundary - return false + if cc.HasStubsVariants() { + if depTag.Shared && depTag.Library { + // dynamic dep to a stubs lib crosses APEX boundary + return false + } + if IsRuntimeDepTag(depTag) { + // runtime dep to a stubs lib also crosses APEX boundary + return false + } } if depTag.FromStatic { // shared_lib dependency from a static lib is considered as crossing