diff options
author | Sebastien Hertz <shertz@google.com> | 2016-03-23 09:48:21 +0100 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2016-04-05 12:12:10 +0200 |
commit | 831c25634045d80f5cd522f934af6f9dfd253e62 (patch) | |
tree | 6dc53ce4f82dd0330c4b1bc777b4049e646a8473 | |
parent | f30df9cd8791309e704754def4adf1c94264c21a (diff) | |
download | jacoco-831c25634045d80f5cd522f934af6f9dfd253e62.tar.gz |
Build jacoco from sourcesandroid-cts-7.0_r9android-cts-7.0_r8android-cts-7.0_r7android-cts-7.0_r6android-cts-7.0_r5android-cts-7.0_r4android-cts-7.0_r33android-cts-7.0_r32android-cts-7.0_r31android-cts-7.0_r30android-cts-7.0_r3android-cts-7.0_r29android-cts-7.0_r28android-cts-7.0_r27android-cts-7.0_r26android-cts-7.0_r25android-cts-7.0_r24android-cts-7.0_r23android-cts-7.0_r22android-cts-7.0_r21android-cts-7.0_r20android-cts-7.0_r2android-cts-7.0_r19android-cts-7.0_r18android-cts-7.0_r17android-cts-7.0_r16android-cts-7.0_r15android-cts-7.0_r14android-cts-7.0_r13android-cts-7.0_r12android-cts-7.0_r11android-cts-7.0_r10android-cts-7.0_r1android-7.0.0_r9android-7.0.0_r8android-7.0.0_r7android-7.0.0_r6android-7.0.0_r5android-7.0.0_r4android-7.0.0_r36android-7.0.0_r35android-7.0.0_r34android-7.0.0_r33android-7.0.0_r32android-7.0.0_r31android-7.0.0_r30android-7.0.0_r3android-7.0.0_r29android-7.0.0_r28android-7.0.0_r27android-7.0.0_r24android-7.0.0_r21android-7.0.0_r19android-7.0.0_r17android-7.0.0_r15android-7.0.0_r14android-7.0.0_r13android-7.0.0_r12android-7.0.0_r11android-7.0.0_r10android-7.0.0_r1nougat-releasenougat-mr0.5-releasenougat-devnougat-cts-releasenougat-bugfix-release
Excludes source files that depend on non-Android classes and modifies
the source code when necessary.
Adds a README.android file to describe those changes and the process
to build jacoco.
Bug: 27719795
(cherry picked from commit 8d9dc829193712ce6859dbd1b894fa2fe6545ff8)
Change-Id: I1efb7cb7d6ef1e1ec5324c8d6ac0630a72169b63
-rw-r--r-- | Android.mk | 48 | ||||
-rw-r--r-- | PREBUILT | 12 | ||||
-rw-r--r-- | README.android | 15 | ||||
-rw-r--r-- | asm-debug-all-5.0.1.jar | bin | 0 -> 380292 bytes | |||
-rw-r--r-- | config.mk | 2 | ||||
-rw-r--r-- | org.jacoco.agent.rt-0.7.5.201505241946-all.jar | bin | 273599 -> 0 bytes | |||
-rw-r--r-- | org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java | 4 |
7 files changed, 67 insertions, 14 deletions
@@ -15,8 +15,50 @@ # LOCAL_PATH := $(call my-dir) +# Build jacoco from sources for the platform +# +# Note: this is only intended to be used for the platform development. This is *not* intended +# to be used in the SDK where apps can use the official jacoco release. include $(CLEAR_VARS) -LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \ - jacocoagent:org.jacoco.agent.rt-0.7.5.201505241946-all$(COMMON_JAVA_PACKAGE_SUFFIX) + +jacoco_src_files := $(call all-java-files-under,org.jacoco.core/src) +jacoco_src_files += $(call all-java-files-under,org.jacoco.agent/src) +jacoco_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src) + +# Some Jacoco source files depend on classes that do not exist in Android. While these classes are +# not executed at runtime (because we use offline instrumentation), they will cause issues when +# compiling them with ART during dex pre-opting. Therefore, it would prevent from applying code +# coverage on classes in the bootclasspath (frameworks, services, ...) or system apps. +# Note: we still may need to update the source code to cut dependencies in mandatory jacoco classes. +jacoco_android_exclude_list := \ + %org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java \ + %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java \ + %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java \ + %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java + +LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacoco_src_files)) + +# In order to include Jacoco in core libraries, we cannot depend on anything in the +# bootclasspath (or we would create dependency cycle). Therefore we compile against +# the SDK android.jar which gives the same APIs Jacoco depends on. +LOCAL_SDK_VERSION := 9 + +LOCAL_MODULE := jacocoagent LOCAL_MODULE_TAGS := optional -include $(BUILD_MULTI_PREBUILT) +LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm +include $(BUILD_STATIC_JAVA_LIBRARY) + +# +# Build asm-5.0.1 as a static library. +# +include $(CLEAR_VARS) + +LOCAL_MODULE := jacoco-asm +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := JAVA_LIBRARIES +LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX) +# Workaround for b/27319022 +LOCAL_JACK_FLAGS := -D jack.import.jar.debug-info=false +LOCAL_UNINSTALLABLE_MODULE := true + +include $(BUILD_PREBUILT) @@ -1,13 +1,7 @@ -The jacocoagent.jar is updated in the following way: +The ASM jar required by jacoco is updated in the following way: -mvn install -rm -f jacocoagent.jar -cp org.jacoco.agent.rt/target/org.jacoco.agent.rt-0.7.5.201505241946-all.jar jacocoagent.jar +mvn -f org.jacoco.agent.rt/pom.xml dependency:copy-dependencies +cp org.jacoco.agent.rt/target/dependency/asm-debug-all-5.0.1.jar ./ mvn clean The Android.mk must be updated to reference the right prebuilt. - -Also, the config.mk file must be updated to indicate what is the internal package name -containing the core classes of Jacoco (org.jacoco.agent.rt.internal_*) -Note: this information is available in the static field RUNTIMEPACKAGE -of the org.jacoco.core.JaCoCo class (http://eclemma.org/jacoco/trunk/doc/api/org/jacoco/core/JaCoCo.html#RUNTIMEPACKAGE) diff --git a/README.android b/README.android new file mode 100644 index 00000000..6df57d1a --- /dev/null +++ b/README.android @@ -0,0 +1,15 @@ +We build an equivalent of the jacoco-agent.jar which contains classes from org.jacoco.core, +org.jacoco.agent and org.jacoco.agent.rt packages but also classes from asm 5.0.1. + +However, Jacoco depends on classes that do not exist in Android (java.lang.instrument.* or +javax.management.*) for runtime instrumentation only. The ART compiler would reject those classes +when they are either in the bootclasspath (core, frameworks, ...) or system apps. + +Since we only use offline instrumentation for code coverage (using Jack) and do not execute these +classes at runtime, we simply not compile them here. + +We also need to modify the source code to cut dependencies to the classes that we exclude from the +compilation. The changes are surrounded by "BEGIN android-change" and "END android-change". Here +is the list of the changes: + +1) Remove the creation of JmxRegistration in org.jacoco.agent.rt.internal.Agent. diff --git a/asm-debug-all-5.0.1.jar b/asm-debug-all-5.0.1.jar Binary files differnew file mode 100644 index 00000000..76d4b6a7 --- /dev/null +++ b/asm-debug-all-5.0.1.jar @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -JACOCO_PACKAGE_NAME := org.jacoco.agent.rt.internal_d695e14 +JACOCO_PACKAGE_NAME := org.jacoco.agent.rt.internal diff --git a/org.jacoco.agent.rt-0.7.5.201505241946-all.jar b/org.jacoco.agent.rt-0.7.5.201505241946-all.jar Binary files differdeleted file mode 100644 index a9162556..00000000 --- a/org.jacoco.agent.rt-0.7.5.201505241946-all.jar +++ /dev/null diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java index 434fecdb..69ffc015 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java @@ -121,7 +121,9 @@ public class Agent implements IAgent { output = createAgentOutput(); output.startup(options, data); if (options.getJmx()) { - jmxRegistration = new JmxRegistration(this); +// BEGIN android-change +// jmxRegistration = new JmxRegistration(this); +// END android-change } } catch (final Exception e) { logger.logExeption(e); |