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