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 |
Narayan Kamath | bbcdc07 | 2017-08-22 15:47:08 +0100 | [diff] [blame] | 34 | dex_preopt_profile_src_file := $(common_javalib.jar) |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 35 | LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) |
| 36 | |
Ying Wang | ba71aba | 2013-03-26 12:42:32 -0700 | [diff] [blame] | 37 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 38 | LOCAL_PROGUARD_ENABLED := |
| 39 | endif |
| 40 | |
Ying Wang | af4800c | 2012-08-21 16:59:01 -0700 | [diff] [blame] | 41 | ifeq (true,$(EMMA_INSTRUMENT)) |
| 42 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 43 | ifeq (true,$(EMMA_INSTRUMENT_STATIC)) |
Sebastien Hertz | dfce8ad | 2015-11-19 17:53:00 +0100 | [diff] [blame] | 44 | LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent |
Colin Cross | dc4a6b8 | 2018-01-03 12:39:11 -0800 | [diff] [blame] | 45 | # Exclude jacoco classes from proguard |
| 46 | LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags |
Dan Willemsen | 829abae | 2019-08-09 09:14:45 -0700 | [diff] [blame] | 47 | LOCAL_PROGUARD_FLAGS_DEPS += $(BUILD_SYSTEM)/proguard.jacoco.flags |
Ying Wang | af4800c | 2012-08-21 16:59:01 -0700 | [diff] [blame] | 48 | endif # LOCAL_EMMA_INSTRUMENT |
| 49 | endif # EMMA_INSTRUMENT_STATIC |
| 50 | else |
| 51 | LOCAL_EMMA_INSTRUMENT := false |
| 52 | endif # EMMA_INSTRUMENT |
| 53 | |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 54 | my_dex_jar := $(common_javalib.jar) |
| 55 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 56 | ################################# |
| 57 | include $(BUILD_SYSTEM)/java.mk |
| 58 | ################################# |
| 59 | |
| 60 | ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 61 | # There are some dependencies outside the build system that assume classes.jar |
| 62 | # is available as javalib.jar so copy it there too. |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 63 | $(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(common_javalib.jar))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 64 | |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 65 | $(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(LOCAL_BUILT_MODULE))) |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 66 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 67 | else # !LOCAL_IS_STATIC_JAVA_LIBRARY |
| 68 | |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 69 | $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 70 | $(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar) |
Colin Cross | c9e4976 | 2018-09-14 13:39:07 -0700 | [diff] [blame] | 71 | $(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP) |
Dan Willemsen | f14179b | 2019-06-12 21:18:31 +0000 | [diff] [blame] | 72 | $(common_javalib.jar) : $(full_classes_pre_proguard_jar) $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 73 | @echo "target Jar: $(PRIVATE_MODULE) ($@)" |
Colin Cross | c9e4976 | 2018-09-14 13:39:07 -0700 | [diff] [blame] | 74 | rm -rf $@.parts && mkdir -p $@.parts |
| 75 | $(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE)) |
| 76 | $(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE)) |
| 77 | $(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip |
| 78 | rm -rf $@.parts |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 79 | $(hide) $(ZIPTIME) $@.tmp |
| 80 | $(call commit-change-for-toc,$@) |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 81 | ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) |
Nicolas Geoffray | a95fbd1 | 2017-09-19 13:10:31 +0100 | [diff] [blame] | 82 | $(uncompress-dexs) |
| 83 | $(align-package) |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 84 | endif # LOCAL_UNCOMPRESS_DEX |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 85 | |
| 86 | .KATI_RESTAT: $(common_javalib.jar) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 87 | |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 88 | $(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 89 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 90 | endif # !LOCAL_IS_STATIC_JAVA_LIBRARY |