diff options
| author | 2020-05-29 16:01:19 +0000 | |
|---|---|---|
| committer | 2020-06-11 23:21:47 +0000 | |
| commit | 190fdc0b1ae59fedda33d83d69496f6fd1439e86 (patch) | |
| tree | 64c9cc14337415635e598ca1a7360481d3277ea5 /java/java.go | |
| parent | 8a624337b308f70151a9f50f8ef29fd636f7e98c (diff) | |
Use EMMA_INSTRUMENT_FRAMEWORK for apex framework libs.
Static coverage builds that trigger a dexpreopt target for a bootclasspath
jar can fail since coverage for jars in apexes are turned on by default
which requires jacocoagent to be present on the bootclasspath.
Fix this by using EMMA_INSTRUMENT_FRAMEWORK to conditionally instrument
framework libs in apexes.
Bug: 157737183
Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true m -j droid
Change-Id: I2c323553e08741bc46b196bc3bb860614bc3f85b
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 21 | 
1 files changed, 16 insertions, 5 deletions
| diff --git a/java/java.go b/java/java.go index 0ba1f5a7a..3518ac4e6 100644 --- a/java/java.go +++ b/java/java.go @@ -609,6 +609,21 @@ func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool {  			ctx.Config().UnbundledBuild())  } +func (j *Module) shouldInstrumentInApex(ctx android.BaseModuleContext) bool { +	// Force enable the instrumentation for java code that is built for APEXes ... +	// except for the jacocoagent itself (because instrumenting jacocoagent using jacocoagent +	// doesn't make sense) or framework libraries (e.g. libraries found in the InstrumentFrameworkModules list) unless EMMA_INSTRUMENT_FRAMEWORK is true. +	isJacocoAgent := ctx.ModuleName() == "jacocoagent" +	if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !isJacocoAgent && !j.IsForPlatform() { +		if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { +			return true +		} else if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { +			return true +		} +	} +	return false +} +  func (j *Module) sdkVersion() sdkSpec {  	return sdkSpecFrom(String(j.deviceProperties.Sdk_version))  } @@ -1541,11 +1556,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {  		j.headerJarFile = j.implementationJarFile  	} -	// Force enable the instrumentation for java code that is built for APEXes ... -	// except for the jacocoagent itself (because instrumenting jacocoagent using jacocoagent -	// doesn't make sense) -	isJacocoAgent := ctx.ModuleName() == "jacocoagent" -	if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !isJacocoAgent && !j.IsForPlatform() { +	if j.shouldInstrumentInApex(ctx) {  		j.properties.Instrument = true  	} |