1# 2# Copyright (C) 2013 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# 18# Rules for building a host dalvik java library. These libraries 19# are meant to be used by a dalvik VM instance running on the host. 20# They will be compiled against libcore and not the host JRE. 21# 22 23ifeq ($(HOST_OS),linux) 24USE_CORE_LIB_BOOTCLASSPATH := true 25 26####################################### 27include $(BUILD_SYSTEM)/host_java_library_common.mk 28####################################### 29 30ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 31 LOCAL_JAVA_LIBRARIES += core-libart-hostdex 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 37full_classes_jack := $(intermediates.COMMON)/classes.jack 38built_dex := $(intermediates.COMMON)/classes.dex 39 40LOCAL_INTERMEDIATE_TARGETS += \ 41 $(full_classes_compiled_jar) \ 42 $(full_classes_jarjar_jar) \ 43 $(full_classes_jack) \ 44 $(full_classes_jar) \ 45 $(built_dex) 46 47# See comment in java.mk 48java_alternative_checked_module := $(full_classes_compiled_jar) 49 50####################################### 51include $(BUILD_SYSTEM)/base_rules.mk 52####################################### 53 54$(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g 55 56java_alternative_checked_module := 57 58# The layers file allows you to enforce a layering between java packages. 59# Run build/tools/java-layers.py for more details. 60layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) 61 62$(LOCAL_INTERMEDIATE_TARGETS): \ 63 PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes 64$(LOCAL_INTERMEDIATE_TARGETS): \ 65 PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) 66$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := 67 68$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON) 69 70$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) 71$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) 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): \ 76 $(java_sources) \ 77 $(java_resource_sources) \ 78 $(full_java_lib_deps) \ 79 $(jar_manifest_file) \ 80 $(proto_java_sources_file_stamp) \ 81 $(LOCAL_MODULE_MAKEFILE) \ 82 $(LOCAL_ADDITIONAL_DEPENDENCIES) 83 $(transform-host-java-to-package) 84 85# Run jarjar if necessary, otherwise just copy the file. 86ifneq ($(strip $(LOCAL_JARJAR_RULES)),) 87$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) 88$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) 89 @echo JarJar: $@ 90 $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ 91else 92$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP) 93 @echo Copying: $@ 94 $(hide) $(ACP) -fp $< $@ 95endif 96 97$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP) 98 @echo Copying: $@ 99 $(hide) $(ACP) -fp $< $@ 100 101ifndef LOCAL_JACK_ENABLED 102$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON) 103$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) 104$(built_dex): $(full_classes_jar) $(DX) 105 $(transform-classes.jar-to-dex) 106 107$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) 108$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) 109$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) 110$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) 111 @echo "Host Jar: $(PRIVATE_MODULE) ($@)" 112 $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@) 113 $(add-dex-to-package) 114 115else # LOCAL_JACK_ENABLED 116$(LOCAL_INTERMEDIATE_TARGETS): \ 117 PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc 118 119ifeq ($(LOCAL_JACK_ENABLED),incremental) 120$(LOCAL_INTERMEDIATE_TARGETS): \ 121 PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental 122else 123$(LOCAL_INTERMEDIATE_TARGETS): \ 124 PRIVATE_JACK_INCREMENTAL_DIR := 125endif 126$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_DEBUG_FLAGS := -g 127 128$(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack) 129$(built_dex): PRIVATE_JACK_FLAGS := $(LOCAL_JACK_FLAGS) 130$(built_dex): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \ 131 $(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_MODULE_MAKEFILE) \ 132 $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK_JAR) $(JACK_LAUNCHER_JAR) 133 @echo Building with Jack: $@ 134 $(jack-java-to-dex) 135 136# $(full_classes_jack) is just by-product of $(built_dex). 137# The dummy command was added because, without it, make misses the fact the $(built_dex) also 138# change $(full_classes_jack). 139$(full_classes_jack): $(built_dex) 140 $(hide) touch $@ 141 142$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) 143$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) 144 @echo "Host Jar: $(PRIVATE_MODULE) ($@)" 145 $(create-empty-package) 146 $(add-dex-to-package) 147 $(add-carried-jack-resources) 148 149endif # LOCAL_JACK_ENABLED 150 151USE_CORE_LIB_BOOTCLASSPATH := 152 153endif 154