2009-03-04 11:28:42 +08: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.
|
|
|
|
|
|
|
|
LOCAL_UNINSTALLABLE_MODULE := true
|
|
|
|
LOCAL_IS_STATIC_JAVA_LIBRARY := true
|
2013-03-27 03:42:32 +08:00
|
|
|
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
2011-12-15 06:29:28 +08:00
|
|
|
|
2016-01-12 05:34:16 +08:00
|
|
|
#################################
|
|
|
|
include $(BUILD_SYSTEM)/configure_local_jack.mk
|
|
|
|
#################################
|
|
|
|
|
2015-12-05 05:59:18 +08:00
|
|
|
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
|
|
|
|
|
|
|
|
my_res_package :=
|
|
|
|
|
2011-12-15 06:29:28 +08:00
|
|
|
# Hack to build static Java library with Android resource
|
|
|
|
# See bug 5714516
|
|
|
|
all_resources :=
|
2014-06-26 04:23:58 +08:00
|
|
|
need_compile_res :=
|
|
|
|
# A static Java library needs to explicily set LOCAL_RESOURCE_DIR.
|
2011-12-15 06:29:28 +08:00
|
|
|
ifdef LOCAL_RESOURCE_DIR
|
2014-06-26 04:23:58 +08:00
|
|
|
need_compile_res := true
|
2015-12-05 05:59:18 +08:00
|
|
|
|
2011-12-15 06:29:28 +08:00
|
|
|
all_resources := $(strip \
|
|
|
|
$(foreach dir, $(LOCAL_RESOURCE_DIR), \
|
|
|
|
$(addprefix $(dir)/, \
|
|
|
|
$(patsubst res/%,%, \
|
|
|
|
$(call find-subdir-assets,$(dir)) \
|
|
|
|
) \
|
|
|
|
) \
|
|
|
|
))
|
2011-12-16 08:36:55 +08:00
|
|
|
|
2012-06-20 01:40:37 +08: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-15 06:29:28 +08:00
|
|
|
endif
|
2012-06-20 01:40:37 +08:00
|
|
|
ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES))
|
|
|
|
LOCAL_JAR_EXCLUDE_FILES :=
|
2012-04-27 03:26:33 +08:00
|
|
|
endif
|
2013-03-27 03:42:32 +08:00
|
|
|
|
|
|
|
proguard_options_file :=
|
|
|
|
|
|
|
|
ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
|
|
|
|
proguard_options_file := $(intermediates.COMMON)/proguard_options
|
|
|
|
endif
|
2014-09-08 20:45:14 +08:00
|
|
|
|
2013-03-27 03:42:32 +08:00
|
|
|
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
|
|
|
|
|
2015-01-09 17:36:40 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
2014-09-08 20:45:14 +08:00
|
|
|
ifndef LOCAL_JACK_PROGUARD_FLAGS
|
|
|
|
LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
|
|
|
|
endif
|
|
|
|
LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS)
|
2015-01-09 17:36:40 +08:00
|
|
|
endif # LOCAL_JACK_ENABLED
|
2014-09-08 20:45:14 +08:00
|
|
|
|
2015-12-05 05:59:18 +08:00
|
|
|
R_file_stamp := $(intermediates.COMMON)/src/R.stamp
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
|
|
|
|
|
2016-02-25 06:11:55 +08:00
|
|
|
ifdef LOCAL_USE_AAPT2
|
2015-12-05 05:59:18 +08:00
|
|
|
# For library we treat all the resource equal with no overlay.
|
|
|
|
my_res_resources := $(all_resources)
|
|
|
|
my_overlay_resources :=
|
|
|
|
# For libraries put everything in the COMMON intermediate directory.
|
|
|
|
my_res_package := $(intermediates.COMMON)/package-res.apk
|
|
|
|
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
|
2016-02-25 06:11:55 +08:00
|
|
|
endif # LOCAL_USE_AAPT2
|
2012-06-20 01:40:37 +08:00
|
|
|
endif # LOCAL_RESOURCE_DIR
|
2011-12-15 06:29:28 +08:00
|
|
|
|
2013-08-29 02:16:06 +08:00
|
|
|
all_res_assets := $(all_resources)
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
include $(BUILD_SYSTEM)/java_library.mk
|
2011-12-15 06:29:28 +08:00
|
|
|
|
2014-06-26 04:23:58 +08:00
|
|
|
ifeq (true,$(need_compile_res))
|
2014-02-06 10:24:45 +08:00
|
|
|
include $(BUILD_SYSTEM)/android_manifest.mk
|
2011-12-15 06:29:28 +08:00
|
|
|
|
2012-01-04 03:52:26 +08: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-15 06:29:28 +08:00
|
|
|
framework_res_package_export :=
|
|
|
|
framework_res_package_export_deps :=
|
|
|
|
# Please refer to package.mk
|
|
|
|
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
|
2015-11-06 23:20:51 +08:00
|
|
|
ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
|
2011-12-15 06:29:28 +08:00
|
|
|
framework_res_package_export := \
|
|
|
|
$(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
|
|
|
|
framework_res_package_export_deps := $(framework_res_package_export)
|
|
|
|
else
|
|
|
|
framework_res_package_export := \
|
|
|
|
$(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
|
|
|
|
framework_res_package_export_deps := \
|
|
|
|
$(dir $(framework_res_package_export))src/R.stamp
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# add --non-constant-id to prevent inlining constants.
|
2014-12-18 09:00:53 +08:00
|
|
|
# AAR needs text symbol file R.txt.
|
2016-02-25 06:11:55 +08:00
|
|
|
ifdef LOCAL_USE_AAPT2
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --no-static-lib-packages
|
2015-12-05 05:59:18 +08:00
|
|
|
else
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(LOCAL_INTERMEDIATE_SOURCE_DIR)
|
|
|
|
endif
|
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
|
|
|
|
$(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)
|
2015-11-06 23:20:51 +08:00
|
|
|
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
|
2015-12-05 05:59:18 +08:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
|
2011-12-15 06:29:28 +08:00
|
|
|
else
|
2015-12-05 05:59:18 +08:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
|
2011-12-15 06:29:28 +08:00
|
|
|
endif
|
2015-12-05 05:59:18 +08: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 :=
|
|
|
|
|
2016-02-25 06:11:55 +08:00
|
|
|
ifdef LOCAL_USE_AAPT2
|
2015-12-05 05:59:18 +08:00
|
|
|
# For libraries don't use any product specific flags.
|
|
|
|
my_aapt_characteristics :=
|
|
|
|
# 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
|
2016-02-25 06:11:55 +08:00
|
|
|
my_generated_res_dirs := $(rs_generated_res_dir)
|
|
|
|
my_generated_res_dirs_deps := $(RenderScript_file_stamp)
|
2015-12-05 05:59:18 +08:00
|
|
|
include $(BUILD_SYSTEM)/aapt2.mk
|
|
|
|
$(my_res_package) : $(framework_res_package_export_deps)
|
|
|
|
else
|
2011-12-15 06:29:28 +08:00
|
|
|
$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps)
|
|
|
|
@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(create-resource-java-files)
|
|
|
|
$(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@
|
2016-02-25 06:11:55 +08:00
|
|
|
endif # LOCAL_USE_AAPT2
|
2011-12-15 06:29:28 +08:00
|
|
|
|
|
|
|
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
|
2015-01-09 17:36:40 +08:00
|
|
|
ifdef LOCAL_JACK_ENABLED
|
2014-09-08 20:45:14 +08:00
|
|
|
$(noshrob_classes_jack): $(R_file_stamp)
|
|
|
|
$(full_classes_jack): $(R_file_stamp)
|
2015-01-09 17:36:40 +08:00
|
|
|
endif # LOCAL_JACK_ENABLED
|
2011-12-15 06:29:28 +08:00
|
|
|
$(full_classes_compiled_jar): $(R_file_stamp)
|
|
|
|
|
2014-12-18 09:00:53 +08: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)
|
|
|
|
$(built_aar): PRIVATE_CLASSES_JAR := $(LOCAL_BUILT_MODULE)
|
|
|
|
$(built_aar): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
|
|
|
|
$(built_aar): PRIVATE_R_TXT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.txt
|
|
|
|
$(built_aar) : $(LOCAL_BUILT_MODULE)
|
|
|
|
@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
|
|
|
|
$(hide) jar -cMf $@ \
|
|
|
|
-C $(dir $@)aar .
|
|
|
|
|
|
|
|
# Register the aar file.
|
|
|
|
ALL_MODULES.$(LOCAL_MODULE).AAR := $(built_aar)
|
2014-06-26 04:23:58 +08:00
|
|
|
endif # need_compile_res
|
2011-12-15 06:29:28 +08:00
|
|
|
|
2013-08-29 04:04:46 +08:00
|
|
|
# Reset internal variables.
|
|
|
|
all_res_assets :=
|
2009-03-04 11:28:42 +08:00
|
|
|
LOCAL_IS_STATIC_JAVA_LIBRARY :=
|