2014-12-02 02:46:56 +01:00
|
|
|
# Set up rules to build dpi-specific apk, with whatever else from the base apk.
|
|
|
|
# Input variable: my_dpi, and all other variables set up in package_internal.mk.
|
|
|
|
#
|
|
|
|
|
|
|
|
dpi_apk_name := $(LOCAL_MODULE)_$(my_dpi)
|
|
|
|
dpi_intermediate := $(call intermediates-dir-for,APPS,$(dpi_apk_name))
|
|
|
|
built_dpi_apk := $(dpi_intermediate)/package.apk
|
2016-05-13 09:03:24 +02:00
|
|
|
additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
|
2014-12-02 02:46:56 +01:00
|
|
|
|
|
|
|
# Set up all the target-specific variables.
|
|
|
|
$(built_dpi_apk): PRIVATE_MODULE := $(dpi_apk_name)
|
2017-10-28 01:10:18 +02:00
|
|
|
$(built_dpi_apk): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --pseudo-localize $($(LOCAL_PACKAGE_NAME)_aapt_flags_$(my_dpi))
|
2014-12-02 02:46:56 +01:00
|
|
|
# Clear PRIVATE_PRODUCT_AAPT_CONFIG to include everything by default.
|
|
|
|
$(built_dpi_apk): PRIVATE_PRODUCT_AAPT_CONFIG :=
|
|
|
|
$(built_dpi_apk): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(my_dpi)
|
|
|
|
$(built_dpi_apk): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
|
|
|
|
$(built_dpi_apk): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
|
|
|
|
$(built_dpi_apk): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
|
|
|
|
$(built_dpi_apk): PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
|
2017-10-02 23:22:02 +02:00
|
|
|
$(built_dpi_apk): PRIVATE_RESOURCE_LIST := $(all_res_assets)
|
2018-01-30 16:14:55 +01:00
|
|
|
ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
|
2017-10-16 12:20:34 +02:00
|
|
|
$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
|
2014-12-02 02:46:56 +01:00
|
|
|
else
|
|
|
|
$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
|
|
|
|
endif
|
|
|
|
$(built_dpi_apk): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
|
|
|
|
$(built_dpi_apk): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_INSTRUMENTATION_FOR)
|
|
|
|
$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
|
|
|
|
$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
|
|
|
|
$(built_dpi_apk): PRIVATE_PRIVATE_KEY := $(private_key)
|
|
|
|
$(built_dpi_apk): PRIVATE_CERTIFICATE := $(certificate)
|
2016-05-13 09:03:24 +02:00
|
|
|
$(built_dpi_apk): $(additional_certificates)
|
|
|
|
$(built_dpi_apk): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
|
2014-12-02 02:46:56 +01:00
|
|
|
|
2016-12-21 23:29:13 +01:00
|
|
|
$(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE :=
|
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-14 23:23:56 +01:00
|
|
|
ifneq ($(full_classes_jar),)
|
2016-03-29 03:39:42 +02:00
|
|
|
$(built_dpi_apk): PRIVATE_DEX_FILE := $(built_dex)
|
2016-12-21 23:29:13 +01:00
|
|
|
# Use the jarjar processed arhive as the initial package file.
|
2017-03-29 21:58:15 +02:00
|
|
|
$(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
|
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-14 23:23:56 +01:00
|
|
|
$(built_dpi_apk): $(built_dex)
|
|
|
|
else
|
|
|
|
$(built_dpi_apk): PRIVATE_DEX_FILE :=
|
|
|
|
endif # full_classes_jar
|
|
|
|
|
2014-12-02 02:46:56 +01:00
|
|
|
# Set up dependenncies and the build recipe.
|
|
|
|
$(built_dpi_apk) : $(R_file_stamp)
|
|
|
|
$(built_dpi_apk) : $(all_library_res_package_export_deps)
|
|
|
|
$(built_dpi_apk) : $(private_key) $(certificate) $(SIGNAPK_JAR)
|
2015-12-04 19:07:41 +01:00
|
|
|
$(built_dpi_apk) : $(AAPT)
|
2014-12-02 02:46:56 +01:00
|
|
|
$(built_dpi_apk) : $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
|
|
|
|
@echo "target Package: $(PRIVATE_MODULE) ($@)"
|
2016-12-21 23:29:13 +01:00
|
|
|
$(if $(PRIVATE_SOURCE_ARCHIVE),\
|
|
|
|
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
|
|
|
|
$(create-empty-package))
|
2014-12-02 02:46:56 +01:00
|
|
|
$(add-assets-to-package)
|
|
|
|
ifneq ($(jni_shared_libraries),)
|
|
|
|
$(add-jni-shared-libs-to-package)
|
|
|
|
endif
|
2015-03-27 19:07:17 +01:00
|
|
|
ifeq ($(full_classes_jar),)
|
|
|
|
# We don't build jar, need to add the Java resources here.
|
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
|
|
|
|
else
|
2014-12-02 02:46:56 +01:00
|
|
|
$(add-dex-to-package)
|
|
|
|
endif
|
|
|
|
$(sign-package)
|
|
|
|
|
|
|
|
# Set up global variables to register this apk to the higher-level dependency graph.
|
|
|
|
ALL_MODULES += $(dpi_apk_name)
|
|
|
|
ALL_MODULES.$(dpi_apk_name).CLASS := APPS
|
|
|
|
ALL_MODULES.$(dpi_apk_name).BUILT := $(built_dpi_apk)
|
|
|
|
PACKAGES := $(PACKAGES) $(dpi_apk_name)
|
|
|
|
PACKAGES.$(dpi_apk_name).PRIVATE_KEY := $(private_key)
|
|
|
|
PACKAGES.$(dpi_apk_name).CERTIFICATE := $(certificate)
|
|
|
|
|
|
|
|
# Phony targets used by "apps_only".
|
|
|
|
.PHONY: $(dpi_apk_name)
|
|
|
|
$(dpi_apk_name) : $(built_dpi_apk)
|