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:
26
apex/apex.go
26
apex/apex.go
@@ -293,6 +293,10 @@ type apexBundleProperties struct {
|
|||||||
// List of sanitizer names that this APEX is enabled for
|
// List of sanitizer names that this APEX is enabled for
|
||||||
SanitizerNames []string `blueprint:"mutated"`
|
SanitizerNames []string `blueprint:"mutated"`
|
||||||
|
|
||||||
|
PreventInstall bool `blueprint:"mutated"`
|
||||||
|
|
||||||
|
HideFromMake bool `blueprint:"mutated"`
|
||||||
|
|
||||||
// Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
|
// Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
|
||||||
Provide_cpp_shared_libs *bool
|
Provide_cpp_shared_libs *bool
|
||||||
|
|
||||||
@@ -631,7 +635,7 @@ func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) installable() bool {
|
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 {
|
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)
|
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) {
|
func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
|
||||||
// Decide the APEX-local directory by the multilib of the library
|
// Decide the APEX-local directory by the multilib of the library
|
||||||
// In the future, we may query this to the module.
|
// 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 {
|
func (a *apexBundle) AndroidMk() android.AndroidMkData {
|
||||||
|
if a.properties.HideFromMake {
|
||||||
|
return android.AndroidMkData{
|
||||||
|
Disabled: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
writers := []android.AndroidMkData{}
|
writers := []android.AndroidMkData{}
|
||||||
if a.apexTypes.image() {
|
if a.apexTypes.image() {
|
||||||
writers = append(writers, a.androidMkForType(imageApex))
|
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())
|
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String())
|
||||||
}
|
}
|
||||||
cc.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
|
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")
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
|
||||||
} else {
|
} else {
|
||||||
|
@@ -425,6 +425,10 @@ func (binary *binaryDecorator) nativeCoverage() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (binary *binaryDecorator) coverageOutputFilePath() android.OptionalPath {
|
||||||
|
return binary.coverageOutputFile
|
||||||
|
}
|
||||||
|
|
||||||
// /system/bin/linker -> /apex/com.android.runtime/bin/linker
|
// /system/bin/linker -> /apex/com.android.runtime/bin/linker
|
||||||
func (binary *binaryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, file android.Path) {
|
func (binary *binaryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, file android.Path) {
|
||||||
dir := binary.baseInstaller.installDir(ctx)
|
dir := binary.baseInstaller.installDir(ctx)
|
||||||
|
8
cc/cc.go
8
cc/cc.go
@@ -327,6 +327,7 @@ type linker interface {
|
|||||||
unstrippedOutputFilePath() android.Path
|
unstrippedOutputFilePath() android.Path
|
||||||
|
|
||||||
nativeCoverage() bool
|
nativeCoverage() bool
|
||||||
|
coverageOutputFilePath() android.OptionalPath
|
||||||
}
|
}
|
||||||
|
|
||||||
type installer interface {
|
type installer interface {
|
||||||
@@ -461,6 +462,13 @@ func (c *Module) UnstrippedOutputFile() android.Path {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Module) CoverageOutputFile() android.OptionalPath {
|
||||||
|
if c.linker != nil {
|
||||||
|
return c.linker.coverageOutputFilePath()
|
||||||
|
}
|
||||||
|
return android.OptionalPath{}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Module) RelativeInstallPath() string {
|
func (c *Module) RelativeInstallPath() string {
|
||||||
if c.installer != nil {
|
if c.installer != nil {
|
||||||
return c.installer.relativeInstallPath()
|
return c.installer.relativeInstallPath()
|
||||||
|
@@ -140,7 +140,6 @@ func (cov *coverage) begin(ctx BaseModuleContext) {
|
|||||||
} else {
|
} else {
|
||||||
// Check if Native_coverage is set to false. This property defaults to true.
|
// Check if Native_coverage is set to false. This property defaults to true.
|
||||||
needCoverageVariant = BoolDefault(cov.Properties.Native_coverage, true)
|
needCoverageVariant = BoolDefault(cov.Properties.Native_coverage, true)
|
||||||
|
|
||||||
if sdk_version := ctx.sdkVersion(); ctx.useSdk() && sdk_version != "current" {
|
if sdk_version := ctx.sdkVersion(); ctx.useSdk() && sdk_version != "current" {
|
||||||
// Native coverage is not supported for SDK versions < 23
|
// Native coverage is not supported for SDK versions < 23
|
||||||
if fromApi, err := strconv.Atoi(sdk_version); err == nil && fromApi < 23 {
|
if fromApi, err := strconv.Atoi(sdk_version); err == nil && fromApi < 23 {
|
||||||
@@ -158,6 +157,14 @@ func (cov *coverage) begin(ctx BaseModuleContext) {
|
|||||||
cov.Properties.NeedCoverageVariant = needCoverageVariant
|
cov.Properties.NeedCoverageVariant = needCoverageVariant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Coverage is an interface for non-CC modules to implement to be mutated for coverage
|
||||||
|
type Coverage interface {
|
||||||
|
android.Module
|
||||||
|
IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool
|
||||||
|
PreventInstall()
|
||||||
|
HideFromMake()
|
||||||
|
}
|
||||||
|
|
||||||
func coverageMutator(mctx android.BottomUpMutatorContext) {
|
func coverageMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if c, ok := mctx.Module().(*Module); ok && c.coverage != nil {
|
if c, ok := mctx.Module().(*Module); ok && c.coverage != nil {
|
||||||
needCoverageVariant := c.coverage.Properties.NeedCoverageVariant
|
needCoverageVariant := c.coverage.Properties.NeedCoverageVariant
|
||||||
@@ -177,5 +184,14 @@ func coverageMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
m[1].(*Module).coverage.Properties.CoverageEnabled = needCoverageBuild
|
m[1].(*Module).coverage.Properties.CoverageEnabled = needCoverageBuild
|
||||||
m[1].(*Module).coverage.Properties.IsCoverageVariant = true
|
m[1].(*Module).coverage.Properties.IsCoverageVariant = true
|
||||||
}
|
}
|
||||||
|
} else if cov, ok := mctx.Module().(Coverage); ok && cov.IsNativeCoverageNeeded(mctx) {
|
||||||
|
// APEX modules fall here
|
||||||
|
|
||||||
|
// Note: variant "" is also created because an APEX can be depended on by another
|
||||||
|
// module which are split into "" and "cov" variants. e.g. when cc_test refers
|
||||||
|
// to an APEX via 'data' property.
|
||||||
|
m := mctx.CreateVariations("", "cov")
|
||||||
|
m[0].(Coverage).PreventInstall()
|
||||||
|
m[0].(Coverage).HideFromMake()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -814,6 +814,10 @@ func (library *libraryDecorator) nativeCoverage() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) coverageOutputFilePath() android.OptionalPath {
|
||||||
|
return library.coverageOutputFile
|
||||||
|
}
|
||||||
|
|
||||||
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
|
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
|
||||||
isLlndkOrNdk := inList(ctx.baseModuleName(), *llndkLibraries(ctx.Config())) || inList(ctx.baseModuleName(), ndkMigratedLibs)
|
isLlndkOrNdk := inList(ctx.baseModuleName(), *llndkLibraries(ctx.Config())) || inList(ctx.baseModuleName(), ndkMigratedLibs)
|
||||||
|
|
||||||
|
@@ -119,3 +119,7 @@ func (object *objectLinker) unstrippedOutputFilePath() android.Path {
|
|||||||
func (object *objectLinker) nativeCoverage() bool {
|
func (object *objectLinker) nativeCoverage() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (object *objectLinker) coverageOutputFilePath() android.OptionalPath {
|
||||||
|
return android.OptionalPath{}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user