The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 24 | |
| 25 | # Hack to build static Java library with Android resource |
| 26 | # See bug 5714516 |
| 27 | all_resources := |
| 28 | ifdef LOCAL_RESOURCE_DIR |
| 29 | all_resources := $(strip \ |
| 30 | $(foreach dir, $(LOCAL_RESOURCE_DIR), \ |
| 31 | $(addprefix $(dir)/, \ |
| 32 | $(patsubst res/%,%, \ |
| 33 | $(call find-subdir-assets,$(dir)) \ |
| 34 | ) \ |
| 35 | ) \ |
| 36 | )) |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 37 | |
| 38 | ifneq (,$(all_resources)) |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame^] | 39 | # By default we should remove the R/Manifest classes from a static Java library, |
| 40 | # because they will be regenerated in the app that uses it. |
| 41 | # But if the static Java library will be used by a library, then we may need to |
| 42 | # keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none". |
| 43 | ifndef LOCAL_JAR_EXCLUDE_FILES |
| 44 | LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES) |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 45 | endif |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame^] | 46 | ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES)) |
| 47 | LOCAL_JAR_EXCLUDE_FILES := |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 48 | endif |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame^] | 49 | endif # all_resources |
| 50 | endif # LOCAL_RESOURCE_DIR |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 51 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | include $(BUILD_SYSTEM)/java_library.mk |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 53 | |
| 54 | ifneq (,$(all_resources)) |
| 55 | R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp |
| 56 | |
| 57 | ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) |
| 58 | LOCAL_MANIFEST_FILE := AndroidManifest.xml |
| 59 | endif |
| 60 | full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) |
| 61 | |
Ying Wang | aaa8f06 | 2012-01-03 11:52:26 -0800 | [diff] [blame] | 62 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 63 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 64 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 65 | endif |
| 66 | |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 67 | framework_res_package_export := |
| 68 | framework_res_package_export_deps := |
| 69 | # Please refer to package.mk |
| 70 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
Ying Wang | 0ec188f | 2012-05-10 17:25:51 -0700 | [diff] [blame] | 71 | ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_RES_VERSION))),) |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 72 | framework_res_package_export := \ |
| 73 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
| 74 | framework_res_package_export_deps := $(framework_res_package_export) |
| 75 | else |
| 76 | framework_res_package_export := \ |
| 77 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
| 78 | framework_res_package_export_deps := \ |
| 79 | $(dir $(framework_res_package_export))src/R.stamp |
| 80 | endif |
| 81 | endif |
| 82 | |
| 83 | $(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 84 | # add --non-constant-id to prevent inlining constants. |
| 85 | $(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id |
| 86 | $(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) |
| 87 | $(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
| 88 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml |
| 89 | $(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) |
| 90 | $(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) |
| 91 | ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) |
| 92 | $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 93 | else |
| 94 | $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 95 | endif |
| 96 | $(R_file_stamp): PRIVATE_ASSET_DIR := |
| 97 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := |
| 98 | $(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME := |
| 99 | $(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := |
| 100 | |
| 101 | $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps) |
| 102 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 103 | $(create-resource-java-files) |
| 104 | $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ |
| 105 | |
| 106 | $(LOCAL_BUILT_MODULE): $(R_file_stamp) |
| 107 | ifneq ($(full_classes_jar),) |
| 108 | $(full_classes_compiled_jar): $(R_file_stamp) |
| 109 | endif |
| 110 | |
| 111 | endif # $(all_resources) not empty |
| 112 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 113 | LOCAL_IS_STATIC_JAVA_LIBRARY := |