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# Build jacoco from sources for the platform
19#
20# Note: this is only intended to be used for the platform development. This is *not* intended
21# to be used in the SDK where apps can use the official jacoco release.
22include $(CLEAR_VARS)
23
24jacoco_src_files := $(call all-java-files-under,org.jacoco.core/src)
25jacoco_src_files += $(call all-java-files-under,org.jacoco.agent/src)
26jacoco_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)
27
28# Some Jacoco source files depend on classes that do not exist in Android. While these classes are
29# not executed at runtime (because we use offline instrumentation), they will cause issues when
30# compiling them with ART during dex pre-opting. Therefore, it would prevent from applying code
31# coverage on classes in the bootclasspath (frameworks, services, ...) or system apps.
32# Note: we still may need to update the source code to cut dependencies in mandatory jacoco classes.
33jacoco_android_exclude_list := \
34  %org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java \
35  %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java \
36  %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java \
37  %org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java
38
39LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacoco_src_files))
40
41# In order to include Jacoco in core libraries, we cannot depend on anything in the
42# bootclasspath (or we would create dependency cycle). Therefore we compile against
43# the SDK android.jar which gives the same APIs Jacoco depends on.
44LOCAL_SDK_VERSION := 9
45
46LOCAL_MODULE := jacocoagent
47LOCAL_MODULE_TAGS := optional
48LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm
49include $(BUILD_STATIC_JAVA_LIBRARY)
50
51#
52# Build asm-5.0.1 as a static library.
53#
54include $(CLEAR_VARS)
55
56LOCAL_MODULE := jacoco-asm
57LOCAL_MODULE_TAGS := optional
58LOCAL_MODULE_CLASS := JAVA_LIBRARIES
59LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX)
60# Workaround for b/27319022
61LOCAL_JACK_FLAGS := -D jack.import.jar.debug-info=false
62LOCAL_UNINSTALLABLE_MODULE := true
63
64include $(BUILD_PREBUILT)
65