The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | # |
| 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 Wren | d4b1d52 | 2013-10-02 13:30:27 -0400 | [diff] [blame] | 21 | ####################################### |
Narayan Kamath | 0dd273a | 2013-10-28 13:20:52 +0000 | [diff] [blame] | 22 | include $(BUILD_SYSTEM)/host_java_library_common.mk |
Ying Wang | 1ff0836 | 2013-12-27 15:55:08 -0800 | [diff] [blame] | 23 | ####################################### |
| 24 | |
| 25 | # Enable emma instrumentation only if the module asks so. |
| 26 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 27 | ifneq (true,$(EMMA_INSTRUMENT)) |
| 28 | LOCAL_EMMA_INSTRUMENT := |
| 29 | endif |
| 30 | endif |
| 31 | |
| 32 | full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar |
Neil Fuller | 432bdaa | 2016-03-02 11:19:41 +0000 | [diff] [blame] | 33 | full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar |
Ying Wang | 1ff0836 | 2013-12-27 15:55:08 -0800 | [diff] [blame] | 34 | emma_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 Fuller | 432bdaa | 2016-03-02 11:19:41 +0000 | [diff] [blame] | 37 | full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar)) |
Ying Wang | 1ff0836 | 2013-12-27 15:55:08 -0800 | [diff] [blame] | 38 | |
| 39 | LOCAL_INTERMEDIATE_TARGETS += \ |
| 40 | $(full_classes_compiled_jar) \ |
Neil Fuller | 432bdaa | 2016-03-02 11:19:41 +0000 | [diff] [blame] | 41 | $(full_classes_jarjar_jar) \ |
Ying Wang | 1ff0836 | 2013-12-27 15:55:08 -0800 | [diff] [blame] | 42 | $(full_classes_emma_jar) |
| 43 | |
| 44 | ####################################### |
Ying Wang | 50d7d7a | 2010-09-23 16:29:53 -0700 | [diff] [blame] | 45 | include $(BUILD_SYSTEM)/base_rules.mk |
Chris Wren | d4b1d52 | 2013-10-02 13:30:27 -0400 | [diff] [blame] | 46 | ####################################### |
Ying Wang | 50d7d7a | 2010-09-23 16:29:53 -0700 | [diff] [blame] | 47 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 48 | java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \ |
| 49 | $(filter %.java,$(LOCAL_GENERATED_SOURCES)) |
| 50 | all_java_sources := $(java_sources) |
| 51 | |
| 52 | include $(BUILD_SYSTEM)/java_common.mk |
Yohann Roussel | b518c3e | 2015-05-20 17:52:15 +0200 | [diff] [blame] | 53 | |
Joe Onorato | 9a6a326 | 2012-10-26 16:25:05 -0700 | [diff] [blame] | 54 | # The layers file allows you to enforce a layering between java packages. |
| 55 | # Run build/tools/java-layers.py for more details. |
| 56 | layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) |
| 57 | |
Ying Wang | 1ff0836 | 2013-12-27 15:55:08 -0800 | [diff] [blame] | 58 | $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) |
Ying Wang | 447d696 | 2015-09-01 19:12:05 -0700 | [diff] [blame] | 59 | $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) |
Ying Wang | 1ff0836 | 2013-12-27 15:55:08 -0800 | [diff] [blame] | 60 | $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := |
| 61 | $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := |
Jeff Brown | 4c4aa99 | 2014-05-23 18:41:19 -0700 | [diff] [blame] | 62 | $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 63 | $(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) \ |
Dan Albert | 954b5bd | 2014-11-08 22:20:03 -0800 | [diff] [blame] | 69 | $(LOCAL_ADDITIONAL_DEPENDENCIES) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 70 | $(transform-host-java-to-package) |
Neil Fuller | 432bdaa | 2016-03-02 11:19:41 +0000 | [diff] [blame] | 71 | |
Ying Wang | cddeb6c | 2016-03-24 11:00:30 -0700 | [diff] [blame^] | 72 | javac-check : $(full_classes_compiled_jar) |
| 73 | |
Neil Fuller | 432bdaa | 2016-03-02 11:19:41 +0000 | [diff] [blame] | 74 | # Run jarjar if necessary, otherwise just copy the file. |
| 75 | ifneq ($(strip $(LOCAL_JARJAR_RULES)),) |
| 76 | $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) |
| 77 | $(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) |
| 78 | @echo JarJar: $@ |
| 79 | $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ |
| 80 | else |
| 81 | $(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP) |
| 82 | @echo Copying: $@ |
| 83 | $(hide) $(ACP) -fp $< $@ |
| 84 | endif |
| 85 | |
| 86 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 87 | $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em |
| 88 | $(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir) |
| 89 | ifdef LOCAL_EMMA_COVERAGE_FILTER |
| 90 | $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER) |
| 91 | else |
| 92 | # by default, avoid applying emma instrumentation onto emma classes itself, |
| 93 | # otherwise there will be exceptions thrown |
| 94 | $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.* |
| 95 | endif |
| 96 | # this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and |
| 97 | # $(full_classes_emma_jar) |
| 98 | $(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR) |
| 99 | $(transform-classes.jar-to-emma) |
| 100 | |
| 101 | $(built_javalib_jar) : $(full_classes_emma_jar) |
| 102 | @echo Copying: $@ |
| 103 | $(hide) $(ACP) -fp $< $@ |
| 104 | |
| 105 | else # LOCAL_EMMA_INSTRUMENT |
| 106 | $(built_javalib_jar): $(full_classes_jarjar_jar) | $(ACP) |
| 107 | @echo Copying: $@ |
| 108 | $(hide) $(ACP) -fp $< $@ |
| 109 | endif # LOCAL_EMMA_INSTRUMENT |