2014-02-06 23:45:37 +01:00
|
|
|
#
|
|
|
|
# Copyright (C) 2008 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Standard rules for building an application package.
|
|
|
|
##
|
|
|
|
## Additional inputs from base_rules.make:
|
|
|
|
## LOCAL_PACKAGE_NAME: The name of the package; the directory
|
|
|
|
## will be called this.
|
|
|
|
##
|
|
|
|
## MODULE, MODULE_PATH, and MODULE_SUFFIX will
|
|
|
|
## be set for you.
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME))
|
|
|
|
ifeq ($(LOCAL_PACKAGE_NAME),)
|
|
|
|
$(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),)
|
|
|
|
$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX)
|
|
|
|
endif
|
|
|
|
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
|
|
|
|
|
|
|
|
ifneq ($(strip $(LOCAL_MODULE)),)
|
|
|
|
$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE)
|
|
|
|
endif
|
|
|
|
LOCAL_MODULE := $(LOCAL_PACKAGE_NAME)
|
|
|
|
|
|
|
|
ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
|
|
|
|
$(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
|
|
|
|
endif
|
|
|
|
LOCAL_MODULE_CLASS := APPS
|
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
intermediates := $(call local-intermediates-dir)
|
|
|
|
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
|
|
|
|
|
2014-02-06 23:45:37 +01:00
|
|
|
# Package LOCAL_MODULE_TAGS default to optional
|
|
|
|
LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS))
|
|
|
|
ifeq ($(LOCAL_MODULE_TAGS),)
|
|
|
|
LOCAL_MODULE_TAGS := optional
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
|
|
|
|
# Force localization check if it's not tagged as tests.
|
|
|
|
LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
|
|
|
|
endif
|
|
|
|
|
2014-07-29 19:34:30 +02:00
|
|
|
need_compile_asset :=
|
2014-02-06 23:45:37 +01:00
|
|
|
ifeq (,$(LOCAL_ASSET_DIR))
|
|
|
|
LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
|
2014-07-29 19:34:30 +02:00
|
|
|
else
|
|
|
|
need_compile_asset := true
|
2014-02-06 23:45:37 +01:00
|
|
|
endif
|
|
|
|
|
2014-06-25 22:23:58 +02:00
|
|
|
# LOCAL_RESOURCE_DIR may point to resource generated during the build
|
|
|
|
need_compile_res :=
|
2014-02-06 23:45:37 +01:00
|
|
|
ifeq (,$(LOCAL_RESOURCE_DIR))
|
|
|
|
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
|
2014-06-25 22:23:58 +02:00
|
|
|
else
|
|
|
|
need_compile_res := true
|
2017-05-03 08:55:44 +02:00
|
|
|
LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
|
2014-02-06 23:45:37 +01:00
|
|
|
endif
|
|
|
|
|
2019-01-05 04:57:54 +01:00
|
|
|
# If LOCAL_MODULE matches a rule in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES,
|
2019-01-15 17:07:35 +01:00
|
|
|
# override the manifest package name by the (first) rule matched
|
2019-01-05 04:57:54 +01:00
|
|
|
override_manifest_name := $(strip $(word 1,\
|
|
|
|
$(foreach rule,$(PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES),\
|
|
|
|
$(eval _pkg_name_pat := $(call word-colon,1,$(rule)))\
|
|
|
|
$(eval _manifest_name_pat := $(call word-colon,2,$(rule)))\
|
|
|
|
$(if $(filter $(_pkg_name_pat),$(LOCAL_MODULE)),\
|
|
|
|
$(patsubst $(_pkg_name_pat),$(_manifest_name_pat),$(LOCAL_MODULE))\
|
|
|
|
)\
|
|
|
|
)\
|
|
|
|
))
|
|
|
|
|
|
|
|
ifneq (,$(override_manifest_name))
|
2019-01-15 17:07:35 +01:00
|
|
|
# Note: this can override LOCAL_MANIFEST_PACKAGE_NAME value set in Android.mk
|
2019-01-05 04:57:54 +01:00
|
|
|
LOCAL_MANIFEST_PACKAGE_NAME := $(override_manifest_name)
|
|
|
|
endif
|
|
|
|
|
2018-05-09 22:29:51 +02:00
|
|
|
include $(BUILD_SYSTEM)/force_aapt2.mk
|
|
|
|
|
2018-05-18 00:05:47 +02:00
|
|
|
# Process Support Library dependencies.
|
|
|
|
include $(BUILD_SYSTEM)/support_libraries.mk
|
|
|
|
|
2019-03-14 20:48:17 +01:00
|
|
|
# Determine whether auto-RRO is enabled for this package.
|
2017-02-01 16:44:58 +01:00
|
|
|
enforce_rro_enabled :=
|
2019-10-01 06:55:26 +02:00
|
|
|
ifneq (,$(filter *, $(PRODUCT_ENFORCE_RRO_TARGETS)))
|
2020-03-09 04:31:23 +01:00
|
|
|
# * means all system and system_ext APKs, so enable conditionally based on module path.
|
|
|
|
# Note that modules in PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS are excluded even if it is '*'
|
2019-03-14 20:48:17 +01:00
|
|
|
|
|
|
|
# Note that base_rules.mk has not yet been included, so it's likely that only
|
|
|
|
# one of LOCAL_MODULE_PATH and the LOCAL_X_MODULE flags has been set.
|
|
|
|
ifeq (,$(LOCAL_MODULE_PATH))
|
2020-03-09 04:31:23 +01:00
|
|
|
non_rro_target_module := $(filter true,\
|
2019-03-14 20:48:17 +01:00
|
|
|
$(LOCAL_ODM_MODULE) \
|
|
|
|
$(LOCAL_OEM_MODULE) \
|
|
|
|
$(LOCAL_PRODUCT_MODULE) \
|
|
|
|
$(LOCAL_PROPRIETARY_MODULE) \
|
|
|
|
$(LOCAL_VENDOR_MODULE))
|
2020-03-09 04:31:23 +01:00
|
|
|
enforce_rro_enabled := $(if $(non_rro_target_module),,true)
|
2019-03-14 20:48:17 +01:00
|
|
|
else ifneq ($(filter $(TARGET_OUT)/%,$(LOCAL_MODULE_PATH)),)
|
2019-03-14 19:53:58 +01:00
|
|
|
enforce_rro_enabled := true
|
2017-02-01 16:44:58 +01:00
|
|
|
endif
|
2019-03-14 20:48:17 +01:00
|
|
|
else ifneq (,$(filter $(LOCAL_PACKAGE_NAME), $(PRODUCT_ENFORCE_RRO_TARGETS)))
|
|
|
|
enforce_rro_enabled := true
|
2017-02-01 16:44:58 +01:00
|
|
|
endif
|
|
|
|
|
2020-03-09 04:31:23 +01:00
|
|
|
# TODO(b/150820813) Some modules depend on static overlay, remove this after eliminating the dependency.
|
|
|
|
ifneq (,$(filter $(LOCAL_PACKAGE_NAME), $(PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS)))
|
|
|
|
enforce_rro_enabled :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2019-03-18 12:43:30 +01:00
|
|
|
product_package_overlays := $(strip \
|
2019-03-14 20:48:17 +01:00
|
|
|
$(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
|
2019-03-18 12:43:30 +01:00
|
|
|
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
|
|
|
|
device_package_overlays := $(strip \
|
2019-03-14 20:48:17 +01:00
|
|
|
$(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
|
|
|
|
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
|
|
|
|
|
|
|
|
static_resource_overlays :=
|
2019-03-18 12:43:30 +01:00
|
|
|
runtime_resource_overlays_product :=
|
|
|
|
runtime_resource_overlays_vendor :=
|
2017-09-01 10:23:25 +02:00
|
|
|
ifdef enforce_rro_enabled
|
|
|
|
ifneq ($(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS),)
|
2019-03-18 12:43:30 +01:00
|
|
|
# The PRODUCT_ exclusion variable applies to both inclusion variables..
|
|
|
|
static_resource_overlays += $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(product_package_overlays))
|
|
|
|
static_resource_overlays += $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(device_package_overlays))
|
2017-09-01 10:23:25 +02:00
|
|
|
endif
|
2019-03-18 12:43:30 +01:00
|
|
|
runtime_resource_overlays_product := $(filter-out $(static_resource_overlays),$(product_package_overlays))
|
|
|
|
runtime_resource_overlays_vendor := $(filter-out $(static_resource_overlays),$(device_package_overlays))
|
2017-09-01 10:23:25 +02:00
|
|
|
else
|
2019-03-18 12:43:30 +01:00
|
|
|
static_resource_overlays := $(product_package_overlays) $(device_package_overlays)
|
2017-02-01 16:44:58 +01:00
|
|
|
endif
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2019-03-14 20:48:17 +01:00
|
|
|
# Add the static overlays. Auto-RRO is created later, as it depends on
|
|
|
|
# other logic in this file.
|
|
|
|
LOCAL_RESOURCE_DIR := $(static_resource_overlays) $(LOCAL_RESOURCE_DIR)
|
|
|
|
|
2014-02-12 22:06:30 +01:00
|
|
|
all_assets := $(strip \
|
|
|
|
$(foreach dir, $(LOCAL_ASSET_DIR), \
|
|
|
|
$(addprefix $(dir)/, \
|
|
|
|
$(patsubst assets/%,%, \
|
|
|
|
$(call find-subdir-assets, $(dir)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
))
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2014-07-29 19:34:30 +02:00
|
|
|
ifneq ($(all_assets),)
|
|
|
|
need_compile_asset := true
|
|
|
|
endif
|
|
|
|
|
2016-02-26 20:13:43 +01:00
|
|
|
my_res_package :=
|
2015-12-04 22:59:18 +01:00
|
|
|
# In aapt2 the last takes precedence.
|
|
|
|
my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR))
|
2016-02-26 20:13:43 +01:00
|
|
|
my_res_dir :=
|
|
|
|
my_overlay_res_dirs :=
|
|
|
|
|
2018-05-23 22:35:53 +02:00
|
|
|
ifneq ($(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),)
|
2016-02-26 20:13:43 +01:00
|
|
|
# If we are using static android libraries, every source file becomes an overlay.
|
|
|
|
# This is to emulate old AAPT behavior which simulated library support.
|
|
|
|
my_res_dir :=
|
|
|
|
my_overlay_res_dirs := $(my_resource_dirs)
|
|
|
|
else
|
|
|
|
# Without static libraries, the first directory is our directory, which can then be
|
|
|
|
# overlaid by the rest. (First directory in my_resource_dirs is last directory in
|
|
|
|
# $(LOCAL_RESOURCE_DIR) due to it being reversed.
|
|
|
|
my_res_dir := $(firstword $(my_resource_dirs))
|
|
|
|
my_overlay_res_dirs := $(wordlist 2,999,$(my_resource_dirs))
|
|
|
|
endif
|
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
my_overlay_resources := $(strip \
|
2016-02-26 20:13:43 +01:00
|
|
|
$(foreach d,$(my_overlay_res_dirs),\
|
2015-12-04 22:59:18 +01:00
|
|
|
$(addprefix $(d)/, \
|
|
|
|
$(call find-subdir-assets,$(d)))))
|
|
|
|
|
2016-11-29 20:12:56 +01:00
|
|
|
my_res_resources := $(if $(my_res_dir),$(strip \
|
2015-12-04 22:59:18 +01:00
|
|
|
$(addprefix $(my_res_dir)/, \
|
2016-11-29 20:12:56 +01:00
|
|
|
$(call find-subdir-assets,$(my_res_dir)))))
|
2015-12-04 22:59:18 +01:00
|
|
|
|
|
|
|
all_resources := $(strip $(my_res_resources) $(my_overlay_resources))
|
|
|
|
|
|
|
|
# The linked resource package.
|
|
|
|
my_res_package := $(intermediates)/package-res.apk
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
|
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
my_bundle_module := $(intermediates)/base.zip
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(my_bundle_module)
|
2018-11-01 21:34:08 +01:00
|
|
|
|
2016-03-01 21:06:47 +01:00
|
|
|
# Always run aapt2, because we need to at least compile the AndroidManifest.xml.
|
2015-12-04 22:59:18 +01:00
|
|
|
need_compile_res := true
|
|
|
|
|
2014-06-25 22:23:58 +02:00
|
|
|
ifneq ($(all_resources),)
|
|
|
|
need_compile_res := true
|
|
|
|
endif
|
|
|
|
|
2014-02-06 23:45:37 +01:00
|
|
|
all_res_assets := $(strip $(all_assets) $(all_resources))
|
|
|
|
|
|
|
|
# If no assets or resources were found, clear the directory variables so
|
|
|
|
# we don't try to build them.
|
2014-07-29 19:34:30 +02:00
|
|
|
ifneq (true,$(need_compile_asset))
|
2014-02-06 23:45:37 +01:00
|
|
|
LOCAL_ASSET_DIR:=
|
|
|
|
endif
|
2014-06-25 22:23:58 +02:00
|
|
|
ifneq (true,$(need_compile_res))
|
2014-02-06 23:45:37 +01:00
|
|
|
LOCAL_RESOURCE_DIR:=
|
|
|
|
R_file_stamp :=
|
|
|
|
else
|
|
|
|
# Make sure that R_file_stamp inherits the proper PRIVATE vars.
|
|
|
|
# If R.stamp moves, be sure to update the framework makefile,
|
|
|
|
# which has intimate knowledge of its location.
|
2014-12-18 23:53:52 +01:00
|
|
|
R_file_stamp := $(intermediates.COMMON)/src/R.stamp
|
2014-02-06 23:45:37 +01:00
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
|
|
|
|
endif
|
|
|
|
|
2017-08-07 13:31:17 +02:00
|
|
|
ifdef LOCAL_COMPRESSED_MODULE
|
|
|
|
ifneq (true,$(LOCAL_COMPRESSED_MODULE))
|
|
|
|
$(call pretty-error, Unknown value for LOCAL_COMPRESSED_MODULE $(LOCAL_COMPRESSED_MODULE))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef LOCAL_COMPRESSED_MODULE
|
2017-08-14 11:53:50 +02:00
|
|
|
PACKAGES.$(LOCAL_PACKAGE_NAME).COMPRESSED := gz
|
2017-08-07 13:31:17 +02:00
|
|
|
LOCAL_BUILT_MODULE_STEM := package.apk.gz
|
|
|
|
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk.gz
|
|
|
|
else # !LOCAL_COMPRESSED_MODULE
|
2014-02-06 23:45:37 +01:00
|
|
|
LOCAL_BUILT_MODULE_STEM := package.apk
|
2014-07-18 06:24:42 +02:00
|
|
|
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
|
2017-08-07 13:31:17 +02:00
|
|
|
endif
|
2014-02-06 23:45:37 +01:00
|
|
|
|
|
|
|
LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
|
|
|
|
ifndef LOCAL_PROGUARD_ENABLED
|
|
|
|
ifneq ($(DISABLE_PROGUARD),true)
|
|
|
|
LOCAL_PROGUARD_ENABLED :=full
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
|
|
|
|
# the package explicitly request to disable proguard.
|
|
|
|
LOCAL_PROGUARD_ENABLED :=
|
|
|
|
endif
|
|
|
|
proguard_options_file :=
|
|
|
|
ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
|
2014-06-25 22:23:58 +02:00
|
|
|
ifeq ($(need_compile_res),true)
|
2014-12-18 23:53:52 +01:00
|
|
|
proguard_options_file := $(intermediates.COMMON)/proguard_options
|
2014-06-25 22:23:58 +02:00
|
|
|
endif # need_compile_res
|
2014-02-06 23:45:37 +01:00
|
|
|
endif # !custom
|
|
|
|
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
|
2019-08-09 18:14:45 +02:00
|
|
|
LOCAL_PROGUARD_FLAGS_DEPS += $(proguard_options_file)
|
2014-02-06 23:45:37 +01:00
|
|
|
|
|
|
|
ifeq (true,$(EMMA_INSTRUMENT))
|
|
|
|
ifndef LOCAL_EMMA_INSTRUMENT
|
2017-04-12 01:36:46 +02:00
|
|
|
# No jacoco for test apks.
|
2015-11-06 20:22:28 +01:00
|
|
|
ifeq (,$(LOCAL_INSTRUMENTATION_FOR))
|
2014-02-06 23:45:37 +01:00
|
|
|
LOCAL_EMMA_INSTRUMENT := true
|
|
|
|
endif # No test apk
|
|
|
|
endif # LOCAL_EMMA_INSTRUMENT is not set
|
|
|
|
else
|
|
|
|
LOCAL_EMMA_INSTRUMENT := false
|
|
|
|
endif # EMMA_INSTRUMENT is true
|
|
|
|
|
|
|
|
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
|
|
|
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
|
2018-03-08 00:44:54 +01:00
|
|
|
ifneq ($(LOCAL_SRC_FILES)$(LOCAL_SRCJARS)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
|
2016-12-21 23:29:13 +01:00
|
|
|
# Only add jacocoagent if the package contains some java code
|
2015-11-19 17:53:00 +01:00
|
|
|
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
2018-01-03 21:39:11 +01:00
|
|
|
# Exclude jacoco classes from proguard
|
|
|
|
LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
|
2019-08-09 18:14:45 +02:00
|
|
|
LOCAL_PROGUARD_FLAGS_DEPS += $(BUILD_SYSTEM)/proguard.jacoco.flags
|
2016-12-21 23:29:13 +01:00
|
|
|
endif # Contains java code
|
|
|
|
else
|
2014-02-06 23:45:37 +01:00
|
|
|
ifdef LOCAL_SDK_VERSION
|
|
|
|
ifdef TARGET_BUILD_APPS
|
2016-03-31 16:48:26 +02:00
|
|
|
# In unbundled build, merge the coverage library into the apk.
|
2016-12-21 23:29:13 +01:00
|
|
|
ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
|
|
|
|
# Only add jacocoagent if the package contains some java code
|
2015-11-19 17:53:00 +01:00
|
|
|
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
2016-03-31 16:48:26 +02:00
|
|
|
# Exclude jacoco classes from proguard
|
|
|
|
LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
|
2019-08-09 18:14:45 +02:00
|
|
|
LOCAL_PROGUARD_FLAGS_DEPS += $(BUILD_SYSTEM)/proguard.jacoco.flags
|
2016-12-21 23:29:13 +01:00
|
|
|
endif # Contains java code
|
2017-09-27 23:28:41 +02:00
|
|
|
endif # TARGET_BUILD_APPS
|
2014-02-06 23:45:37 +01:00
|
|
|
endif # LOCAL_SDK_VERSION
|
2016-12-21 23:29:13 +01:00
|
|
|
endif # EMMA_INSTRUMENT_STATIC
|
2014-02-06 23:45:37 +01:00
|
|
|
endif # LOCAL_EMMA_INSTRUMENT
|
|
|
|
|
|
|
|
rs_compatibility_jni_libs :=
|
|
|
|
|
2017-08-07 13:31:17 +02:00
|
|
|
# If the module is a compressed module, we don't pre-opt it because its final
|
|
|
|
# installation location will be the data partition.
|
|
|
|
ifdef LOCAL_COMPRESSED_MODULE
|
|
|
|
LOCAL_DEX_PREOPT := false
|
|
|
|
endif
|
|
|
|
|
2019-02-07 01:36:32 +01:00
|
|
|
# Default to use uncompressed native libraries in APKs if minSdkVersion >= marshmallow
|
|
|
|
ifndef LOCAL_USE_EMBEDDED_NATIVE_LIBS
|
|
|
|
LOCAL_USE_EMBEDDED_NATIVE_LIBS := $(call math_gt_or_eq, \
|
|
|
|
$(patsubst $(PLATFORM_VERSION_CODENAME),100,$(call module-min-sdk-version)),23)
|
|
|
|
endif
|
|
|
|
|
2014-10-29 23:48:32 +01:00
|
|
|
include $(BUILD_SYSTEM)/android_manifest.mk
|
|
|
|
|
2018-01-04 23:27:36 +01:00
|
|
|
resource_export_package :=
|
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
include $(BUILD_SYSTEM)/java_renderscript.mk
|
|
|
|
|
2018-03-07 03:18:06 +01:00
|
|
|
include $(BUILD_SYSTEM)/aapt_flags.mk
|
|
|
|
|
2014-06-25 22:23:58 +02:00
|
|
|
ifeq ($(need_compile_res),true)
|
2016-08-12 21:57:17 +02:00
|
|
|
|
|
|
|
###############################
|
|
|
|
## APK splits
|
|
|
|
built_apk_splits :=
|
|
|
|
installed_apk_splits :=
|
|
|
|
my_apk_split_configs :=
|
|
|
|
|
|
|
|
ifdef LOCAL_PACKAGE_SPLITS
|
2017-08-07 13:31:17 +02:00
|
|
|
ifdef LOCAL_COMPRESSED_MODULE
|
|
|
|
$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs)
|
|
|
|
endif # LOCAL_COMPRESSED_MODULE
|
|
|
|
|
2016-08-12 21:57:17 +02:00
|
|
|
my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS)
|
|
|
|
my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs))
|
2017-05-16 08:38:04 +02:00
|
|
|
built_apk_splits := $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk)
|
2016-08-12 21:57:17 +02:00
|
|
|
endif
|
|
|
|
|
2019-06-22 22:03:09 +02:00
|
|
|
$(R_file_stamp) $(my_res_package): PRIVATE_AAPT_FLAGS := $(filter-out --legacy,$(LOCAL_AAPT_FLAGS))
|
2018-03-07 01:21:36 +01:00
|
|
|
$(R_file_stamp) $(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS)
|
|
|
|
$(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
|
|
|
|
$(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
|
|
|
|
|
|
|
|
###############################
|
2019-02-26 07:21:24 +01:00
|
|
|
## AAPT2
|
2018-03-07 01:21:36 +01:00
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
|
|
|
|
ifneq (,$(filter-out current,$(renderscript_target_api)))
|
|
|
|
ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true)
|
|
|
|
my_generated_res_zips := $(rs_generated_res_zip)
|
|
|
|
endif # renderscript_target_api < 21
|
|
|
|
endif # renderscript_target_api is set
|
|
|
|
my_asset_dirs := $(LOCAL_ASSET_DIR)
|
|
|
|
my_full_asset_paths := $(all_assets)
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
# Add AAPT2 link specific flags.
|
|
|
|
ifndef LOCAL_AAPT_NAMESPACES
|
|
|
|
$(my_res_package): PRIVATE_AAPT_FLAGS += --no-static-lib-packages
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(BUILD_SYSTEM)/aapt2.mk
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
endif # need_compile_res
|
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
my_dex_jar := $(intermediates.COMMON)/dex.jar
|
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
called_from_package_internal := true
|
|
|
|
#################################
|
|
|
|
include $(BUILD_SYSTEM)/java.mk
|
|
|
|
#################################
|
|
|
|
called_from_package_internal :=
|
|
|
|
|
|
|
|
ifeq ($(need_compile_res),true)
|
|
|
|
|
2014-02-06 23:45:37 +01:00
|
|
|
# Other modules should depend on the BUILT module if
|
|
|
|
# they want to use this module's R.java file.
|
2016-12-21 23:29:13 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
|
|
|
|
|
2017-05-27 00:22:02 +02:00
|
|
|
# The R.java file must exist by the time the java source
|
|
|
|
# list is generated
|
|
|
|
$(java_source_list_file): $(R_file_stamp)
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
endif # need_compile_res
|
|
|
|
|
|
|
|
LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
|
|
|
|
ifeq ($(LOCAL_SDK_RES_VERSION),)
|
|
|
|
LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): \
|
|
|
|
PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
|
|
|
|
|
2018-02-15 01:18:12 +01:00
|
|
|
framework_res_package_export :=
|
|
|
|
|
|
|
|
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
|
2014-02-06 23:45:37 +01:00
|
|
|
# Most packages should link against the resources defined by framework-res.
|
|
|
|
# Even if they don't have their own resources, they may use framework
|
|
|
|
# resources.
|
2018-02-16 22:31:17 +01:00
|
|
|
ifeq ($(LOCAL_SDK_RES_VERSION),core_current)
|
|
|
|
# core_current doesn't contain any framework resources.
|
2018-12-19 07:43:16 +01:00
|
|
|
else ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS_USE_PREBUILT_SDK),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
|
2014-02-06 23:45:37 +01:00
|
|
|
# for released sdk versions, the platform resources were built into android.jar.
|
|
|
|
framework_res_package_export := \
|
2018-04-27 15:11:17 +02:00
|
|
|
$(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION))
|
2014-02-06 23:45:37 +01:00
|
|
|
else # LOCAL_SDK_RES_VERSION
|
|
|
|
framework_res_package_export := \
|
|
|
|
$(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
|
|
|
|
endif # LOCAL_SDK_RES_VERSION
|
2018-02-15 01:18:12 +01:00
|
|
|
endif # LOCAL_NO_STANDARD_LIBRARIES
|
|
|
|
|
2014-03-14 02:48:27 +01:00
|
|
|
all_library_res_package_exports := \
|
|
|
|
$(framework_res_package_export) \
|
2014-03-25 23:45:34 +01:00
|
|
|
$(foreach lib,$(LOCAL_RES_LIBRARIES),\
|
2014-03-14 02:48:27 +01:00
|
|
|
$(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk)
|
|
|
|
|
|
|
|
all_library_res_package_export_deps := \
|
2018-02-20 23:31:33 +01:00
|
|
|
$(framework_res_package_export) \
|
2014-03-25 23:45:34 +01:00
|
|
|
$(foreach lib,$(LOCAL_RES_LIBRARIES),\
|
2014-03-14 02:48:27 +01:00
|
|
|
$(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp)
|
2014-06-20 01:07:30 +02:00
|
|
|
$(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_res_package_export_deps)
|
2014-02-06 23:45:37 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): \
|
2014-03-14 02:48:27 +01:00
|
|
|
PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
|
2015-12-04 22:59:18 +01:00
|
|
|
|
|
|
|
$(my_res_package) : $(all_library_res_package_export_deps)
|
2014-02-06 23:45:37 +01:00
|
|
|
|
|
|
|
ifneq ($(full_classes_jar),)
|
|
|
|
$(LOCAL_BUILT_MODULE): 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
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
|
2019-06-12 23:18:31 +02:00
|
|
|
$(LOCAL_BUILT_MODULE): $(built_dex) $(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
|
|
|
else
|
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
|
2016-12-21 23:29:13 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE :=
|
2014-02-06 23:45:37 +01:00
|
|
|
endif # full_classes_jar
|
|
|
|
|
2014-04-17 22:38:04 +02:00
|
|
|
include $(BUILD_SYSTEM)/install_jni_libs.mk
|
2014-02-06 23:45:37 +01:00
|
|
|
|
|
|
|
# Pick a key to sign the package with. If this package hasn't specified
|
|
|
|
# an explicit certificate, use the default.
|
|
|
|
# Secure release builds will have their packages signed after the fact,
|
|
|
|
# so it's ok for these private keys to be in the clear.
|
|
|
|
ifeq ($(LOCAL_CERTIFICATE),)
|
|
|
|
LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
|
|
|
|
# The special value "EXTERNAL" means that we will sign it with the
|
|
|
|
# default devkey, apply predexopt, but then expect the final .apk
|
|
|
|
# (after dexopting) to be signed by an outside tool.
|
|
|
|
LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
|
|
|
|
PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
# If this is not an absolute certificate, assign it to a generic one.
|
|
|
|
ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
|
|
|
|
LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
|
|
|
|
endif
|
2018-12-17 06:45:15 +01:00
|
|
|
include $(BUILD_SYSTEM)/app_certificate_validate.mk
|
2014-02-06 23:45:37 +01:00
|
|
|
private_key := $(LOCAL_CERTIFICATE).pk8
|
|
|
|
certificate := $(LOCAL_CERTIFICATE).x509.pem
|
2016-05-13 09:03:24 +02:00
|
|
|
additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2019-08-08 21:56:01 +02:00
|
|
|
$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR) $(SIGNAPK_JNI_LIBRARY_PATH)
|
2014-02-06 23:45:37 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
|
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate)
|
|
|
|
|
|
|
|
PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
|
|
|
|
PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
|
|
|
|
|
2016-05-13 09:03:24 +02:00
|
|
|
$(LOCAL_BUILT_MODULE): $(additional_certificates)
|
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2019-05-22 19:25:59 +02:00
|
|
|
# Verify LOCAL_USES_LIBRARIES/LOCAL_OPTIONAL_USES_LIBRARIES
|
|
|
|
# If LOCAL_ENFORCE_USES_LIBRARIES is not set, default to true if either of LOCAL_USES_LIBRARIES or
|
|
|
|
# LOCAL_OPTIONAL_USES_LIBRARIES are specified.
|
|
|
|
# Will change the default to true unconditionally in the future.
|
|
|
|
ifndef LOCAL_ENFORCE_USES_LIBRARIES
|
|
|
|
ifneq (,$(strip $(LOCAL_USES_LIBRARIES)$(LOCAL_OPTIONAL_USES_LIBRARIES)))
|
|
|
|
LOCAL_ENFORCE_USES_LIBRARIES := true
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
my_enforced_uses_libraries :=
|
|
|
|
ifdef LOCAL_ENFORCE_USES_LIBRARIES
|
|
|
|
my_manifest_check := $(intermediates.COMMON)/manifest/AndroidManifest.xml.check
|
|
|
|
$(my_manifest_check): $(MANIFEST_CHECK)
|
|
|
|
$(my_manifest_check): PRIVATE_USES_LIBRARIES := $(LOCAL_USES_LIBRARIES)
|
|
|
|
$(my_manifest_check): PRIVATE_OPTIONAL_USES_LIBRARIES := $(LOCAL_OPTIONAL_USES_LIBRARIES)
|
|
|
|
$(my_manifest_check): $(full_android_manifest)
|
|
|
|
@echo Checking manifest: $<
|
|
|
|
$(MANIFEST_CHECK) --enforce-uses-libraries \
|
|
|
|
$(addprefix --uses-library ,$(PRIVATE_USES_LIBRARIES)) \
|
|
|
|
$(addprefix --optional-uses-library ,$(PRIVATE_OPTIONAL_USES_LIBRARIES)) \
|
|
|
|
$< -o $@
|
|
|
|
$(LOCAL_BUILT_MODULE): $(my_manifest_check)
|
|
|
|
endif
|
|
|
|
|
2014-02-06 23:45:37 +01:00
|
|
|
# Define the rule to build the actual package.
|
2014-06-25 05:01:52 +02:00
|
|
|
# PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>.
|
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
|
|
|
|
# PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names.
|
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
|
2014-02-06 23:45:37 +01:00
|
|
|
ifneq ($(TARGET_BUILD_APPS),)
|
|
|
|
# Include all resources for unbundled apps.
|
|
|
|
LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
|
|
|
|
endif
|
|
|
|
ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
|
2016-02-26 20:13:43 +01:00
|
|
|
$(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
|
|
|
|
$(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
|
2014-02-06 23:45:37 +01:00
|
|
|
else
|
2016-02-26 20:13:43 +01:00
|
|
|
$(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
|
2014-07-30 22:40:14 +02:00
|
|
|
ifdef LOCAL_PACKAGE_SPLITS
|
2016-02-26 20:13:43 +01:00
|
|
|
$(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
|
2014-07-30 22:40:14 +02:00
|
|
|
else
|
2016-02-26 20:13:43 +01:00
|
|
|
$(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
|
2014-02-06 23:45:37 +01:00
|
|
|
endif
|
2014-07-30 22:40:14 +02:00
|
|
|
endif
|
2017-08-03 05:17:34 +02:00
|
|
|
|
2019-06-25 08:58:13 +02:00
|
|
|
# Run veridex on product, system_ext and vendor modules.
|
2018-07-31 12:31:30 +02:00
|
|
|
# We skip it for unbundled app builds where we cannot build veridex.
|
|
|
|
module_run_appcompat :=
|
2019-01-18 07:09:09 +01:00
|
|
|
ifeq (true,$(non_system_module))
|
2018-07-31 12:31:30 +02:00
|
|
|
ifeq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK))) # ! unbundled app build
|
2019-01-15 18:30:51 +01:00
|
|
|
ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true)
|
2018-07-31 12:31:30 +02:00
|
|
|
module_run_appcompat := true
|
|
|
|
endif
|
|
|
|
endif
|
2019-01-15 18:30:51 +01:00
|
|
|
endif
|
2018-07-31 12:31:30 +02:00
|
|
|
|
|
|
|
ifeq ($(module_run_appcompat),true)
|
2018-09-17 23:36:37 +02:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(appcompat-files)
|
2018-07-31 16:29:13 +02:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
|
2018-07-13 17:44:28 +02:00
|
|
|
endif
|
|
|
|
|
2017-08-03 05:17:34 +02:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/resources
|
2015-12-04 22:59:18 +01:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
|
2018-09-14 22:39:07 +02:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(JAR_ARGS) $(SOONG_ZIP) $(MERGE_ZIPS) $(ZIP2ZIP)
|
2015-12-04 22:59:18 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
|
2019-05-29 00:36:47 +02:00
|
|
|
$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2)
|
2017-08-07 13:31:17 +02:00
|
|
|
ifdef LOCAL_COMPRESSED_MODULE
|
|
|
|
$(LOCAL_BUILT_MODULE) : $(MINIGZIP)
|
2015-12-04 22:59:18 +01:00
|
|
|
endif
|
2018-10-08 06:32:07 +02:00
|
|
|
ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
|
|
|
|
$(LOCAL_BUILT_MODULE) : $(ZIP2ZIP)
|
|
|
|
endif
|
2019-02-07 01:36:32 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_USE_EMBEDDED_NATIVE_LIBS := $(LOCAL_USE_EMBEDDED_NATIVE_LIBS)
|
2018-09-29 01:19:42 +02:00
|
|
|
$(LOCAL_BUILT_MODULE):
|
2014-02-06 23:45:37 +01:00
|
|
|
@echo "target Package: $(PRIVATE_MODULE) ($@)"
|
2018-09-14 22:39:07 +02:00
|
|
|
rm -rf $@.parts
|
|
|
|
mkdir -p $@.parts
|
2018-09-29 01:19:42 +02:00
|
|
|
cp -f $(PRIVATE_RES_PACKAGE) $@.parts/apk.zip
|
2014-02-06 23:45:37 +01:00
|
|
|
ifneq ($(jni_shared_libraries),)
|
2019-02-07 01:36:32 +01:00
|
|
|
$(call create-jni-shared-libs-package,$@.parts/jni.zip,$(PRIVATE_USE_EMBEDDED_NATIVE_LIBS))
|
2014-02-06 23:45:37 +01:00
|
|
|
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.
|
2018-09-14 22:39:07 +02:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call create-java-resources-jar,$@.parts/res.zip))
|
2016-03-11 19:32:01 +01:00
|
|
|
else # full_classes_jar
|
2018-09-14 22:39:07 +02:00
|
|
|
$(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
|
|
|
|
$(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
|
2016-03-11 19:32:01 +01:00
|
|
|
endif # full_classes_jar
|
2018-09-14 22:39:07 +02:00
|
|
|
$(MERGE_ZIPS) $@ $@.parts/*.zip
|
|
|
|
rm -rf $@.parts
|
2018-01-09 12:46:30 +01:00
|
|
|
ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
|
|
|
|
@# No need to align, sign-package below will do it.
|
|
|
|
$(uncompress-dexs)
|
|
|
|
endif
|
2019-10-18 15:47:19 +02:00
|
|
|
# Run appcompat before signing.
|
2018-07-31 12:31:30 +02:00
|
|
|
ifeq ($(module_run_appcompat),true)
|
2018-07-31 16:29:13 +02:00
|
|
|
$(appcompat-header)
|
2018-07-13 17:44:28 +02:00
|
|
|
$(run-appcompat)
|
2018-07-31 12:31:30 +02:00
|
|
|
endif # module_run_appcompat
|
2015-04-15 21:09:32 +02:00
|
|
|
$(sign-package)
|
2017-08-07 13:31:17 +02:00
|
|
|
ifdef LOCAL_COMPRESSED_MODULE
|
|
|
|
$(compress-package)
|
|
|
|
endif # LOCAL_COMPRESSED_MODULE
|
2014-02-06 23:45:37 +01:00
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
my_package_res_pb := $(intermediates)/package-res.pb.apk
|
|
|
|
$(my_package_res_pb): $(my_res_package) $(AAPT2)
|
2018-11-01 21:34:08 +01:00
|
|
|
$(AAPT2) convert --output-format proto $< -o $@
|
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
$(my_bundle_module): $(my_package_res_pb)
|
|
|
|
$(my_bundle_module): PRIVATE_RES_PACKAGE := $(my_package_res_pb)
|
2018-11-01 21:34:08 +01:00
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
$(my_bundle_module): $(jni_shared_libraries)
|
|
|
|
$(my_bundle_module): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
|
|
|
|
$(my_bundle_module): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
|
2018-11-01 21:34:08 +01:00
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
ifneq ($(full_classes_jar),)
|
|
|
|
$(my_bundle_module): PRIVATE_DEX_FILE := $(built_dex)
|
|
|
|
# Use the jarjar processed archive as the initial package file.
|
|
|
|
$(my_bundle_module): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
|
|
|
|
$(my_bundle_module): $(built_dex)
|
|
|
|
else
|
|
|
|
$(my_bundle_module): PRIVATE_DEX_FILE :=
|
|
|
|
$(my_bundle_module): PRIVATE_SOURCE_ARCHIVE :=
|
|
|
|
endif # full_classes_jar
|
2018-11-01 21:34:08 +01:00
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
$(my_bundle_module): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP)
|
2018-11-01 21:34:08 +01:00
|
|
|
@echo "target Bundle: $(PRIVATE_MODULE) ($@)"
|
|
|
|
rm -rf $@.parts
|
|
|
|
mkdir -p $@.parts
|
|
|
|
$(ZIP2ZIP) -i $(PRIVATE_RES_PACKAGE) -o $@.parts/apk.zip AndroidManifest.xml:manifest/AndroidManifest.xml resources.pb "res/**/*" "assets/**/*"
|
2019-02-26 07:21:24 +01:00
|
|
|
ifneq ($(jni_shared_libraries),)
|
2018-11-01 21:34:08 +01:00
|
|
|
$(call create-jni-shared-libs-package,$@.parts/jni.zip)
|
2019-02-26 07:21:24 +01:00
|
|
|
endif
|
|
|
|
ifeq ($(full_classes_jar),)
|
|
|
|
# We don't build jar, need to add the Java resources here.
|
2018-11-05 19:13:10 +01:00
|
|
|
$(if $(PRIVATE_EXTRA_JAR_ARGS),\
|
|
|
|
$(call create-java-resources-jar,$@.parts/res.zip) && \
|
|
|
|
$(ZIP2ZIP) -i $@.parts/res.zip -o $@.parts/res.zip.tmp "**/*:root/" && \
|
|
|
|
mv -f $@.parts/res.zip.tmp $@.parts/res.zip)
|
2019-02-26 07:21:24 +01:00
|
|
|
else # full_classes_jar
|
2018-11-01 21:34:08 +01:00
|
|
|
$(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
|
|
|
|
$(ZIP2ZIP) -i $@.parts/dex.zip -o $@.parts/dex.zip.tmp "classes*.dex:dex/"
|
|
|
|
mv -f $@.parts/dex.zip.tmp $@.parts/dex.zip
|
|
|
|
$(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
|
2018-11-05 19:13:10 +01:00
|
|
|
$(ZIP2ZIP) -i $@.parts/res.zip -o $@.parts/res.zip.tmp "**/*:root/"
|
|
|
|
mv -f $@.parts/res.zip.tmp $@.parts/res.zip
|
2019-02-26 07:21:24 +01:00
|
|
|
endif # full_classes_jar
|
2018-11-01 21:34:08 +01:00
|
|
|
$(MERGE_ZIPS) $@ $@.parts/*.zip
|
|
|
|
rm -rf $@.parts
|
2019-02-26 07:21:24 +01:00
|
|
|
ALL_MODULES.$(LOCAL_MODULE).BUNDLE := $(my_bundle_module)
|
2018-11-01 21:34:08 +01:00
|
|
|
|
2014-12-02 02:46:56 +01:00
|
|
|
ifdef TARGET_BUILD_APPS
|
2019-02-26 07:21:24 +01:00
|
|
|
ifdef LOCAL_DPI_VARIANTS
|
|
|
|
$(call pretty-error,Building DPI-specific APKs is no longer supported)
|
|
|
|
endif
|
2014-12-02 02:46:56 +01:00
|
|
|
endif
|
|
|
|
|
2014-05-22 01:13:33 +02:00
|
|
|
###############################
|
2018-11-17 06:26:33 +01:00
|
|
|
## Rule to build a jar containing dex files to dexpreopt without waiting for
|
|
|
|
## the APK
|
2014-05-22 01:13:33 +02:00
|
|
|
ifdef LOCAL_DEX_PREOPT
|
2018-11-17 06:26:33 +01:00
|
|
|
$(my_dex_jar): PRIVATE_DEX_FILE := $(built_dex)
|
2019-06-12 08:05:02 +02:00
|
|
|
$(my_dex_jar): $(built_dex) $(SOONG_ZIP)
|
2014-05-28 22:34:59 +02:00
|
|
|
$(hide) mkdir -p $(dir $@) && rm -f $@
|
2018-09-14 22:39:07 +02:00
|
|
|
$(call create-dex-jar,$@,$(PRIVATE_DEX_FILE))
|
2014-05-22 01:13:33 +02:00
|
|
|
endif
|
|
|
|
|
2014-07-23 00:42:11 +02:00
|
|
|
###############################
|
|
|
|
## APK splits
|
|
|
|
ifdef LOCAL_PACKAGE_SPLITS
|
2014-07-23 19:27:57 +02:00
|
|
|
# The splits should have been built in the same command building the base apk.
|
2015-12-04 19:07:41 +01:00
|
|
|
# This rule just runs signing.
|
2014-07-23 19:27:57 +02:00
|
|
|
# Note that we explicily check the existence of the split apk and remove the
|
|
|
|
# built base apk if the split apk isn't there.
|
|
|
|
# That way the build system will rerun the aapt after the user changes the splitting parameters.
|
2014-07-23 00:42:11 +02:00
|
|
|
$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key)
|
|
|
|
$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate)
|
2017-05-16 08:38:04 +02:00
|
|
|
$(built_apk_splits) : $(intermediates)/%.apk : $(LOCAL_BUILT_MODULE)
|
2014-07-23 19:27:57 +02:00
|
|
|
$(hide) if [ ! -f $@ ]; then \
|
|
|
|
echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \
|
|
|
|
rm $<; exit 1; \
|
|
|
|
fi
|
|
|
|
$(sign-package)
|
2014-07-23 00:42:11 +02:00
|
|
|
|
|
|
|
# Rules to install the splits
|
2018-03-07 01:21:36 +01:00
|
|
|
installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
|
2017-05-16 08:38:04 +02:00
|
|
|
$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(intermediates)/package_%.apk
|
2014-07-23 19:27:57 +02:00
|
|
|
@echo "Install: $@"
|
|
|
|
$(copy-file-to-new-target)
|
2014-07-23 00:42:11 +02:00
|
|
|
|
|
|
|
# Register the additional built and installed files.
|
|
|
|
ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
|
|
|
|
ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
|
2017-05-16 08:38:04 +02:00
|
|
|
$(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
|
2014-07-23 00:42:11 +02:00
|
|
|
|
|
|
|
# Make sure to install the splits when you run "make <module_name>".
|
2016-09-21 01:01:28 +02:00
|
|
|
$(my_all_targets): $(installed_apk_splits)
|
2015-06-03 21:43:50 +02:00
|
|
|
|
|
|
|
ifdef LOCAL_COMPATIBILITY_SUITE
|
|
|
|
|
2019-03-14 02:04:05 +01:00
|
|
|
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
|
|
|
|
$(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
|
|
|
|
$(foreach s,$(my_split_suffixes),\
|
|
|
|
$(call compat-copy-pair,$(intermediates)/package_$(s).apk,$(dir)/$(LOCAL_MODULE)_$(s).apk)))))
|
2017-02-17 03:04:10 +01:00
|
|
|
|
|
|
|
$(call create-suite-dependencies)
|
2015-06-03 21:43:50 +02:00
|
|
|
|
|
|
|
endif # LOCAL_COMPATIBILITY_SUITE
|
2014-07-23 00:42:11 +02:00
|
|
|
endif # LOCAL_PACKAGE_SPLITS
|
|
|
|
|
2014-02-06 23:45:37 +01:00
|
|
|
# Save information about this package
|
|
|
|
PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
|
|
|
|
PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
|
|
|
|
|
|
|
|
PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
|
|
|
|
|
|
|
|
# Reset internal variables.
|
|
|
|
all_res_assets :=
|
2017-02-01 16:44:58 +01:00
|
|
|
|
2019-03-18 12:43:30 +01:00
|
|
|
ifneq (,$(runtime_resource_overlays_product)$(runtime_resource_overlays_vendor))
|
2017-02-01 16:44:58 +01:00
|
|
|
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
|
|
|
|
enforce_rro_use_res_lib := true
|
|
|
|
else
|
|
|
|
enforce_rro_use_res_lib := false
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef LOCAL_MANIFEST_PACKAGE_NAME
|
|
|
|
enforce_rro_is_manifest_package_name := true
|
|
|
|
enforce_rro_manifest_package_info := $(LOCAL_MANIFEST_PACKAGE_NAME)
|
|
|
|
else
|
|
|
|
enforce_rro_is_manifest_package_name := false
|
|
|
|
enforce_rro_manifest_package_info := $(full_android_manifest)
|
|
|
|
endif
|
|
|
|
|
2019-03-18 12:43:30 +01:00
|
|
|
ifdef runtime_resource_overlays_product
|
|
|
|
$(call append_enforce_rro_sources, \
|
|
|
|
$(my_register_name), \
|
|
|
|
$(enforce_rro_is_manifest_package_name), \
|
|
|
|
$(enforce_rro_manifest_package_info), \
|
|
|
|
$(enforce_rro_use_res_lib), \
|
|
|
|
$(runtime_resource_overlays_product), \
|
|
|
|
product \
|
|
|
|
)
|
|
|
|
endif
|
|
|
|
ifdef runtime_resource_overlays_vendor
|
|
|
|
$(call append_enforce_rro_sources, \
|
|
|
|
$(my_register_name), \
|
|
|
|
$(enforce_rro_is_manifest_package_name), \
|
|
|
|
$(enforce_rro_manifest_package_info), \
|
|
|
|
$(enforce_rro_use_res_lib), \
|
|
|
|
$(runtime_resource_overlays_vendor), \
|
|
|
|
vendor \
|
|
|
|
)
|
|
|
|
endif
|
2019-03-14 20:48:17 +01:00
|
|
|
endif
|