Add option for generating coverage info.

To enable building with coverage, the environment variable
NATIVE_COVERAGE must be set to true.

Set `LOCAL_NATIVE_COVERAGE := true` to generate coverage information for
a given component.

This is currently not supported for clang (b/17574078, b/17583330).

If static library A is included in a binary B (dynamic or static
executable, or shared library), and A is built with coverage
information, B is required to link with libgcov.a. Since the make does
not offer a good way to track this dependency, link libgcov.a even if
LOCAL_NATIVE_COVERAGE is not set (but still guarded by NATIVE_COVERAGE).
This ensures that all of the libgcov dependencies will always be
resolved, and causes no change in the resulting binary if coverage is
not used.

Bug: 10134489
Change-Id: Id5a19f2c215e4be80e6eae27ecc19b582f2f6813
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 61a0927..23ff97d 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -158,6 +158,7 @@
 LOCAL_MODULE_HOST_ARCH:=
 LOCAL_NO_FPIE :=
 LOCAL_CXX_STL := default
+LOCAL_NATIVE_COVERAGE :=
 
 # arch specific variables
 LOCAL_SRC_FILES_$(TARGET_ARCH):=