From e62e594a2420afd9326bab7d7c28e2517086fa62 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Tue, 7 Apr 2020 13:07:55 -0700 Subject: [PATCH] Collect JNI coverage data only for first target. Modules with compile_multilib property set to "both" cause builds to fail due to duplicate Make recipes. Fix it by outputting reports only for the first target for now. Bug: 153461674 Test: Built cts with the coverage flags set. Change-Id: Ibb8da6e9c112a857695cd7095a62c910cddfbb94 --- java/app.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/app.go b/java/app.go index f9992d885..c64f1f73c 100755 --- a/java/app.go +++ b/java/app.go @@ -385,7 +385,18 @@ func (a *AndroidApp) jniBuildActions(jniLibs []jniLib, ctx android.ModuleContext TransformJniLibsToJar(ctx, jniJarFile, jniLibs, a.useEmbeddedNativeLibs(ctx)) for _, jni := range jniLibs { if jni.coverageFile.Valid() { - a.jniCoverageOutputs = append(a.jniCoverageOutputs, jni.coverageFile.Path()) + // Only collect coverage for the first target arch if this is a multilib target. + // TODO(jungjw): Ideally, we want to collect both reports, but that would cause coverage + // data file path collisions since the current coverage file path format doesn't contain + // arch-related strings. This is fine for now though; the code coverage team doesn't use + // multi-arch targets such as test_suite_* for coverage collections yet. + // + // Work with the team to come up with a new format that handles multilib modules properly + // and change this. + if len(ctx.Config().Targets[android.Android]) == 1 || + ctx.Config().Targets[android.Android][0].Arch.ArchType == jni.target.Arch.ArchType { + a.jniCoverageOutputs = append(a.jniCoverageOutputs, jni.coverageFile.Path()) + } } } } else {