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

Commit 4866e885 authored by Roland Levillain's avatar Roland Levillain Committed by Automerger Merge Worker
Browse files

Introduce product variables to select Java code coverage paths in Soong. am: 583691a0

Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/12036111

Change-Id: I2abfabe19fabd088296a171aef52a765da79fa64
parents 4a49ad6e 583691a0
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -1037,6 +1037,27 @@ func (c *deviceConfig) SamplingPGO() bool {
	return Bool(c.config.productVariables.SamplingPGO)
}

// JavaCoverageEnabledForPath returns whether Java code coverage is enabled for
// path. Coverage is enabled by default when the product variable
// JavaCoveragePaths is empty. If JavaCoveragePaths is not empty, coverage is
// enabled for any path which is part of this variable (and not part of the
// JavaCoverageExcludePaths product variable). Value "*" in JavaCoveragePaths
// represents any path.
func (c *deviceConfig) JavaCoverageEnabledForPath(path string) bool {
	coverage := false
	if c.config.productVariables.JavaCoveragePaths == nil ||
		InList("*", c.config.productVariables.JavaCoveragePaths) ||
		HasAnyPrefix(path, c.config.productVariables.JavaCoveragePaths) {
		coverage = true
	}
	if coverage && c.config.productVariables.JavaCoverageExcludePaths != nil {
		if HasAnyPrefix(path, c.config.productVariables.JavaCoverageExcludePaths) {
			coverage = false
		}
	}
	return coverage
}

func (c *config) NativeLineCoverage() bool {
	return Bool(c.productVariables.NativeLineCoverage)
}
+3 −0
Original line number Diff line number Diff line
@@ -253,6 +253,9 @@ type productVariables struct {

	SamplingPGO *bool `json:",omitempty"`

	JavaCoveragePaths        []string `json:",omitempty"`
	JavaCoverageExcludePaths []string `json:",omitempty"`

	NativeLineCoverage         *bool    `json:",omitempty"`
	Native_coverage            *bool    `json:",omitempty"`
	ClangCoverage              *bool    `json:",omitempty"`
+3 −1
Original line number Diff line number Diff line
@@ -633,7 +633,9 @@ type jniLib struct {
}

func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool {
	return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
	return j.properties.Instrument &&
		ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") &&
		ctx.DeviceConfig().JavaCoverageEnabledForPath(ctx.ModuleDir())
}

func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool {