summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorChris Gross <chrisgross@google.com>2020-06-15 16:59:05 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-15 16:59:05 +0000
commitefa623c7e4e6dbd17087b6fcef815ebef5563d99 (patch)
treef83348235be5a3ccac40ac8a5f279bde51c01e11 /java/java.go
parentd4b69d31c43fb0f400035a06288bc15ae02fc74d (diff)
parenta7a36e22fbe9906a8f94626cb087518e68a19bbd (diff)
Merge "Use EMMA_INSTRUMENT_FRAMEWORK for apex framework libs." am: a7a36e22fb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1320475 Change-Id: I6521c532272e83c17547e505c0a12172cf8293a6
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/java/java.go b/java/java.go
index 1cdfbf187..13f9f2fbf 100644
--- a/java/java.go
+++ b/java/java.go
@@ -610,6 +610,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))
}
@@ -1543,11 +1558,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
}