Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c4e5c05 authored by Ivan Lozano's avatar Ivan Lozano Committed by Gerrit Code Review
Browse files

Merge "Add gcov coverage support to Rust modules."

parents bd7e3295 a0cd8f9a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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",
@@ -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",
+10 −0
Original line number Diff line number Diff line
@@ -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 {
+4 −0
Original line number Diff line number Diff line
@@ -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())
}
@@ -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
+1 −38
Original line number Diff line number Diff line
@@ -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)
		})

+13 −2
Original line number Diff line number Diff line
@@ -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"}
)

@@ -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 {
@@ -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