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 | ########################################################### |
Dan Willemsen | 3bf15e7 | 2016-07-25 16:03:53 -0700 | [diff] [blame] | 5 | $(call record-module-type,JAVA_LIBRARY) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 6 | |
| 7 | ifdef LOCAL_IS_HOST_MODULE |
| 8 | $(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY) |
| 9 | endif |
| 10 | |
| 11 | LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX) |
| 12 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES |
| 13 | |
| 14 | ifneq (,$(LOCAL_ASSET_DIR)) |
| 15 | $(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR) |
| 16 | endif |
| 17 | |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 18 | ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 19 | ifneq (,$(LOCAL_RESOURCE_DIR)) |
| 20 | $(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR) |
| 21 | endif |
Ying Wang | 576e014 | 2013-08-28 11:16:06 -0700 | [diff] [blame] | 22 | # base_rules.mk looks at this |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 23 | all_res_assets := |
Ying Wang | 576e014 | 2013-08-28 11:16:06 -0700 | [diff] [blame] | 24 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 25 | |
| 26 | LOCAL_BUILT_MODULE_STEM := javalib.jar |
| 27 | |
Colin Cross | e673deb | 2017-09-27 14:28:41 -0700 | [diff] [blame] | 28 | # For java libraries, other modules should depend on |
| 29 | # out/target/common/obj/JAVA_LIBRARIES/.../classes.jar. |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 30 | # There are some dependencies outside the build system that assume static |
| 31 | # java libraries produce javalib.jar, so we will copy classes.jar there too. |
Ying Wang | 30090e4 | 2010-09-27 14:53:39 -0700 | [diff] [blame] | 32 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
Yohann Roussel | d2a76c1 | 2015-02-05 16:10:58 +0100 | [diff] [blame] | 33 | common_javalib.jar := $(intermediates.COMMON)/javalib.jar |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 34 | LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) |
| 35 | |
Ying Wang | ba71aba | 2013-03-26 12:42:32 -0700 | [diff] [blame] | 36 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 37 | LOCAL_PROGUARD_ENABLED := |
| 38 | endif |
| 39 | |
Ying Wang | af4800c | 2012-08-21 16:59:01 -0700 | [diff] [blame] | 40 | ifeq (true,$(EMMA_INSTRUMENT)) |
| 41 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 42 | ifeq (true,$(EMMA_INSTRUMENT_STATIC)) |
Sebastien Hertz | dfce8ad | 2015-11-19 17:53:00 +0100 | [diff] [blame] | 43 | LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent |
Ying Wang | af4800c | 2012-08-21 16:59:01 -0700 | [diff] [blame] | 44 | endif # LOCAL_EMMA_INSTRUMENT |
| 45 | endif # EMMA_INSTRUMENT_STATIC |
| 46 | else |
| 47 | LOCAL_EMMA_INSTRUMENT := false |
| 48 | endif # EMMA_INSTRUMENT |
| 49 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 50 | ################################# |
| 51 | include $(BUILD_SYSTEM)/java.mk |
| 52 | ################################# |
| 53 | |
| 54 | ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 55 | # There are some dependencies outside the build system that assume classes.jar |
| 56 | # is available as javalib.jar so copy it there too. |
Nan Zhang | 870025f | 2017-09-13 14:56:11 -0700 | [diff] [blame] | 57 | $(eval $(call copy-one-file,$(full_classes_proguard_jar),$(common_javalib.jar))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 58 | |
Nan Zhang | 870025f | 2017-09-13 14:56:11 -0700 | [diff] [blame] | 59 | $(eval $(call copy-one-file,$(full_classes_proguard_jar),$(LOCAL_BUILT_MODULE))) |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 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) |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 64 | $(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar) |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 65 | $(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) |
Dan Willemsen | 48a621c | 2015-10-29 16:33:05 -0700 | [diff] [blame] | 66 | $(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 67 | @echo "target Jar: $(PRIVATE_MODULE) ($@)" |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 68 | $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 69 | $(call add-dex-to-package-arg,$@.tmp) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 70 | $(hide) $(ZIPTIME) $@.tmp |
| 71 | $(call commit-change-for-toc,$@) |
| 72 | |
| 73 | .KATI_RESTAT: $(common_javalib.jar) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 74 | |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 75 | ifdef LOCAL_DEX_PREOPT |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 76 | ifneq ($(dexpreopt_boot_jar_module),) # boot jar |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 77 | # boot jar's rules are defined in dex_preopt.mk |
| 78 | dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 79 | $(eval $(call copy-one-file,$(dexpreopted_boot_jar),$(LOCAL_BUILT_MODULE))) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 80 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 81 | # For libart boot jars, we don't have .odex files. |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 82 | else # ! boot jar |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 83 | $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 84 | # Use pattern rule - we may have multiple built odex files. |
| 85 | $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 86 | @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 87 | $(call dexpreopt-one-file,$<,$@) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 88 | |
Colin Cross | ea1629e | 2017-10-06 13:55:48 -0700 | [diff] [blame] | 89 | $(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT))) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 90 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 91 | endif # ! boot jar |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 92 | |
| 93 | else # LOCAL_DEX_PREOPT |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 94 | $(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 95 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 96 | endif # LOCAL_DEX_PREOPT |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 97 | endif # !LOCAL_IS_STATIC_JAVA_LIBRARY |