aboutsummaryrefslogtreecommitdiffstats
path: root/java/java.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2018-01-03 15:06:47 -0800
committerColin Cross <ccross@android.com>2018-01-04 14:52:45 -0800
commit3144dfc96610b68ac6c815e589b662960086ff4f (patch)
tree6ae41c42d1724369b53f4b4e231db5c2f5034ee8 /java/java.go
parente7fa3b1b749389411ed2f16e32a41934c4ffe38f (diff)
downloadbuild_soong-3144dfc96610b68ac6c815e589b662960086ff4f.tar.gz
build_soong-3144dfc96610b68ac6c815e589b662960086ff4f.tar.bz2
build_soong-3144dfc96610b68ac6c815e589b662960086ff4f.zip
Add EMMA_INSTRUMENT_STATIC support
Add jacocoagent when instrumenting with EMMA_INSTRUMENT_STATIC. Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true Change-Id: I451bb9d16b7f0a66fd06c2da576062b28830e470
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go
index 24debacd..8f58c6ea 100644
--- a/java/java.go
+++ b/java/java.go
@@ -319,6 +319,16 @@ func sdkStringToNumber(ctx android.BaseContext, v string) int {
}
}
+func (j *Module) shouldInstrument(ctx android.BaseContext) bool {
+ return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
+}
+
+func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool {
+ return j.shouldInstrument(ctx) &&
+ (ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") ||
+ ctx.Config().UnbundledBuild())
+}
+
func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
i := sdkStringToNumber(ctx, v)
if i == -1 {
@@ -443,6 +453,10 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
// Kotlin files
ctx.AddDependency(ctx.Module(), kotlinStdlibTag, "kotlin-stdlib")
}
+
+ if j.shouldInstrumentStatic(ctx) {
+ ctx.AddDependency(ctx.Module(), staticLibTag, "jacocoagent")
+ }
}
func hasSrcExt(srcs []string, ext string) bool {
@@ -871,7 +885,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
}
}
- if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") && j.properties.Instrument {
+ if j.shouldInstrument(ctx) {
outputFile = j.instrument(ctx, flags, outputFile, jarName)
}