diff options
author | Chris Gross <chrisgross@google.com> | 2020-06-15 17:18:39 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-15 17:18:39 +0000 |
commit | ca7a598d67364b99fc90de78a73dcea085682570 (patch) | |
tree | 8e10c318379339c2d9558eef28a769eb941baee2 /java/java.go | |
parent | ea3fdcd596bc14a022f4564b69ef513399159509 (diff) | |
parent | efa623c7e4e6dbd17087b6fcef815ebef5563d99 (diff) |
Merge "Use EMMA_INSTRUMENT_FRAMEWORK for apex framework libs." am: a7a36e22fb am: efa623c7e4
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1320475
Change-Id: I2b9bca7a7d7107353541a36d5feeea492fc5ed87
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 c51a1d3b6..83573e55b 100644 --- a/java/java.go +++ b/java/java.go @@ -614,6 +614,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)) } @@ -1547,11 +1562,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 } |