1# 2# Copyright (C) 2008 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# Standard rules for building a "static" java library. 18# Static java libraries are not installed, nor listed on any 19# classpaths. They can, however, be included wholesale in 20# other java modules. 21 22LOCAL_UNINSTALLABLE_MODULE := true 23LOCAL_IS_STATIC_JAVA_LIBRARY := true 24LOCAL_MODULE_CLASS := JAVA_LIBRARIES 25 26# Hack to build static Java library with Android resource 27# See bug 5714516 28all_resources := 29ifdef LOCAL_RESOURCE_DIR 30all_resources := $(strip \ 31 $(foreach dir, $(LOCAL_RESOURCE_DIR), \ 32 $(addprefix $(dir)/, \ 33 $(patsubst res/%,%, \ 34 $(call find-subdir-assets,$(dir)) \ 35 ) \ 36 ) \ 37 )) 38 39ifneq (,$(all_resources)) 40# By default we should remove the R/Manifest classes from a static Java library, 41# because they will be regenerated in the app that uses it. 42# But if the static Java library will be used by a library, then we may need to 43# keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none". 44ifndef LOCAL_JAR_EXCLUDE_FILES 45LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES) 46endif 47ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES)) 48LOCAL_JAR_EXCLUDE_FILES := 49endif 50 51proguard_options_file := 52 53intermediates.COMMON := $(call local-intermediates-dir,COMMON) 54ifneq ($(LOCAL_PROGUARD_ENABLED),custom) 55 proguard_options_file := $(intermediates.COMMON)/proguard_options 56endif 57LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) 58 59endif # all_resources 60endif # LOCAL_RESOURCE_DIR 61 62all_res_assets := $(all_resources) 63 64include $(BUILD_SYSTEM)/java_library.mk 65 66ifneq (,$(all_resources)) 67R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp 68 69ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) 70 LOCAL_MANIFEST_FILE := AndroidManifest.xml 71endif 72ifdef LOCAL_FULL_MANIFEST_FILE 73 full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) 74else 75 full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) 76endif 77 78LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) 79ifeq ($(LOCAL_SDK_RES_VERSION),) 80 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) 81endif 82 83framework_res_package_export := 84framework_res_package_export_deps := 85# Please refer to package.mk 86ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 87ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_RES_VERSION))),) 88framework_res_package_export := \ 89 $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar 90framework_res_package_export_deps := $(framework_res_package_export) 91else 92framework_res_package_export := \ 93 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 94framework_res_package_export_deps := \ 95 $(dir $(framework_res_package_export))src/R.stamp 96endif 97endif 98 99$(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE) 100# add --non-constant-id to prevent inlining constants. 101$(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id 102$(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) 103$(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) 104$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml 105$(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) 106$(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) 107ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) 108$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) 109else 110$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) 111endif 112$(R_file_stamp): PRIVATE_ASSET_DIR := 113$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) 114$(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME := 115$(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := 116 117$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps) 118 @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" 119 $(create-resource-java-files) 120 $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ 121 122$(LOCAL_BUILT_MODULE): $(R_file_stamp) 123ifneq ($(full_classes_jar),) 124$(full_classes_compiled_jar): $(R_file_stamp) 125endif 126 127endif # $(all_resources) not empty 128 129# Reset internal variables. 130all_res_assets := 131LOCAL_IS_STATIC_JAVA_LIBRARY := 132