Loading cc/coverage.go +11 −2 Original line number Diff line number Diff line Loading @@ -219,10 +219,14 @@ func SetCoverageProperties(ctx android.BaseModuleContext, properties CoveragePro return properties } // Coverage is an interface for non-CC modules to implement to be mutated for coverage type Coverage interface { type UseCoverage interface { android.Module IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool } // Coverage is an interface for non-CC modules to implement to be mutated for coverage type Coverage interface { UseCoverage SetPreventInstall() HideFromMake() MarkAsCoverageVariant(bool) Loading Loading @@ -261,6 +265,11 @@ func coverageMutator(mctx android.BottomUpMutatorContext) { m[1].(Coverage).MarkAsCoverageVariant(true) m[1].(Coverage).EnableCoverageIfNeeded() } else if cov, ok := mctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(mctx) { // Module itself doesn't have to have "cov" variant, but it should use "cov" variants of // deps. mctx.CreateVariations("cov") mctx.AliasVariation("cov") } } Loading filesystem/filesystem.go +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import ( "strings" "android/soong/android" "android/soong/cc" "github.com/google/blueprint" "github.com/google/blueprint/proptools" Loading Loading @@ -498,3 +499,11 @@ func sha1sum(values []string) string { } return fmt.Sprintf("%x", h.Sum(nil)) } // Base cc.UseCoverage var _ cc.UseCoverage = (*filesystem)(nil) func (*filesystem) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled() } filesystem/filesystem_test.go +57 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,9 @@ import ( "android/soong/android" "android/soong/cc" "android/soong/etc" "github.com/google/blueprint/proptools" ) func TestMain(m *testing.M) { Loading @@ -28,6 +31,7 @@ func TestMain(m *testing.M) { var fixture = android.GroupFixturePreparers( android.PrepareForIntegrationTestWithAndroid, etc.PrepareForTestWithPrebuiltEtc, cc.PrepareForIntegrationTestWithCc, PrepareForTestWithFilesystemBuildComponents, ) Loading Loading @@ -225,3 +229,56 @@ func TestFileSystemShouldInstallCoreVariantIfTargetBuildAppsIsSet(t *testing.T) inputs.Strings(), "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared/libbar.so") } func TestFileSystemWithCoverageVariants(t *testing.T) { context := android.GroupFixturePreparers( fixture, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.GcovCoverage = proptools.BoolPtr(true) variables.Native_coverage = proptools.BoolPtr(true) }), ) result := context.RunTestWithBp(t, ` prebuilt_etc { name: "prebuilt", src: ":myfilesystem", } android_system_image { name: "myfilesystem", deps: [ "libfoo", ], linker_config_src: "linker.config.json", } cc_library { name: "libfoo", shared_libs: [ "libbar", ], stl: "none", } cc_library { name: "libbar", stl: "none", } `) filesystem := result.ModuleForTests("myfilesystem", "android_common_cov") inputs := filesystem.Output("deps.zip").Implicits android.AssertStringListContains(t, "filesystem should have libfoo(cov)", inputs.Strings(), "out/soong/.intermediates/libfoo/android_arm64_armv8-a_shared_cov/libfoo.so") android.AssertStringListContains(t, "filesystem should have libbar(cov)", inputs.Strings(), "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared_cov/libbar.so") filesystemOutput := filesystem.Output("myfilesystem.img").Output prebuiltInput := result.ModuleForTests("prebuilt", "android_arm64_armv8-a").Rule("Cp").Input if filesystemOutput != prebuiltInput { t.Error("prebuilt should use cov variant of filesystem") } } Loading
cc/coverage.go +11 −2 Original line number Diff line number Diff line Loading @@ -219,10 +219,14 @@ func SetCoverageProperties(ctx android.BaseModuleContext, properties CoveragePro return properties } // Coverage is an interface for non-CC modules to implement to be mutated for coverage type Coverage interface { type UseCoverage interface { android.Module IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool } // Coverage is an interface for non-CC modules to implement to be mutated for coverage type Coverage interface { UseCoverage SetPreventInstall() HideFromMake() MarkAsCoverageVariant(bool) Loading Loading @@ -261,6 +265,11 @@ func coverageMutator(mctx android.BottomUpMutatorContext) { m[1].(Coverage).MarkAsCoverageVariant(true) m[1].(Coverage).EnableCoverageIfNeeded() } else if cov, ok := mctx.Module().(UseCoverage); ok && cov.IsNativeCoverageNeeded(mctx) { // Module itself doesn't have to have "cov" variant, but it should use "cov" variants of // deps. mctx.CreateVariations("cov") mctx.AliasVariation("cov") } } Loading
filesystem/filesystem.go +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import ( "strings" "android/soong/android" "android/soong/cc" "github.com/google/blueprint" "github.com/google/blueprint/proptools" Loading Loading @@ -498,3 +499,11 @@ func sha1sum(values []string) string { } return fmt.Sprintf("%x", h.Sum(nil)) } // Base cc.UseCoverage var _ cc.UseCoverage = (*filesystem)(nil) func (*filesystem) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled() }
filesystem/filesystem_test.go +57 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,9 @@ import ( "android/soong/android" "android/soong/cc" "android/soong/etc" "github.com/google/blueprint/proptools" ) func TestMain(m *testing.M) { Loading @@ -28,6 +31,7 @@ func TestMain(m *testing.M) { var fixture = android.GroupFixturePreparers( android.PrepareForIntegrationTestWithAndroid, etc.PrepareForTestWithPrebuiltEtc, cc.PrepareForIntegrationTestWithCc, PrepareForTestWithFilesystemBuildComponents, ) Loading Loading @@ -225,3 +229,56 @@ func TestFileSystemShouldInstallCoreVariantIfTargetBuildAppsIsSet(t *testing.T) inputs.Strings(), "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared/libbar.so") } func TestFileSystemWithCoverageVariants(t *testing.T) { context := android.GroupFixturePreparers( fixture, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.GcovCoverage = proptools.BoolPtr(true) variables.Native_coverage = proptools.BoolPtr(true) }), ) result := context.RunTestWithBp(t, ` prebuilt_etc { name: "prebuilt", src: ":myfilesystem", } android_system_image { name: "myfilesystem", deps: [ "libfoo", ], linker_config_src: "linker.config.json", } cc_library { name: "libfoo", shared_libs: [ "libbar", ], stl: "none", } cc_library { name: "libbar", stl: "none", } `) filesystem := result.ModuleForTests("myfilesystem", "android_common_cov") inputs := filesystem.Output("deps.zip").Implicits android.AssertStringListContains(t, "filesystem should have libfoo(cov)", inputs.Strings(), "out/soong/.intermediates/libfoo/android_arm64_armv8-a_shared_cov/libfoo.so") android.AssertStringListContains(t, "filesystem should have libbar(cov)", inputs.Strings(), "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared_cov/libbar.so") filesystemOutput := filesystem.Output("myfilesystem.img").Output prebuiltInput := result.ModuleForTests("prebuilt", "android_arm64_armv8-a").Rule("Cp").Input if filesystemOutput != prebuiltInput { t.Error("prebuilt should use cov variant of filesystem") } }