2009-03-04 11:28:42 +08:00
|
|
|
###########################################################
|
|
|
|
## Standard rules for building a java library.
|
|
|
|
##
|
|
|
|
###########################################################
|
2016-07-26 07:03:53 +08:00
|
|
|
$(call record-module-type,JAVA_LIBRARY)
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
|
|
$(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY)
|
|
|
|
endif
|
|
|
|
|
|
|
|
LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
|
|
|
|
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
|
|
|
|
|
|
|
ifneq (,$(LOCAL_ASSET_DIR))
|
|
|
|
$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR)
|
|
|
|
endif
|
|
|
|
|
2011-12-15 06:29:28 +08:00
|
|
|
ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY))
|
2009-03-04 11:28:42 +08:00
|
|
|
ifneq (,$(LOCAL_RESOURCE_DIR))
|
|
|
|
$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR)
|
|
|
|
endif
|
2013-08-29 02:16:06 +08:00
|
|
|
# base_rules.mk looks at this
|
2009-03-04 11:28:42 +08:00
|
|
|
all_res_assets :=
|
2013-08-29 02:16:06 +08:00
|
|
|
endif
|
2009-03-04 11:28:42 +08:00
|
|
|
|
|
|
|
LOCAL_BUILT_MODULE_STEM := javalib.jar
|
|
|
|
|
2015-02-05 23:10:58 +08:00
|
|
|
#################################
|
|
|
|
include $(BUILD_SYSTEM)/configure_local_jack.mk
|
|
|
|
#################################
|
|
|
|
|
2016-12-22 06:29:13 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
2015-02-05 23:10:58 +08:00
|
|
|
ifdef LOCAL_IS_STATIC_JAVA_LIBRARY
|
|
|
|
LOCAL_BUILT_MODULE_STEM := classes.jack
|
|
|
|
endif
|
2016-12-22 06:29:13 +08:00
|
|
|
endif
|
2015-02-05 23:10:58 +08:00
|
|
|
|
2010-09-28 05:53:39 +08:00
|
|
|
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
|
|
|
|
|
2010-09-25 09:09:04 +08:00
|
|
|
# This file will be the one that other modules should depend on.
|
2015-02-05 23:10:58 +08:00
|
|
|
common_javalib.jar := $(intermediates.COMMON)/javalib.jar
|
2010-09-25 09:09:04 +08:00
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
|
|
|
|
|
2013-03-27 03:42:32 +08:00
|
|
|
ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
|
|
|
|
LOCAL_PROGUARD_ENABLED :=
|
|
|
|
endif
|
|
|
|
|
2012-08-22 07:59:01 +08:00
|
|
|
ifeq (true,$(EMMA_INSTRUMENT))
|
|
|
|
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
|
|
|
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
|
2016-12-22 06:29:13 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
2015-11-20 00:53:00 +08:00
|
|
|
# Jack supports coverage with Jacoco
|
|
|
|
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
2016-12-22 06:29:13 +08:00
|
|
|
else
|
|
|
|
LOCAL_STATIC_JAVA_LIBRARIES += emma
|
|
|
|
endif # LOCAL_JACK_ENABLED
|
2012-08-22 07:59:01 +08:00
|
|
|
endif # LOCAL_EMMA_INSTRUMENT
|
|
|
|
endif # EMMA_INSTRUMENT_STATIC
|
|
|
|
else
|
|
|
|
LOCAL_EMMA_INSTRUMENT := false
|
|
|
|
endif # EMMA_INSTRUMENT
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
#################################
|
|
|
|
include $(BUILD_SYSTEM)/java.mk
|
|
|
|
#################################
|
|
|
|
|
|
|
|
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
|
2011-04-02 06:45:58 +08:00
|
|
|
# No dex; all we want are the .class files with resources.
|
2013-03-27 03:42:32 +08:00
|
|
|
$(common_javalib.jar) : $(java_resource_sources)
|
|
|
|
$(common_javalib.jar) : $(full_classes_jar)
|
2009-03-04 11:28:42 +08:00
|
|
|
@echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
|
2016-12-22 06:29:13 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
2015-02-05 23:10:58 +08:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(full_classes_jack)
|
2016-12-22 06:29:13 +08:00
|
|
|
else
|
|
|
|
$(LOCAL_BUILT_MODULE) : $(common_javalib.jar)
|
|
|
|
endif
|
2010-09-25 09:09:04 +08:00
|
|
|
$(copy-file-to-target)
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
else # !LOCAL_IS_STATIC_JAVA_LIBRARY
|
|
|
|
|
2010-09-25 09:09:04 +08:00
|
|
|
$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
|
2017-04-06 06:30:42 +08:00
|
|
|
$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
|
2016-12-22 06:29:13 +08:00
|
|
|
$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
|
2015-10-30 07:33:05 +08:00
|
|
|
$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME)
|
2010-09-18 07:36:06 +08:00
|
|
|
@echo "target Jar: $(PRIVATE_MODULE) ($@)"
|
2016-12-22 06:29:13 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
2010-09-18 07:36:06 +08:00
|
|
|
$(create-empty-package)
|
2016-12-22 06:29:13 +08:00
|
|
|
else
|
|
|
|
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
|
|
|
|
endif
|
Running jarjar on Java resources.
Before this change, Java resources are added as a separate step
(add-java-resources-to-package) after dex is run, so jarjar isn't run on
the resource files.
With this change, we add Java resources immediately after we call javac,
so jarjar is run on the resource files (the module's own resource, as
well as resources carried by static Java libraries).
When we generate the final apk/jar, we use the jarjar'ed jar as the
inital pacakge file, with class files and empty folders removed.
When jack is enabled, in jack-java-to-dex we add the Java resources to
a temp jar using the PRIVATE_EXTRA_JAR_ARGS, and extrac the files in a
temp dir. Jack will process the resource files and output the result to
PRIVATE_JACK_INTERMEDIATES_DIR. When we package the final apk/jar, we
need to call add-carried-jack-resources to readd the resources.
(TODO: if jack can output all resources to a jar/zip file, we can use
that file as the initial package file as well.)
Bug: 18837479
Change-Id: I8d7296e30ec8d005054cf04c4f2aed6d7a0d823b
2015-01-15 06:23:56 +08:00
|
|
|
$(add-dex-to-package)
|
2016-12-22 06:29:13 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
Running jarjar on Java resources.
Before this change, Java resources are added as a separate step
(add-java-resources-to-package) after dex is run, so jarjar isn't run on
the resource files.
With this change, we add Java resources immediately after we call javac,
so jarjar is run on the resource files (the module's own resource, as
well as resources carried by static Java libraries).
When we generate the final apk/jar, we use the jarjar'ed jar as the
inital pacakge file, with class files and empty folders removed.
When jack is enabled, in jack-java-to-dex we add the Java resources to
a temp jar using the PRIVATE_EXTRA_JAR_ARGS, and extrac the files in a
temp dir. Jack will process the resource files and output the result to
PRIVATE_JACK_INTERMEDIATES_DIR. When we package the final apk/jar, we
need to call add-carried-jack-resources to readd the resources.
(TODO: if jack can output all resources to a jar/zip file, we can use
that file as the initial package file as well.)
Bug: 18837479
Change-Id: I8d7296e30ec8d005054cf04c4f2aed6d7a0d823b
2015-01-15 06:23:56 +08:00
|
|
|
$(add-carried-jack-resources)
|
2016-12-22 06:29:13 +08:00
|
|
|
endif
|
2015-10-30 07:33:05 +08:00
|
|
|
$(remove-timestamps-from-package)
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2011-10-25 03:17:03 +08:00
|
|
|
ifdef LOCAL_DEX_PREOPT
|
2013-11-15 15:44:56 +08:00
|
|
|
ifneq ($(dexpreopt_boot_jar_module),) # boot jar
|
2010-09-18 07:36:06 +08:00
|
|
|
# boot jar's rules are defined in dex_preopt.mk
|
|
|
|
dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
|
2016-03-01 09:52:39 +08:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar)
|
2010-09-18 07:36:06 +08:00
|
|
|
$(call copy-file-to-target)
|
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
# For libart boot jars, we don't have .odex files.
|
|
|
|
else # ! boot jar
|
2010-09-18 07:36:06 +08:00
|
|
|
$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
|
2014-05-14 04:57:28 +08:00
|
|
|
# Use pattern rule - we may have multiple built odex files.
|
|
|
|
$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar)
|
2010-09-18 07:36:06 +08:00
|
|
|
@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
|
2014-05-14 04:57:28 +08:00
|
|
|
$(call dexpreopt-one-file,$<,$@)
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2016-03-01 09:52:39 +08:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(common_javalib.jar)
|
2010-09-18 07:36:06 +08:00
|
|
|
$(call copy-file-to-target)
|
2011-10-25 03:17:03 +08:00
|
|
|
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
|
2010-09-18 07:36:06 +08:00
|
|
|
$(call dexpreopt-remove-classes.dex,$@)
|
2011-10-25 03:17:03 +08:00
|
|
|
endif
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
endif # ! boot jar
|
2010-09-18 07:36:06 +08:00
|
|
|
|
|
|
|
else # LOCAL_DEX_PREOPT
|
2016-03-01 09:52:39 +08:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(common_javalib.jar)
|
2010-09-25 09:09:04 +08:00
|
|
|
$(call copy-file-to-target)
|
2009-03-04 11:28:42 +08:00
|
|
|
|
2010-09-25 09:09:04 +08:00
|
|
|
endif # LOCAL_DEX_PREOPT
|
2009-03-04 11:28:42 +08:00
|
|
|
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
|