aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-02-09 16:16:31 -0800
committerDan Willemsen <dwillemsen@google.com>2017-02-14 13:05:48 -0800
commit581341d4f2752a1f2823173167d30ddb30db5932 (patch)
treec8a4413cdc0a81ca2d934442d71b55a6e5abfec9 /android
parente13374d3c1e33176ac229317505c5e2b4d8d5240 (diff)
downloadbuild_soong-581341d4f2752a1f2823173167d30ddb30db5932.tar.gz
build_soong-581341d4f2752a1f2823173167d30ddb30db5932.tar.bz2
build_soong-581341d4f2752a1f2823173167d30ddb30db5932.zip
Native Coverage support in Soong (gcov)
This is configured the same as make -- a global NATIVE_COVERAGE=true flag to allow native coverage, then COVERAGE_PATHS=path1,path2,... to turn it on for certain paths. There are .gcnodir files exported to Make and saved in $OUT/coverage/... files which are `ar` archives containing all of the compiler-produced .gcno files for a particular executable / shared library. Unlike the Make implementation, this only passes links the helper library (automatically through --coverage) when one of the object files or static libraries being used actually has coverage enabled. Host support is currently disabled, since we set -nodefaultlibs, which prevents libclang_rt.profile-*.a from being picked up automatically. Bug: 32749731 Test: NATIVE_COVERAGE=true COVERAGE_PATHS=system/core/libcutils m -j libbacktrace libutils tombstoned $OUT/coverage/system/lib*/libcutils.gcnodir looks correct (self) $OUT/coverage/system/lib*/libbacktrace.gcnodir looks correct (static) $OUT/coverage/system/lib*/libutils.gcnodir doesn't exist (shared) $OUT/coverage/system/bin/tombstoned.gcnodir looks correct (executable) Test: NATIVE_COVERAGE=true COVERAGE_PATHS=external/libcxxabi m -j libc++ Confirm that $OUT/coverage/system/lib*/libc++.gcnodir looks correct (whole_static_libs) Change-Id: I48aaa0ba8d76e50e9c2d1151421c0c6dc8ed79a9
Diffstat (limited to 'android')
-rw-r--r--android/config.go15
-rw-r--r--android/variable.go3
2 files changed, 18 insertions, 0 deletions
diff --git a/android/config.go b/android/config.go
index eaacef71..b4b0be87 100644
--- a/android/config.go
+++ b/android/config.go
@@ -471,3 +471,18 @@ func (c *deviceConfig) VndkVersion() string {
func (c *deviceConfig) BtConfigIncludeDir() string {
return String(c.config.ProductVariables.BtConfigIncludeDir)
}
+
+func (c *deviceConfig) NativeCoverageEnabled() bool {
+ return Bool(c.config.ProductVariables.NativeCoverage)
+}
+
+func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
+ if c.config.ProductVariables.CoveragePaths != nil {
+ for _, prefix := range *c.config.ProductVariables.CoveragePaths {
+ if strings.HasPrefix(path, prefix) {
+ return true
+ }
+ }
+ }
+ return false
+}
diff --git a/android/variable.go b/android/variable.go
index 24c58dff..29f7c318 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -131,6 +131,9 @@ type productVariables struct {
ClangTidy *bool `json:",omitempty"`
TidyChecks *string `json:",omitempty"`
+ NativeCoverage *bool `json:",omitempty"`
+ CoveragePaths *[]string `json:",omitempty"`
+
DevicePrefer32BitExecutables *bool `json:",omitempty"`
HostPrefer32BitExecutables *bool `json:",omitempty"`