aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc')
-rw-r--r--cc/binary.go4
-rw-r--r--cc/cc.go8
-rw-r--r--cc/coverage.go18
-rw-r--r--cc/library.go4
-rw-r--r--cc/object.go4
5 files changed, 37 insertions, 1 deletions
diff --git a/cc/binary.go b/cc/binary.go
index 1b749146..2a6ceb82 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -421,6 +421,10 @@ func (binary *binaryDecorator) nativeCoverage() bool {
return true
}
+func (binary *binaryDecorator) coverageOutputFilePath() android.OptionalPath {
+ return binary.coverageOutputFile
+}
+
// /system/bin/linker -> /apex/com.android.runtime/bin/linker
func (binary *binaryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, file android.Path) {
dir := binary.baseInstaller.installDir(ctx)
diff --git a/cc/cc.go b/cc/cc.go
index f2a51da3..49dce18f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -314,6 +314,7 @@ type linker interface {
unstrippedOutputFilePath() android.Path
nativeCoverage() bool
+ coverageOutputFilePath() android.OptionalPath
}
type installer interface {
@@ -423,6 +424,13 @@ func (c *Module) UnstrippedOutputFile() android.Path {
return nil
}
+func (c *Module) CoverageOutputFile() android.OptionalPath {
+ if c.linker != nil {
+ return c.linker.coverageOutputFilePath()
+ }
+ return android.OptionalPath{}
+}
+
func (c *Module) RelativeInstallPath() string {
if c.installer != nil {
return c.installer.relativeInstallPath()
diff --git a/cc/coverage.go b/cc/coverage.go
index 0de0c1c9..2e81a9e4 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -140,7 +140,6 @@ func (cov *coverage) begin(ctx BaseModuleContext) {
} else {
// Check if Native_coverage is set to false. This property defaults to true.
needCoverageVariant = BoolDefault(cov.Properties.Native_coverage, true)
-
if sdk_version := ctx.sdkVersion(); ctx.useSdk() && sdk_version != "current" {
// Native coverage is not supported for SDK versions < 23
if fromApi, err := strconv.Atoi(sdk_version); err == nil && fromApi < 23 {
@@ -158,6 +157,14 @@ func (cov *coverage) begin(ctx BaseModuleContext) {
cov.Properties.NeedCoverageVariant = needCoverageVariant
}
+// Coverage is an interface for non-CC modules to implement to be mutated for coverage
+type Coverage interface {
+ android.Module
+ IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool
+ PreventInstall()
+ HideFromMake()
+}
+
func coverageMutator(mctx android.BottomUpMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.coverage != nil {
needCoverageVariant := c.coverage.Properties.NeedCoverageVariant
@@ -177,5 +184,14 @@ func coverageMutator(mctx android.BottomUpMutatorContext) {
m[1].(*Module).coverage.Properties.CoverageEnabled = needCoverageBuild
m[1].(*Module).coverage.Properties.IsCoverageVariant = true
}
+ } else if cov, ok := mctx.Module().(Coverage); ok && cov.IsNativeCoverageNeeded(mctx) {
+ // APEX modules fall here
+
+ // Note: variant "" is also created because an APEX can be depended on by another
+ // module which are split into "" and "cov" variants. e.g. when cc_test refers
+ // to an APEX via 'data' property.
+ m := mctx.CreateVariations("", "cov")
+ m[0].(Coverage).PreventInstall()
+ m[0].(Coverage).HideFromMake()
}
}
diff --git a/cc/library.go b/cc/library.go
index 71d8170e..39f7a724 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -758,6 +758,10 @@ func (library *libraryDecorator) nativeCoverage() bool {
return true
}
+func (library *libraryDecorator) coverageOutputFilePath() android.OptionalPath {
+ return library.coverageOutputFile
+}
+
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
isLlndk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs)
diff --git a/cc/object.go b/cc/object.go
index 50ecc38e..2fefd301 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -118,3 +118,7 @@ func (object *objectLinker) unstrippedOutputFilePath() android.Path {
func (object *objectLinker) nativeCoverage() bool {
return true
}
+
+func (object *objectLinker) coverageOutputFilePath() android.OptionalPath {
+ return android.OptionalPath{}
+}