Add test_for property
This change adds 'test_for' property to cc_test_* types. The property is
used to mark a module as a test for one or more APEXes, in which case
the module has accecss to the private part of the listed APEXes. For
example, the module is linked with the actrual shared library in the
APEX instead of the stub of the shared library.
Exempt-From-Owner-Approval: cherry-pick from AOSP
Bug: 129539670
Bug: 153046163
Test: m
Merged-In: I45ed0d7a15540b0d69b2a3b8d9c4cb202adff6f2
(cherry picked from commit 62304bbeeca32bb7dc557d730a233fd8b0652624)
Change-Id: I45ed0d7a15540b0d69b2a3b8d9c4cb202adff6f2
diff --git a/cc/cc.go b/cc/cc.go
index 9baeceb..a92495c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2301,6 +2301,15 @@
// always link to non-stub variant
useThisDep = !depIsStubs
}
+ for _, testFor := range c.TestFor() {
+ // Another exception: if this module is bundled with an APEX, then
+ // it is linked with the non-stub variant of a module in the APEX
+ // as if this is part of the APEX.
+ if android.DirectlyInApex(testFor, depName) {
+ useThisDep = !depIsStubs
+ break
+ }
+ }
} else {
// If building for APEX, use stubs only when it is not from
// the same APEX
@@ -2727,6 +2736,16 @@
}
}
+func (c *Module) TestFor() []string {
+ if test, ok := c.linker.(interface {
+ testFor() []string
+ }); ok {
+ return test.testFor()
+ } else {
+ return c.ApexModuleBase.TestFor()
+ }
+}
+
// Return true if the module is ever installable.
func (c *Module) EverInstallable() bool {
return c.installer != nil &&