Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -391,6 +391,7 @@ bootstrap_go_package { srcs: [ "rust/androidmk.go", "rust/compiler.go", "rust/coverage.go", "rust/binary.go", "rust/builder.go", "rust/library.go", Loading @@ -403,6 +404,7 @@ bootstrap_go_package { testSrcs: [ "rust/binary_test.go", "rust/compiler_test.go", "rust/coverage_test.go", "rust/library_test.go", "rust/rust_test.go", "rust/test_test.go", Loading android/util.go +10 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,16 @@ func PrefixInList(list []string, prefix string) bool { return false } // Returns true if any string in the given list has the given suffix. func SuffixInList(list []string, suffix string) bool { for _, s := range list { if strings.HasSuffix(s, suffix) { return true } } return false } // IndexListPred returns the index of the element which in the given `list` satisfying the predicate, or -1 if there is no such element. func IndexListPred(pred func(s string) bool, list []string) int { for i, l := range list { Loading apex/apex.go +4 −0 Original line number Diff line number Diff line Loading @@ -1603,6 +1603,8 @@ func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizer return android.InList(sanitizerName, globalSanitizerNames) } var _ cc.Coverage = (*apexBundle)(nil) func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled()) } Loading @@ -1619,6 +1621,8 @@ func (a *apexBundle) MarkAsCoverageVariant(coverage bool) { a.properties.IsCoverageVariant = coverage } func (a *apexBundle) EnableCoverageIfNeeded() {} // TODO(jiyong) move apexFileFor* close to the apexFile type definition func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile { // Decide the APEX-local directory by the multilib of the library Loading apex/vndk_test.go +1 −38 Original line number Diff line number Diff line Loading @@ -117,44 +117,7 @@ func TestVndkApexUsesVendorVariant(t *testing.T) { }) t.Run("VNDK APEX supports coverage variants", func(t *testing.T) { ctx, _ := testApex(t, bp+` cc_library { name: "libprofile-extras", vendor_available: true, recovery_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", } cc_library { name: "libprofile-clang-extras", vendor_available: true, recovery_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", } cc_library { name: "libprofile-extras_ndk", vendor_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", sdk_version: "current", } cc_library { name: "libprofile-clang-extras_ndk", vendor_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", sdk_version: "current", } `, func(fs map[string][]byte, config android.Config) { ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) { config.TestProductVariables.Native_coverage = proptools.BoolPtr(true) }) Loading cc/cc.go +13 −2 Original line number Diff line number Diff line Loading @@ -437,7 +437,6 @@ var ( ndkLateStubDepTag = DependencyTag{Name: "ndk late stub", Library: true} vndkExtDepTag = DependencyTag{Name: "vndk extends", Library: true} runtimeDepTag = DependencyTag{Name: "runtime lib"} coverageDepTag = DependencyTag{Name: "coverage"} testPerSrcDepTag = DependencyTag{Name: "test_per_src"} ) Loading Loading @@ -745,6 +744,15 @@ func (c *Module) OutputFile() android.OptionalPath { return c.outputFile } func (c *Module) CoverageFiles() android.Paths { if c.linker != nil { if library, ok := c.linker.(libraryInterface); ok { return library.objs().coverageFiles } } panic(fmt.Errorf("CoverageFiles called on non-library module: %q", c.BaseModuleName())) } var _ LinkableInterface = (*Module)(nil) func (c *Module) UnstrippedOutputFile() android.Path { Loading Loading @@ -2493,13 +2501,16 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // When combining coverage files for shared libraries and executables, coverage files // in static libraries act as if they were whole static libraries. The same goes for // source based Abi dump files. // This should only be done for cc.Modules if c, ok := ccDep.(*Module); ok { staticLib := c.linker.(libraryInterface) depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, staticLib.objs().coverageFiles...) depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles, staticLib.objs().sAbiDumpFiles...) } else if c, ok := ccDep.(LinkableInterface); ok { // Handle non-CC modules here depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, c.CoverageFiles()...) } } Loading Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -391,6 +391,7 @@ bootstrap_go_package { srcs: [ "rust/androidmk.go", "rust/compiler.go", "rust/coverage.go", "rust/binary.go", "rust/builder.go", "rust/library.go", Loading @@ -403,6 +404,7 @@ bootstrap_go_package { testSrcs: [ "rust/binary_test.go", "rust/compiler_test.go", "rust/coverage_test.go", "rust/library_test.go", "rust/rust_test.go", "rust/test_test.go", Loading
android/util.go +10 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,16 @@ func PrefixInList(list []string, prefix string) bool { return false } // Returns true if any string in the given list has the given suffix. func SuffixInList(list []string, suffix string) bool { for _, s := range list { if strings.HasSuffix(s, suffix) { return true } } return false } // IndexListPred returns the index of the element which in the given `list` satisfying the predicate, or -1 if there is no such element. func IndexListPred(pred func(s string) bool, list []string) int { for i, l := range list { Loading
apex/apex.go +4 −0 Original line number Diff line number Diff line Loading @@ -1603,6 +1603,8 @@ func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizer return android.InList(sanitizerName, globalSanitizerNames) } var _ cc.Coverage = (*apexBundle)(nil) func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { return ctx.Device() && (ctx.DeviceConfig().NativeCoverageEnabled() || ctx.DeviceConfig().ClangCoverageEnabled()) } Loading @@ -1619,6 +1621,8 @@ func (a *apexBundle) MarkAsCoverageVariant(coverage bool) { a.properties.IsCoverageVariant = coverage } func (a *apexBundle) EnableCoverageIfNeeded() {} // TODO(jiyong) move apexFileFor* close to the apexFile type definition func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile { // Decide the APEX-local directory by the multilib of the library Loading
apex/vndk_test.go +1 −38 Original line number Diff line number Diff line Loading @@ -117,44 +117,7 @@ func TestVndkApexUsesVendorVariant(t *testing.T) { }) t.Run("VNDK APEX supports coverage variants", func(t *testing.T) { ctx, _ := testApex(t, bp+` cc_library { name: "libprofile-extras", vendor_available: true, recovery_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", } cc_library { name: "libprofile-clang-extras", vendor_available: true, recovery_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", } cc_library { name: "libprofile-extras_ndk", vendor_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", sdk_version: "current", } cc_library { name: "libprofile-clang-extras_ndk", vendor_available: true, native_coverage: false, system_shared_libs: [], stl: "none", notice: "custom_notice", sdk_version: "current", } `, func(fs map[string][]byte, config android.Config) { ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) { config.TestProductVariables.Native_coverage = proptools.BoolPtr(true) }) Loading
cc/cc.go +13 −2 Original line number Diff line number Diff line Loading @@ -437,7 +437,6 @@ var ( ndkLateStubDepTag = DependencyTag{Name: "ndk late stub", Library: true} vndkExtDepTag = DependencyTag{Name: "vndk extends", Library: true} runtimeDepTag = DependencyTag{Name: "runtime lib"} coverageDepTag = DependencyTag{Name: "coverage"} testPerSrcDepTag = DependencyTag{Name: "test_per_src"} ) Loading Loading @@ -745,6 +744,15 @@ func (c *Module) OutputFile() android.OptionalPath { return c.outputFile } func (c *Module) CoverageFiles() android.Paths { if c.linker != nil { if library, ok := c.linker.(libraryInterface); ok { return library.objs().coverageFiles } } panic(fmt.Errorf("CoverageFiles called on non-library module: %q", c.BaseModuleName())) } var _ LinkableInterface = (*Module)(nil) func (c *Module) UnstrippedOutputFile() android.Path { Loading Loading @@ -2493,13 +2501,16 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // When combining coverage files for shared libraries and executables, coverage files // in static libraries act as if they were whole static libraries. The same goes for // source based Abi dump files. // This should only be done for cc.Modules if c, ok := ccDep.(*Module); ok { staticLib := c.linker.(libraryInterface) depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, staticLib.objs().coverageFiles...) depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles, staticLib.objs().sAbiDumpFiles...) } else if c, ok := ccDep.(LinkableInterface); ok { // Handle non-CC modules here depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, c.CoverageFiles()...) } } Loading