diff options
author | 2018-01-03 15:59:46 -0800 | |
---|---|---|
committer | 2018-01-03 16:02:47 -0800 | |
commit | 84c3882e649ed15db8a30a4acdbeed26f9304f06 (patch) | |
tree | ba92cb830a0f0592378e24d2dbc4f43b036737ce /java/jacoco.go | |
parent | 66dbc0bc32100d9696dd248018683128a1274016 (diff) |
Fix jacoco_cli invocation
jacoco_cli --dest takes a directory, not a jar name, and assumes
an output file with the same name as the input jar in that
directory. Rename jacoco-report-classes.jar to
jacoco-report-classes/modulename.jar, and generate to
jacoco/tmp/modulename.jar before combining to the final output file
at jacoco/modulename.jar.
Bug: 69669951
Test: m EMMA_INSTRUMENT=true
Change-Id: Ia7dd881d2819ae09dfb60a00b4c1b8396629cd9a
Diffstat (limited to 'java/jacoco.go')
-rw-r--r-- | java/jacoco.go | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/java/jacoco.go b/java/jacoco.go index e6da5a657..8f1ceb261 100644 --- a/java/jacoco.go +++ b/java/jacoco.go @@ -18,6 +18,7 @@ package java import ( "fmt" + "path/filepath" "strings" "github.com/google/blueprint" @@ -27,11 +28,12 @@ import ( var ( jacoco = pctx.AndroidStaticRule("jacoco", blueprint.RuleParams{ - Command: `${config.Zip2ZipCmd} -i $in -o $strippedJar $stripSpec && ` + + Command: `rm -rf $tmpDir && mkdir -p $tmpDir && ` + + `${config.Zip2ZipCmd} -i $in -o $strippedJar $stripSpec && ` + `${config.JavaCmd} -jar ${config.JacocoCLIJar} ` + - ` instrument --quiet --dest $instrumentedJar $strippedJar && ` + - `${config.Ziptime} $instrumentedJar && ` + - `${config.MergeZipsCmd} --ignore-duplicates -j $out $instrumentedJar $in`, + ` instrument --quiet --dest $tmpDir $strippedJar && ` + + `${config.Ziptime} $tmpJar && ` + + `${config.MergeZipsCmd} --ignore-duplicates -j $out $tmpJar $in`, CommandDeps: []string{ "${config.Zip2ZipCmd}", "${config.JavaCmd}", @@ -40,23 +42,30 @@ var ( "${config.MergeZipsCmd}", }, }, - "strippedJar", "stripSpec", "instrumentedJar") + "strippedJar", "stripSpec", "tmpDir", "tmpJar") ) -func jacocoInstrumentJar(ctx android.ModuleContext, outputJar, strippedJar android.WritablePath, +// Instruments a jar using the Jacoco command line interface. Uses stripSpec to extract a subset +// of the classes in inputJar into strippedJar, instruments strippedJar into tmpJar, and then +// combines the classes in tmpJar with inputJar (preferring the instrumented classes in tmpJar) +// to produce instrumentedJar. +func jacocoInstrumentJar(ctx android.ModuleContext, instrumentedJar, strippedJar android.WritablePath, inputJar android.Path, stripSpec string) { - instrumentedJar := android.PathForModuleOut(ctx, "jacoco/instrumented.jar") + + // The basename of tmpJar has to be the same as the basename of strippedJar + tmpJar := android.PathForModuleOut(ctx, "jacoco", "tmp", strippedJar.Base()) ctx.Build(pctx, android.BuildParams{ Rule: jacoco, Description: "jacoco", - Output: outputJar, + Output: instrumentedJar, ImplicitOutput: strippedJar, Input: inputJar, Args: map[string]string{ - "strippedJar": strippedJar.String(), - "stripSpec": stripSpec, - "instrumentedJar": instrumentedJar.String(), + "strippedJar": strippedJar.String(), + "stripSpec": stripSpec, + "tmpDir": filepath.Dir(tmpJar.String()), + "tmpJar": tmpJar.String(), }, }) } |