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 $(call record-module-type,HOST_JAVA_LIBRARY) 18 19 # 20 # Standard rules for building a host java library. 21 # 22 23 ####################################### 24 include $(BUILD_SYSTEM)/host_java_library_common.mk 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 35 full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar 36 full_classes_jar := $(intermediates.COMMON)/classes.jar 37 java_source_list_file := $(intermediates.COMMON)/java-source-list 38 full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar 39 full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar 40 41 LOCAL_INTERMEDIATE_TARGETS += \ 42 $(full_classes_compiled_jar) \ 43 $(full_classes_jarjar_jar) \ 44 $(java_source_list_file) \ 45 $(full_classes_combined_jar) 46 47 ####################################### 48 include $(BUILD_SYSTEM)/base_rules.mk 49 ####################################### 50 51 java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \ 52 $(filter %.java,$(LOCAL_GENERATED_SOURCES)) 53 all_java_sources := $(java_sources) 54 55 include $(BUILD_SYSTEM)/java_common.mk 56 57 # The layers file allows you to enforce a layering between java packages. 58 # Run build/make/tools/java-layers.py for more details. 59 layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) 60 61 # List of dependencies for anything that needs all java sources in place 62 java_sources_deps := \ 63 $(java_sources) \ 64 $(java_resource_sources) \ 65 $(proto_java_sources_file_stamp) \ 66 $(LOCAL_SRCJARS) \ 67 $(LOCAL_ADDITIONAL_DEPENDENCIES) 68 69 $(java_source_list_file): $(java_sources_deps) 70 $(write-java-source-list) 71 72 $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) 73 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) 74 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := 75 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := 76 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := 77 $(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) 78 $(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list 79 $(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars 80 $(full_classes_compiled_jar): \ 81 $(java_source_list_file) \ 82 $(java_sources_deps) \ 83 $(full_java_libs) \ 84 $(full_java_bootclasspath_libs) \ 85 $(annotation_processor_deps) \ 86 $(NORMALIZE_PATH) \ 87 $(ZIPTIME) \ 88 $(JAR_ARGS) \ 89 $(ZIPSYNC) \ 90 | $(SOONG_JAVAC_WRAPPER) 91 $(transform-host-java-to-package) 92 $(remove-timestamps-from-package) 93 94 javac-check : $(full_classes_compiled_jar) 95 javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar) 96 .PHONY: javac-check-$(LOCAL_MODULE) 97 98 $(full_classes_combined_jar): $(full_classes_compiled_jar) \ 99 $(jar_manifest_file) \ 100 $(full_static_java_libs) | $(MERGE_ZIPS) 101 $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ 102 $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) 103 $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ 104 -stripDir META-INF -zipToNotStrip $< $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES)) 105 106 # Run jarjar if necessary, otherwise just copy the file. 107 ifneq ($(strip $(LOCAL_JARJAR_RULES)),) 108 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) 109 $(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) 110 @echo JarJar: $@ 111 $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ 112 else 113 full_classes_jarjar_jar := $(full_classes_combined_jar) 114 endif 115 116 117 ####################################### 118 LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jarjar_jar) 119 120 include $(BUILD_SYSTEM)/jacoco.mk 121 ####################################### 122 123 $(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(LOCAL_BUILT_MODULE))) 124 $(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_jar))) 125 126 ifeq ($(TURBINE_ENABLED),false) 127 $(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_header_jar))) 128 endif 129