The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | ########################################################### |
| 2 | ## Standard rules for building a java library. |
| 3 | ## |
| 4 | ########################################################### |
| 5 | |
| 6 | ifdef LOCAL_IS_HOST_MODULE |
| 7 | $(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY) |
| 8 | endif |
| 9 | |
| 10 | LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX) |
| 11 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES |
| 12 | |
| 13 | ifneq (,$(LOCAL_ASSET_DIR)) |
| 14 | $(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR) |
| 15 | endif |
| 16 | |
| 17 | ifneq (,$(LOCAL_RESOURCE_DIR)) |
| 18 | $(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR) |
| 19 | endif |
| 20 | |
| 21 | #xxx base_rules.mk looks at this |
| 22 | all_res_assets := |
| 23 | |
| 24 | LOCAL_BUILT_MODULE_STEM := javalib.jar |
| 25 | |
Ying Wang | 30090e4 | 2010-09-27 14:53:39 -0700 | [diff] [blame] | 26 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
| 27 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 28 | # This file will be the one that other modules should depend on. |
| 29 | common_javalib.jar := $(intermediates.COMMON)/$(LOCAL_BUILT_MODULE_STEM) |
| 30 | LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) |
| 31 | |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 32 | ifneq (true,$(WITH_DEXPREOPT)) |
| 33 | LOCAL_DEX_PREOPT := |
| 34 | else |
Ying Wang | 94978cf | 2011-01-12 11:12:06 -0800 | [diff] [blame] | 35 | ifeq (,$(TARGET_BUILD_APPS)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 36 | ifndef LOCAL_DEX_PREOPT |
| 37 | LOCAL_DEX_PREOPT := true |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 38 | endif |
| 39 | endif |
Ying Wang | 94978cf | 2011-01-12 11:12:06 -0800 | [diff] [blame] | 40 | endif |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 41 | ifeq (false,$(LOCAL_DEX_PREOPT)) |
| 42 | LOCAL_DEX_PREOPT := |
| 43 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 44 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 45 | ################################# |
| 46 | include $(BUILD_SYSTEM)/java.mk |
| 47 | ################################# |
| 48 | |
| 49 | ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) |
Brian Carlstrom | bb7c6d8 | 2011-04-01 15:45:58 -0700 | [diff] [blame] | 50 | # No dex; all we want are the .class files with resources. |
| 51 | $(common_javalib.jar) : $(full_classes_jar) $(java_resource_sources) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | @echo "target Static Jar: $(PRIVATE_MODULE) ($@)" |
| 53 | $(copy-file-to-target) |
Brian Carlstrom | bb7c6d8 | 2011-04-01 15:45:58 -0700 | [diff] [blame] | 54 | ifneq ($(extra_jar_args),) |
| 55 | $(add-java-resources-to-package) |
| 56 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 57 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 58 | $(LOCAL_BUILT_MODULE): $(common_javalib.jar) |
| 59 | $(copy-file-to-target) |
| 60 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 61 | else # !LOCAL_IS_STATIC_JAVA_LIBRARY |
| 62 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 63 | $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) |
| 64 | $(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(AAPT) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 65 | @echo "target Jar: $(PRIVATE_MODULE) ($@)" |
| 66 | $(create-empty-package) |
| 67 | $(add-dex-to-package) |
| 68 | ifneq ($(extra_jar_args),) |
| 69 | $(add-java-resources-to-package) |
| 70 | endif |
| 71 | |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 72 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 73 | dexpreopt_boot_jar_module := $(filter $(LOCAL_MODULE),$(DEXPREOPT_BOOT_JARS_MODULES)) |
| 74 | ifneq ($(dexpreopt_boot_jar_module),) |
| 75 | # boot jar's rules are defined in dex_preopt.mk |
| 76 | dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar |
| 77 | $(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP) |
| 78 | $(call copy-file-to-target) |
| 79 | |
| 80 | dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex |
| 81 | built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex |
| 82 | $(built_odex) : $(dexpreopted_boot_odex) | $(ACP) |
| 83 | $(call copy-file-to-target) |
| 84 | |
| 85 | else # dexpreopt_boot_jar_module |
| 86 | built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex |
| 87 | $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 88 | # Make sure the boot jars get dex-preopt-ed first |
| 89 | $(built_odex) : $(DEXPREOPT_BOOT_ODEXS) |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 90 | $(built_odex) : $(common_javalib.jar) | $(DEXPREOPT) $(DEXOPT) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 91 | @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" |
| 92 | $(hide) rm -f $@ |
| 93 | $(call dexpreopt-one-file,$<,$@) |
| 94 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 95 | $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) $(AAPT) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 96 | $(call copy-file-to-target) |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 97 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 98 | $(call dexpreopt-remove-classes.dex,$@) |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 99 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 100 | |
| 101 | endif # dexpreopt_boot_jar_module |
| 102 | |
| 103 | else # LOCAL_DEX_PREOPT |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 104 | $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) |
| 105 | $(call copy-file-to-target) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 106 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 107 | endif # LOCAL_DEX_PREOPT |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 108 | endif # !LOCAL_IS_STATIC_JAVA_LIBRARY |