• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16LOCAL_PATH := $(call my-dir)
17
18# Some Jacoco source files depend on classes that do not exist in Android. While these classes are
19# not executed at runtime (because we use offline instrumentation), they will cause issues when
20# compiling them with ART during dex pre-opting. Therefore, it would prevent from applying code
21# coverage on classes in the bootclasspath (frameworks, services, ...) or system apps.
22# Note: we still may need to update the source code to cut dependencies in mandatory jacoco classes.
23jacoco_android_exclude_list := \
24  %org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java \
25  %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java \
26  %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java \
27  %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
28
29
30# Build jacoco-agent from sources for the platform
31#
32# Note: this is only intended to be used for the platform development. This is *not* intended
33# to be used in the SDK where apps can use the official jacoco release.
34include $(CLEAR_VARS)
35
36jacocoagent_src_files := $(call all-java-files-under,org.jacoco.core/src)
37jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent/src)
38jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)
39
40LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacocoagent_src_files))
41
42# In order to include Jacoco in core libraries, we cannot depend on anything in the
43# bootclasspath (or we would create dependency cycle). Therefore we compile against
44# the SDK android.jar which gives the same APIs Jacoco depends on.
45LOCAL_SDK_VERSION := 9
46
47LOCAL_MODULE := jacocoagent
48LOCAL_MODULE_TAGS := optional
49LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm
50include $(BUILD_STATIC_JAVA_LIBRARY)
51
52
53# Build jacoco-cli from sources for the platform
54include $(CLEAR_VARS)
55
56# TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
57# what is defined in the pom.xml files, although it's probably much more trouble than it's worth
58jacococli_src_files += $(call all-java-files-under,org.jacoco.core/src)
59jacococli_src_files += $(call all-java-files-under,org.jacoco.report/src)
60jacococli_src_files += $(call all-java-files-under,org.jacoco.cli/src)
61LOCAL_JAVA_RESOURCE_DIRS := org.jacoco.core/src org.jacoco.report/src
62LOCAL_JAR_MANIFEST := org.jacoco.cli/src/MANIFEST.MF
63
64LOCAL_SRC_FILES := $(jacococli_src_files)
65
66LOCAL_MODULE := jacoco-cli
67LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm-host args4j-2.0.28
68
69include $(BUILD_HOST_JAVA_LIBRARY)
70
71# include jacoco-cli in the dist directory to enable running it to generate a code-coverage report
72ifeq ($(ANDROID_COMPILE_WITH_JACK),false)
73ifeq ($(EMMA_INSTRUMENT),true)
74$(call dist-for-goals, dist_files, $(LOCAL_INSTALLED_MODULE))
75endif
76endif
77
78
79#
80# Build asm-5.0.1 as a static library for the device
81#
82include $(CLEAR_VARS)
83
84LOCAL_MODULE := jacoco-asm
85LOCAL_MODULE_TAGS := optional
86LOCAL_MODULE_CLASS := JAVA_LIBRARIES
87LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX)
88# Workaround for b/27319022
89LOCAL_JACK_FLAGS := -D jack.import.jar.debug-info=false
90LOCAL_UNINSTALLABLE_MODULE := true
91
92include $(BUILD_PREBUILT)
93
94
95#
96# Build asm-5.0.1 as a static library for the host
97#
98include $(CLEAR_VARS)
99
100LOCAL_MODULE := jacoco-asm-host
101LOCAL_IS_HOST_MODULE := true
102LOCAL_MODULE_CLASS := JAVA_LIBRARIES
103LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX)
104
105include $(BUILD_PREBUILT)
106