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 22 LOCAL_UNINSTALLABLE_MODULE := true 23 LOCAL_IS_STATIC_JAVA_LIBRARY := true 24 LOCAL_MODULE_CLASS := JAVA_LIBRARIES 25 26 # Hack to build static Java library with Android resource 27 # See bug 5714516 28 all_resources := 29 need_compile_res := 30 # A static Java library needs to explicily set LOCAL_RESOURCE_DIR. 31 ifdef LOCAL_RESOURCE_DIR 32 need_compile_res := true 33 all_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". 46 ifndef LOCAL_JAR_EXCLUDE_FILES 47 LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES) 48 endif 49 ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES)) 50 LOCAL_JAR_EXCLUDE_FILES := 51 endif 52 53 proguard_options_file := 54 55 intermediates.COMMON := $(call local-intermediates-dir,COMMON) 56 ifneq ($(LOCAL_PROGUARD_ENABLED),custom) 57 proguard_options_file := $(intermediates.COMMON)/proguard_options 58 endif 59 LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) 60 61 endif # LOCAL_RESOURCE_DIR 62 63 all_res_assets := $(all_resources) 64 65 include $(BUILD_SYSTEM)/java_library.mk 66 67 ifeq (true,$(need_compile_res)) 68 R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp 69 70 include $(BUILD_SYSTEM)/android_manifest.mk 71 72 LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) 73 ifeq ($(LOCAL_SDK_RES_VERSION),) 74 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) 75 endif 76 77 framework_res_package_export := 78 framework_res_package_export_deps := 79 # Please refer to package.mk 80 ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 81 ifneq ($(filter-out current system_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current,$(LOCAL_SDK_RES_VERSION))),) 82 framework_res_package_export := \ 83 $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar 84 framework_res_package_export_deps := $(framework_res_package_export) 85 else 86 framework_res_package_export := \ 87 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 88 framework_res_package_export_deps := \ 89 $(dir $(framework_res_package_export))src/R.stamp 90 endif 91 endif 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) 101 ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) 102 $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) 103 else 104 $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) 105 endif 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) 117 ifneq ($(full_classes_jar),) 118 $(full_classes_compiled_jar): $(R_file_stamp) 119 endif 120 121 endif # need_compile_res 122 123 # Reset internal variables. 124 all_res_assets := 125 LOCAL_IS_STATIC_JAVA_LIBRARY := 126