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
11 files changed