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