blob: 97079fd37843d2827b7de0d2661b0aa6a1c87a02 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001#
2# Copyright (C) 2008 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#
16
17#
18# Standard rules for building a host java library.
19#
20
Chris Wrend4b1d522013-10-02 13:30:27 -040021#######################################
Narayan Kamath0dd273a2013-10-28 13:20:52 +000022include $(BUILD_SYSTEM)/host_java_library_common.mk
Ying Wang1ff08362013-12-27 15:55:08 -080023#######################################
24
25# Enable emma instrumentation only if the module asks so.
26ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
27ifneq (true,$(EMMA_INSTRUMENT))
28LOCAL_EMMA_INSTRUMENT :=
29endif
30endif
31
32full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
Neil Fuller432bdaa2016-03-02 11:19:41 +000033full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
Ying Wang1ff08362013-12-27 15:55:08 -080034emma_intermediates_dir := $(intermediates.COMMON)/emma_out
35# emma is hardcoded to use the leaf name of its input for the output file --
36# only the output directory can be changed
Neil Fuller432bdaa2016-03-02 11:19:41 +000037full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar))
Ying Wang1ff08362013-12-27 15:55:08 -080038
39LOCAL_INTERMEDIATE_TARGETS += \
40 $(full_classes_compiled_jar) \
Neil Fuller432bdaa2016-03-02 11:19:41 +000041 $(full_classes_jarjar_jar) \
Ying Wang1ff08362013-12-27 15:55:08 -080042 $(full_classes_emma_jar)
43
44#######################################
Ying Wang50d7d7a2010-09-23 16:29:53 -070045include $(BUILD_SYSTEM)/base_rules.mk
Chris Wrend4b1d522013-10-02 13:30:27 -040046#######################################
Ying Wang50d7d7a2010-09-23 16:29:53 -070047
Ying Wang956dccc2015-08-28 11:47:03 -070048java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \
49 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
50all_java_sources := $(java_sources)
51
52include $(BUILD_SYSTEM)/java_common.mk
Yohann Rousselb518c3e2015-05-20 17:52:15 +020053
Joe Onorato9a6a3262012-10-26 16:25:05 -070054# The layers file allows you to enforce a layering between java packages.
55# Run build/tools/java-layers.py for more details.
56layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
57
Ying Wang1ff08362013-12-27 15:55:08 -080058$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
Ying Wang447d6962015-09-01 19:12:05 -070059$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
Ying Wang1ff08362013-12-27 15:55:08 -080060$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
61$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
Jeff Brown4c4aa992014-05-23 18:41:19 -070062$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
Dan Albert954b5bd2014-11-08 22:20:03 -080063$(full_classes_compiled_jar): \
64 $(java_sources) \
65 $(java_resource_sources) \
66 $(full_java_lib_deps) \
67 $(jar_manifest_file) \
68 $(proto_java_sources_file_stamp) \
Colin Crossa4447e82015-09-28 16:26:00 -070069 $(LOCAL_MODULE_MAKEFILE_DEP) \
Dan Albert954b5bd2014-11-08 22:20:03 -080070 $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -080071 $(transform-host-java-to-package)
Neil Fuller432bdaa2016-03-02 11:19:41 +000072
73# Run jarjar if necessary, otherwise just copy the file.
74ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
75$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
76$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
77 @echo JarJar: $@
78 $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
79else
80$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
81 @echo Copying: $@
82 $(hide) $(ACP) -fp $< $@
83endif
84
85ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
86$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
87$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
88ifdef LOCAL_EMMA_COVERAGE_FILTER
89$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER)
90else
91# by default, avoid applying emma instrumentation onto emma classes itself,
92# otherwise there will be exceptions thrown
93$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.*
94endif
95# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
96# $(full_classes_emma_jar)
97$(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
98 $(transform-classes.jar-to-emma)
99
100$(built_javalib_jar) : $(full_classes_emma_jar)
101 @echo Copying: $@
102 $(hide) $(ACP) -fp $< $@
103
104else # LOCAL_EMMA_INSTRUMENT
105$(built_javalib_jar): $(full_classes_jarjar_jar) | $(ACP)
106 @echo Copying: $@
107 $(hide) $(ACP) -fp $< $@
108endif # LOCAL_EMMA_INSTRUMENT
109