Extend coverage mutator to allow variants with coverage on and off
Bug: http://b/116873221
This allows us to enable coverage for a module (typically static
libraries) even if a dependent module cannot build with coverage. In
this case, the dependent module can just pick the variant with coverage
off.
- Create the following variants from the coverage mutator:
- "" (empty): Don't build with coverage and always pick the
non-coverage variants for dependents. This variant is
created for modules with 'native_coverage: false'.
- "cov": If this module's path is covered by the COVERAGE_PATHS
option, build this module with coverage. If not, build
this module without coverage. In either case, pick
coverage variants ("cov") for dependencies if available.
- Do not enable coverage:
- for NDK stub libraries
- if sdk_version < 23 since libc doesn't export 'stderr' which is
needed by the coverage/profile runtime library.
- for VNDK libraries
Test: In AOSP: m COVERAGE_PATHS=system/security NATIVE_COVERAGE=true nothing
Change-Id: I4d08790d35cdeaf12fb3c4f999d69a870e65836a
diff --git a/cc/cc.go b/cc/cc.go
index 081da12..7b19e98 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -63,7 +63,7 @@
ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator)
ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
- ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
+ ctx.BottomUp("coverage", coverageMutator).Parallel()
ctx.TopDown("vndk_deps", sabiDepsMutator)
ctx.TopDown("lto_deps", ltoDepsMutator)
@@ -258,6 +258,7 @@
baseModuleName() string
getVndkExtendsModuleName() string
isPgoCompile() bool
+ isNDKStubLibrary() bool
useClangLld(actx ModuleContext) bool
apexName() string
hasStubsVariants() bool
@@ -497,6 +498,10 @@
return c.Properties.UseVndk
}
+func (c *Module) isCoverageVariant() bool {
+ return c.coverage.Properties.IsCoverageVariant
+}
+
func (c *Module) isNdk() bool {
return inList(c.Name(), ndkMigratedLibs)
}
@@ -530,6 +535,13 @@
return false
}
+func (c *Module) isNDKStubLibrary() bool {
+ if _, ok := c.compiler.(*stubDecorator); ok {
+ return true
+ }
+ return false
+}
+
func (c *Module) isVndkSp() bool {
if vndkdep := c.vndkdep; vndkdep != nil {
return vndkdep.isVndkSp()
@@ -675,6 +687,10 @@
return ctx.mod.isPgoCompile()
}
+func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
+ return ctx.mod.isNDKStubLibrary()
+}
+
func (ctx *moduleContextImpl) isVndkSp() bool {
return ctx.mod.isVndkSp()
}
@@ -956,7 +972,8 @@
// module is marked with 'bootstrap: true').
if c.HasStubsVariants() &&
android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) &&
- !c.inRecovery() && !c.useVndk() && !c.static() && c.IsStubs() {
+ !c.inRecovery() && !c.useVndk() && !c.static() && !c.isCoverageVariant() &&
+ c.IsStubs() {
c.Properties.HideFromMake = false // unhide
// Note: this is still non-installable
}