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# List of dependencies for anything that needs all java sources in place 60java_sources_deps := \ 61 $(java_sources) \ 62 $(java_resource_sources) \ 63 $(LOCAL_SRCJARS) \ 64 $(LOCAL_ADDITIONAL_DEPENDENCIES) 65 66$(java_source_list_file): $(java_sources_deps) 67 $(write-java-source-list) 68 69# TODO(b/143658984): goma can't handle the --system argument to javac. 70#$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(GOMA_POOL) 71$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) 72$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := 73$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := 74$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := 75$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) 76$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list 77$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars 78$(full_classes_compiled_jar): \ 79 $(java_source_list_file) \ 80 $(java_sources_deps) \ 81 $(full_java_libs) \ 82 $(full_java_bootclasspath_libs) \ 83 $(annotation_processor_deps) \ 84 $(NORMALIZE_PATH) \ 85 $(ZIPTIME) \ 86 $(JAR_ARGS) \ 87 $(ZIPSYNC) \ 88 $(SOONG_ZIP) \ 89 | $(SOONG_JAVAC_WRAPPER) 90 $(transform-host-java-to-package) 91 $(remove-timestamps-from-package) 92 93javac-check : $(full_classes_compiled_jar) 94javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar) 95.PHONY: javac-check-$(LOCAL_MODULE) 96 97$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) 98$(full_classes_combined_jar): $(full_classes_compiled_jar) \ 99 $(jar_manifest_file) \ 100 $(full_static_java_libs) | $(MERGE_ZIPS) 101 $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(PRIVATE_JAR_MANIFEST)) \ 102 $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \ 103 $@ $< $(PRIVATE_STATIC_JAVA_LIBRARIES) 104 105# Run jarjar if necessary, otherwise just copy the file. 106ifneq ($(strip $(LOCAL_JARJAR_RULES)),) 107$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) 108$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) 109 $(call transform-jarjar) 110else 111full_classes_jarjar_jar := $(full_classes_combined_jar) 112endif 113 114 115####################################### 116LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jarjar_jar) 117 118include $(BUILD_SYSTEM)/jacoco.mk 119####################################### 120 121$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(LOCAL_BUILT_MODULE))) 122$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_jar))) 123 124ifeq ($(TURBINE_ENABLED),false) 125$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_header_jar))) 126endif 127