Home | History | Annotate | Download | only in core
      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 #
     18 # Standard rules for building a host java library.
     19 #
     20 
     21 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
     22 LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
     23 LOCAL_IS_HOST_MODULE := true
     24 LOCAL_BUILT_MODULE_STEM := javalib.jar
     25 
     26 ifeq ($(LOCAL_BUILD_HOST_DEX),true)
     27 intermediates := $(call local-intermediates-dir)
     28 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
     29 
     30 full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
     31 full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
     32 full_classes_jar := $(intermediates.COMMON)/classes.jar
     33 built_dex := $(intermediates.COMMON)/classes.dex
     34 
     35 LOCAL_INTERMEDIATE_TARGETS += \
     36     $(full_classes_compiled_jar) \
     37     $(full_classes_jarjar_jar) \
     38     $(full_classes_jar) \
     39     $(built_dex)
     40 
     41 LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
     42 endif # LOCAL_BUILD_HOST_DEX
     43 
     44 include $(BUILD_SYSTEM)/base_rules.mk
     45 
     46 ifeq ($(LOCAL_BUILD_HOST_DEX),true)
     47 $(LOCAL_INTERMEDIATE_TARGETS): \
     48 	PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
     49 $(LOCAL_INTERMEDIATE_TARGETS): \
     50 	PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
     51 
     52 $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
     53 
     54 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
     55 $(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
     56 	$(transform-host-java-to-package)
     57 
     58 # Run jarjar if necessary, otherwise just copy the file.
     59 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
     60 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
     61 $(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(JARJAR)
     62 	@echo JarJar: $@
     63 	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
     64 else
     65 $(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
     66 	@echo Copying: $@
     67 	$(hide) $(ACP) -fp $< $@
     68 endif
     69 
     70 $(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
     71 	@echo Copying: $@
     72 	$(hide) $(ACP) -fp $< $@
     73 
     74 $(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
     75 $(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
     76 $(built_dex): $(full_classes_jar) $(DX)
     77 	$(transform-classes.jar-to-dex)
     78 
     79 $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
     80 $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) | $(AAPT)
     81 	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
     82 	$(create-empty-package)
     83 	$(add-dex-to-package)
     84 ifneq ($(extra_jar_args),)
     85 	$(add-java-resources-to-package)
     86 endif
     87 
     88 else
     89 $(LOCAL_BUILT_MODULE): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
     90 $(LOCAL_BUILT_MODULE): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
     91 	$(transform-host-java-to-package)
     92 endif  # LOCAL_BUILD_HOST_DEX
     93