Make filesystem aware of coverage

filesystem should have coverage variants with coverage-enabled build.
Otherwise, it would fail to collect dependencies.

Bug: 273238141
Test: m nothing (soong tests)
Test: compare the artifacts
 $ SKIP_ABI_CHECKS=true SOONG_COLLECT_JAVA_DEPS=true EMMA_INSTRUMENT=true\
   EMMA_INSTRUMENT_FRAMEWORK=true CLANG_COVERAGE=true\
   NATIVE_COVERAGE_PATHS='*' m microdroid
 $ m microdroid
Change-Id: I792458ace00a63b4b5213898fd3209351a6e00be
This commit is contained in:
Jooyung Han
2023-03-16 13:11:17 +09:00
parent 58fa5a3f36
commit e606759ddf
3 changed files with 77 additions and 2 deletions

View File

@@ -219,10 +219,14 @@ func SetCoverageProperties(ctx android.BaseModuleContext, properties CoveragePro
return properties
}
// Coverage is an interface for non-CC modules to implement to be mutated for coverage
type Coverage interface {
type UseCoverage interface {
android.Module
IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool
}
// Coverage is an interface for non-CC modules to implement to be mutated for coverage
type Coverage interface {
UseCoverage
SetPreventInstall()
HideFromMake()
MarkAsCoverageVariant(bool)
@@ -261,6 +265,11 @@ func coverageMutator(mctx android.BottomUpMutatorContext) {
m[1].(Coverage).MarkAsCoverageVariant(true)
m[1].(Coverage).EnableCoverageIfNeeded()
} else if cov, ok := mctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(mctx) {
// Module itself doesn't have to have "cov" variant, but it should use "cov" variants of
// deps.
mctx.CreateVariations("cov")
mctx.AliasVariation("cov")
}
}