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
This commit is contained in:
16
java/java.go
16
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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user