summaryrefslogtreecommitdiff
path: root/rust/binary.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-04-09 09:56:02 -0400
committer Ivan Lozano <ivanlozano@google.com> 2020-05-05 10:30:15 -0400
commita0cd8f9acb8c5c04c1082cc980cc8cca28aff5a9 (patch)
treef69f7651add1ce0e4089711fa207b4741815c589 /rust/binary.go
parentb8bb5d05ce523b0dc88085313f6514910954db41 (diff)
Add gcov coverage support to Rust modules.
This adds gcov coverage support for Rust device library and binary modules (including test modules). Support is provided to pass Rust static library gcno files to CC modules and visa versa. Additional changes: * Begin mutator added for Rust modules. * SuffixInList added to android package. * CoverageEnabled added to Coverage interface. * CoverageFiles added to LinkableLibrary interface. * Fix in coverage mutator for non-CC modules which marked the wrong variant as the coverage variant. * Added coverage libraries to the cc.GatherRequiredDepsForTest. Bug: 146448203 Test: NATIVE_COVERAGE=true COVERAGE_PATHS='*' m -j <rust_module> Change-Id: If20728bdde42a1dd544a35a40f0d981b80a5835f
Diffstat (limited to 'rust/binary.go')
-rw-r--r--rust/binary.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/rust/binary.go b/rust/binary.go
index fda056e43..c25ae0969 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -35,9 +35,10 @@ type BinaryCompilerProperties struct {
type binaryDecorator struct {
*baseCompiler
- Properties BinaryCompilerProperties
- distFile android.OptionalPath
- unstrippedOutputFile android.Path
+ Properties BinaryCompilerProperties
+ distFile android.OptionalPath
+ coverageOutputZipFile android.OptionalPath
+ unstrippedOutputFile android.Path
}
var _ compiler = (*binaryDecorator)(nil)
@@ -104,6 +105,10 @@ func (binary *binaryDecorator) compilerProps() []interface{} {
&binary.Properties)
}
+func (binary *binaryDecorator) nativeCoverage() bool {
+ return true
+}
+
func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix()
@@ -114,7 +119,21 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
- TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
+ outputs := TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
+ binary.coverageFile = outputs.coverageFile
+
+ var coverageFiles android.Paths
+ if outputs.coverageFile != nil {
+ coverageFiles = append(coverageFiles, binary.coverageFile)
+ }
+ if len(deps.coverageFiles) > 0 {
+ coverageFiles = append(coverageFiles, deps.coverageFiles...)
+ }
+ binary.coverageOutputZipFile = TransformCoverageFilesToZip(ctx, coverageFiles, binary.getStem(ctx))
return outputFile
}
+
+func (binary *binaryDecorator) coverageOutputZipPath() android.OptionalPath {
+ return binary.coverageOutputZipFile
+}