aboutsummaryrefslogtreecommitdiff
path: root/Android.mk
blob: 5ba54801459fa09baf1d3314723a04993d702cd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)

# 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


# Build jacoco-agent 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)

jacocoagent_src_files := $(call all-java-files-under,org.jacoco.core/src)
jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent/src)
jacocoagent_src_files += $(call all-java-files-under,org.jacoco.agent.rt/src)

LOCAL_SRC_FILES := $(filter-out $(jacoco_android_exclude_list),$(jacocoagent_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
LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm
include $(BUILD_STATIC_JAVA_LIBRARY)


# Build jacoco-cli from sources for the platform
include $(CLEAR_VARS)

# TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
# what is defined in the pom.xml files, although it's probably much more trouble than it's worth
jacococli_src_files += $(call all-java-files-under,org.jacoco.core/src)
jacococli_src_files += $(call all-java-files-under,org.jacoco.report/src)
jacococli_src_files += $(call all-java-files-under,org.jacoco.cli/src)
LOCAL_JAVA_RESOURCE_DIRS := org.jacoco.core/src org.jacoco.report/src
LOCAL_JAR_MANIFEST := org.jacoco.cli/src/MANIFEST.MF

LOCAL_SRC_FILES := $(jacococli_src_files)

LOCAL_MODULE := jacoco-cli
LOCAL_STATIC_JAVA_LIBRARIES := jacoco-asm-host args4j-2.0.28

include $(BUILD_HOST_JAVA_LIBRARY)

# include jacoco-cli in the dist directory to enable running it to generate a code-coverage report
ifeq ($(ANDROID_COMPILE_WITH_JACK),false)
ifeq ($(EMMA_INSTRUMENT),true)
$(call dist-for-goals, dist_files, $(LOCAL_INSTALLED_MODULE))
endif
endif


#
# Build asm-5.0.1 as a static library for the device
#
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)


#
# Build asm-5.0.1 as a static library for the host
#
include $(CLEAR_VARS)

LOCAL_MODULE := jacoco-asm-host
LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := asm-debug-all-5.0.1$(COMMON_JAVA_PACKAGE_SUFFIX)

include $(BUILD_PREBUILT)