2009-03-04 04:28:42 +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 a "static" java library.
|
|
|
|
# Static java libraries are not installed, nor listed on any
|
|
|
|
# classpaths. They can, however, be included wholesale in
|
|
|
|
# other java modules.
|
|
|
|
|
2016-07-26 01:03:53 +02:00
|
|
|
$(call record-module-type,STATIC_JAVA_LIBRARY)
|
2009-03-04 04:28:42 +01:00
|
|
|
LOCAL_UNINSTALLABLE_MODULE := true
|
|
|
|
LOCAL_IS_STATIC_JAVA_LIBRARY := true
|
2013-03-26 20:42:32 +01:00
|
|
|
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
|
|
|
|
|
|
|
|
my_res_package :=
|
|
|
|
|
2018-05-18 00:05:47 +02:00
|
|
|
# Process Support Library dependencies.
|
|
|
|
include $(BUILD_SYSTEM)/support_libraries.mk
|
|
|
|
|
2018-05-09 22:29:51 +02:00
|
|
|
include $(BUILD_SYSTEM)/force_aapt2.mk
|
|
|
|
|
2011-12-14 23:29:28 +01:00
|
|
|
# Hack to build static Java library with Android resource
|
|
|
|
# See bug 5714516
|
|
|
|
all_resources :=
|
2014-06-25 22:23:58 +02:00
|
|
|
need_compile_res :=
|
|
|
|
# A static Java library needs to explicily set LOCAL_RESOURCE_DIR.
|
2011-12-14 23:29:28 +01:00
|
|
|
ifdef LOCAL_RESOURCE_DIR
|
2014-06-25 22:23:58 +02:00
|
|
|
need_compile_res := true
|
2017-05-03 08:55:44 +02:00
|
|
|
LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
|
2016-03-01 21:06:47 +01:00
|
|
|
endif
|
2018-05-23 22:35:53 +02:00
|
|
|
ifneq ($(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),)
|
2016-03-01 21:06:47 +01:00
|
|
|
need_compile_res := true
|
|
|
|
endif
|
2015-12-04 22:59:18 +01:00
|
|
|
|
2016-03-01 21:06:47 +01:00
|
|
|
ifeq ($(need_compile_res),true)
|
2011-12-14 23:29:28 +01:00
|
|
|
all_resources := $(strip \
|
|
|
|
$(foreach dir, $(LOCAL_RESOURCE_DIR), \
|
|
|
|
$(addprefix $(dir)/, \
|
|
|
|
$(patsubst res/%,%, \
|
|
|
|
$(call find-subdir-assets,$(dir)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
))
|
2011-12-16 01:36:55 +01:00
|
|
|
|
2012-06-19 19:40:37 +02:00
|
|
|
# By default we should remove the R/Manifest classes from a static Java library,
|
|
|
|
# because they will be regenerated in the app that uses it.
|
|
|
|
# But if the static Java library will be used by a library, then we may need to
|
|
|
|
# keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none".
|
|
|
|
ifndef LOCAL_JAR_EXCLUDE_FILES
|
|
|
|
LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES)
|
2011-12-14 23:29:28 +01:00
|
|
|
endif
|
2012-06-19 19:40:37 +02:00
|
|
|
ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES))
|
|
|
|
LOCAL_JAR_EXCLUDE_FILES :=
|
2012-04-26 21:26:33 +02:00
|
|
|
endif
|
2013-03-26 20:42:32 +01:00
|
|
|
|
|
|
|
proguard_options_file :=
|
|
|
|
|
2016-11-15 02:18:55 +01:00
|
|
|
ifneq ($(filter custom,$(LOCAL_PROGUARD_ENABLED)),custom)
|
2013-03-26 20:42:32 +01:00
|
|
|
proguard_options_file := $(intermediates.COMMON)/proguard_options
|
|
|
|
endif
|
2014-09-08 14:45:14 +02:00
|
|
|
|
2013-03-26 20:42:32 +01:00
|
|
|
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)
|
2013-03-26 20:42:32 +01:00
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
R_file_stamp := $(intermediates.COMMON)/src/R.stamp
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
|
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
ifneq ($(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),)
|
|
|
|
# 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_resources :=
|
|
|
|
my_overlay_resources := $(all_resources)
|
|
|
|
else
|
|
|
|
# Otherwise, for a library we treat all the resource equal with no overlay.
|
|
|
|
my_res_resources := $(all_resources)
|
|
|
|
my_overlay_resources :=
|
|
|
|
endif
|
|
|
|
# For libraries put everything in the COMMON intermediate directory.
|
|
|
|
my_res_package := $(intermediates.COMMON)/package-res.apk
|
|
|
|
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
|
2019-02-13 22:14:07 +01:00
|
|
|
|
2018-01-25 23:55:31 +01:00
|
|
|
endif # need_compile_res
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2013-08-28 20:16:06 +02:00
|
|
|
all_res_assets := $(all_resources)
|
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
include $(BUILD_SYSTEM)/java_renderscript.mk
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2014-06-25 22:23:58 +02:00
|
|
|
ifeq (true,$(need_compile_res))
|
2021-11-02 04:54:05 +01:00
|
|
|
# work around missing manifests by creating a default one
|
|
|
|
ifeq (,$(strip $(LOCAL_MANIFEST_FILE)$(LOCAL_FULL_MANIFEST_FILE)))
|
|
|
|
ifeq (,$(wildcard $(LOCAL_PATH)/AndroidManifest.xml))
|
|
|
|
LOCAL_FULL_MANIFEST_FILE := $(call local-intermediates-dir,COMMON)/DefaultManifest.xml
|
|
|
|
$(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE),$(call module-min-sdk-version))
|
|
|
|
endif
|
|
|
|
endif
|
2014-02-06 03:24:45 +01:00
|
|
|
include $(BUILD_SYSTEM)/android_manifest.mk
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2012-01-03 20:52:26 +01:00
|
|
|
LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
|
|
|
|
ifeq ($(LOCAL_SDK_RES_VERSION),)
|
|
|
|
LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
|
|
|
|
endif
|
|
|
|
|
2011-12-14 23:29:28 +01:00
|
|
|
framework_res_package_export :=
|
|
|
|
# Please refer to package.mk
|
|
|
|
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
|
2020-07-08 11:10:38 +02:00
|
|
|
ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_USE_PREBUILT_SDKS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
|
2011-12-14 23:29:28 +01:00
|
|
|
framework_res_package_export := \
|
2018-04-27 15:11:17 +02:00
|
|
|
$(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION))
|
2011-12-14 23:29:28 +01:00
|
|
|
else
|
|
|
|
framework_res_package_export := \
|
|
|
|
$(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2023-06-24 01:17:54 +02:00
|
|
|
# transitive-res-packages is only populated for Soong modules for now, but needs
|
|
|
|
# to exist so that other Make modules can depend on it. Create an empty file.
|
|
|
|
my_transitive_res_packages := $(intermediates.COMMON)/transitive-res-packages
|
|
|
|
$(my_transitive_res_packages):
|
|
|
|
touch $@
|
|
|
|
|
2018-05-23 22:35:53 +02:00
|
|
|
import_proguard_flag_files := $(strip $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
|
2018-02-10 00:19:11 +01:00
|
|
|
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags))
|
|
|
|
$(intermediates.COMMON)/export_proguard_flags: $(import_proguard_flag_files) $(addprefix $(LOCAL_PATH)/,$(LOCAL_EXPORT_PROGUARD_FLAG_FILES))
|
2017-11-17 22:11:26 +01:00
|
|
|
@echo "Export proguard flags: $@"
|
|
|
|
rm -f $@
|
2018-02-10 00:19:11 +01:00
|
|
|
touch $@
|
|
|
|
for f in $+; do \
|
|
|
|
echo -e "\n# including $$f" >>$@; \
|
|
|
|
cat $$f >>$@; \
|
|
|
|
done
|
|
|
|
import_proguard_flag_files :=
|
2017-11-17 22:11:26 +01:00
|
|
|
|
2018-03-07 03:18:06 +01:00
|
|
|
include $(BUILD_SYSTEM)/aapt_flags.mk
|
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS)
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS)
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
|
|
|
|
|
2011-12-14 23:29:28 +01:00
|
|
|
# add --non-constant-id to prevent inlining constants.
|
2014-12-18 02:00:53 +01:00
|
|
|
# AAR needs text symbol file R.txt.
|
2018-03-12 22:56:27 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --output-text-symbols $(intermediates.COMMON)/R.txt
|
2017-08-17 00:52:53 +02:00
|
|
|
ifndef LOCAL_AAPT_NAMESPACES
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS += --no-static-lib-packages
|
|
|
|
endif
|
2016-02-26 20:13:43 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_CONFIG :=
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS :=
|
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
|
2016-02-26 20:13:43 +01:00
|
|
|
|
2015-12-04 22:59:18 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR :=
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME :=
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR :=
|
|
|
|
|
2019-02-26 07:21:24 +01:00
|
|
|
# One more level with name res so we can zip up the flat resources that can be linked by apps.
|
|
|
|
my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/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
|
|
|
|
include $(BUILD_SYSTEM)/aapt2.mk
|
|
|
|
$(my_res_package) : $(framework_res_package_export)
|
|
|
|
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(intermediates.COMMON)/R.txt
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2018-03-07 01:21:36 +01:00
|
|
|
endif # need_compile_res
|
|
|
|
|
|
|
|
include $(BUILD_SYSTEM)/java_library.mk
|
|
|
|
|
|
|
|
ifeq (true,$(need_compile_res))
|
|
|
|
|
2016-12-21 23:29:13 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
|
2017-05-27 00:22:02 +02:00
|
|
|
$(java_source_list_file): $(R_file_stamp)
|
2016-12-21 23:29:13 +01:00
|
|
|
$(full_classes_compiled_jar): $(R_file_stamp)
|
2017-08-31 23:43:04 +02:00
|
|
|
$(full_classes_turbine_jar): $(R_file_stamp)
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2016-11-15 02:18:55 +01:00
|
|
|
|
|
|
|
# if we have custom proguarding done use the proguarded classes jar instead of the normal classes jar
|
|
|
|
ifeq ($(filter custom,$(LOCAL_PROGUARD_ENABLED)),custom)
|
|
|
|
aar_classes_jar = $(full_classes_jar)
|
2017-03-29 21:58:15 +02:00
|
|
|
else
|
|
|
|
aar_classes_jar = $(full_classes_pre_proguard_jar)
|
2016-11-15 02:18:55 +01:00
|
|
|
endif
|
|
|
|
|
2014-12-18 02:00:53 +01:00
|
|
|
# Rule to build AAR, archive including classes.jar, resource, etc.
|
|
|
|
built_aar := $(intermediates.COMMON)/javalib.aar
|
|
|
|
$(built_aar): PRIVATE_MODULE := $(LOCAL_MODULE)
|
|
|
|
$(built_aar): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
|
2016-11-15 02:18:55 +01:00
|
|
|
$(built_aar): PRIVATE_CLASSES_JAR := $(aar_classes_jar)
|
2014-12-18 02:00:53 +01:00
|
|
|
$(built_aar): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
|
2018-03-12 22:56:27 +01:00
|
|
|
$(built_aar): PRIVATE_R_TXT := $(intermediates.COMMON)/R.txt
|
2017-08-11 00:24:10 +02:00
|
|
|
$(built_aar): $(JAR_ARGS)
|
2018-03-12 22:56:27 +01:00
|
|
|
$(built_aar) : $(aar_classes_jar) $(full_android_manifest) $(intermediates.COMMON)/R.txt
|
2014-12-18 02:00:53 +01:00
|
|
|
@echo "target AAR: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(hide) rm -rf $(dir $@)aar && mkdir -p $(dir $@)aar/res
|
|
|
|
$(hide) cp $(PRIVATE_ANDROID_MANIFEST) $(dir $@)aar/AndroidManifest.xml
|
|
|
|
$(hide) cp $(PRIVATE_CLASSES_JAR) $(dir $@)aar/classes.jar
|
|
|
|
# Note: Use "cp -n" to honor the resource overlay rules, if multiple res dirs exist.
|
|
|
|
$(hide) $(foreach res,$(PRIVATE_RESOURCE_DIR),cp -Rfn $(res)/* $(dir $@)aar/res;)
|
|
|
|
$(hide) cp $(PRIVATE_R_TXT) $(dir $@)aar/R.txt
|
2017-06-30 22:55:38 +02:00
|
|
|
$(hide) $(JAR) -cMf $@ \
|
2017-08-17 08:33:17 +02:00
|
|
|
$(call jar-args-sorted-files-in-directory,$(dir $@)aar)
|
2014-12-18 02:00:53 +01:00
|
|
|
|
|
|
|
# Register the aar file.
|
2020-05-08 09:38:46 +02:00
|
|
|
ALL_MODULES.$(my_register_name).AAR := $(built_aar)
|
2014-06-25 22:23:58 +02:00
|
|
|
endif # need_compile_res
|
2011-12-14 23:29:28 +01:00
|
|
|
|
2013-08-28 22:04:46 +02:00
|
|
|
# Reset internal variables.
|
2016-11-15 02:18:55 +01:00
|
|
|
aar_classes_jar :=
|
2013-08-28 22:04:46 +02:00
|
|
|
all_res_assets :=
|
2009-03-04 04:28:42 +01:00
|
|
|
LOCAL_IS_STATIC_JAVA_LIBRARY :=
|