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####################################### 24include $(BUILD_SYSTEM)/host_java_library_common.mk 25####################################### 26 27# Enable emma instrumentation only if the module asks so. 28ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) 29ifneq (true,$(EMMA_INSTRUMENT)) 30LOCAL_EMMA_INSTRUMENT := 31endif 32endif 33 34full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar 35full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar 36full_classes_jar := $(intermediates.COMMON)/classes.jar 37java_source_list_file := $(intermediates.COMMON)/java-source-list 38full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar 39full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar 40 41LOCAL_INTERMEDIATE_TARGETS += \ 42 $(full_classes_compiled_jar) \ 43 $(full_classes_jarjar_jar) \ 44 $(java_source_list_file) \ 45 $(full_classes_combined_jar) 46 47####################################### 48include $(BUILD_SYSTEM)/base_rules.mk 49####################################### 50 51java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \ 52 $(filter %.java,$(LOCAL_GENERATED_SOURCES)) 53all_java_sources := $(java_sources) 54 55include $(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. 59layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) 60 61# List of dependencies for anything that needs all java sources in place 62java_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 94javac-check : $(full_classes_compiled_jar) 95javac-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. 107ifneq ($(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) $< $@ 112else 113full_classes_jarjar_jar := $(full_classes_combined_jar) 114endif 115 116 117####################################### 118LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jarjar_jar) 119 120include $(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 126ifeq ($(TURBINE_ENABLED),false) 127$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_header_jar))) 128endif 129