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 := 29need_compile_res := 30# A static Java library needs to explicily set LOCAL_RESOURCE_DIR. 31ifdef LOCAL_RESOURCE_DIR 32need_compile_res := true 33all_resources := $(strip \ 34 $(foreach dir, $(LOCAL_RESOURCE_DIR), \ 35 $(addprefix $(dir)/, \ 36 $(patsubst res/%,%, \ 37 $(call find-subdir-assets,$(dir)) \ 38 ) \ 39 ) \ 40 )) 41 42# By default we should remove the R/Manifest classes from a static Java library, 43# because they will be regenerated in the app that uses it. 44# But if the static Java library will be used by a library, then we may need to 45# keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none". 46ifndef LOCAL_JAR_EXCLUDE_FILES 47LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES) 48endif 49ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES)) 50LOCAL_JAR_EXCLUDE_FILES := 51endif 52 53proguard_options_file := 54 55intermediates.COMMON := $(call local-intermediates-dir,COMMON) 56ifneq ($(LOCAL_PROGUARD_ENABLED),custom) 57 proguard_options_file := $(intermediates.COMMON)/proguard_options 58endif 59LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) 60 61endif # LOCAL_RESOURCE_DIR 62 63all_res_assets := $(all_resources) 64 65include $(BUILD_SYSTEM)/java_library.mk 66 67ifeq (true,$(need_compile_res)) 68R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp 69 70include $(BUILD_SYSTEM)/android_manifest.mk 71 72LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) 73ifeq ($(LOCAL_SDK_RES_VERSION),) 74 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) 75endif 76 77framework_res_package_export := 78framework_res_package_export_deps := 79# Please refer to package.mk 80ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 81ifneq ($(filter-out current system_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current,$(LOCAL_SDK_RES_VERSION))),) 82framework_res_package_export := \ 83 $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar 84framework_res_package_export_deps := $(framework_res_package_export) 85else 86framework_res_package_export := \ 87 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 88framework_res_package_export_deps := \ 89 $(dir $(framework_res_package_export))src/R.stamp 90endif 91endif 92 93$(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE) 94# add --non-constant-id to prevent inlining constants. 95$(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id 96$(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) 97$(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) 98$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml 99$(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) 100$(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) 101ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) 102$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) 103else 104$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) 105endif 106$(R_file_stamp): PRIVATE_ASSET_DIR := 107$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) 108$(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME := 109$(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := 110 111$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps) 112 @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" 113 $(create-resource-java-files) 114 $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ 115 116$(LOCAL_BUILT_MODULE): $(R_file_stamp) 117ifneq ($(full_classes_jar),) 118$(full_classes_compiled_jar): $(R_file_stamp) 119endif 120 121endif # need_compile_res 122 123# Reset internal variables. 124all_res_assets := 125LOCAL_IS_STATIC_JAVA_LIBRARY := 126