Build native coverage variant of APEXes when needed

When the native coverage is enabled, APEXes (and files there) are built
for native coverage as well.

Bug: 138952487
Test: make -j NATIVE_COVERAGE=true COVERAGE_PATHS='*' com.android.resolv
find out -name "*.gcno" | grep DnsResolver shows files

Test: libnetd_resolv.zip is found under
$(TARGET_OUT)/apex/com.android.resolv/lib directory

Change-Id: I97bcee9bf8ffc0dc71453abbdb613ed56ea2cdb4
This commit is contained in:
Jiyong Park
2019-08-09 14:44:36 +09:00
parent 02ed5df4ac
commit ee9a98d88e
6 changed files with 62 additions and 2 deletions

View File

@@ -293,6 +293,10 @@ type apexBundleProperties struct {
// List of sanitizer names that this APEX is enabled for
SanitizerNames []string `blueprint:"mutated"`
PreventInstall bool `blueprint:"mutated"`
HideFromMake bool `blueprint:"mutated"`
// Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
Provide_cpp_shared_libs *bool
@@ -631,7 +635,7 @@ func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
}
func (a *apexBundle) installable() bool {
return a.properties.Installable == nil || proptools.Bool(a.properties.Installable)
return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
}
func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
@@ -666,6 +670,18 @@ func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizer
return android.InList(sanitizerName, globalSanitizerNames)
}
func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
}
func (a *apexBundle) PreventInstall() {
a.properties.PreventInstall = true
}
func (a *apexBundle) HideFromMake() {
a.properties.HideFromMake = true
}
func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
// Decide the APEX-local directory by the multilib of the library
// In the future, we may query this to the module.
@@ -1257,6 +1273,11 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
}
func (a *apexBundle) AndroidMk() android.AndroidMkData {
if a.properties.HideFromMake {
return android.AndroidMkData{
Disabled: true,
}
}
writers := []android.AndroidMkData{}
if a.apexTypes.image() {
writers = append(writers, a.androidMkForType(imageApex))
@@ -1351,6 +1372,9 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String())
}
cc.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
if cc.CoverageOutputFile().Valid() {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", cc.CoverageOutputFile().String())
}
}
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
} else {