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)) |
| 39 | # Those files will be excluded from the built jar. |
| 40 | # The R/Manifest classes should be re-generated in the app Module instead. |
| 41 | # Use '' and $ escape because they will be passed to bash. |
Ying Wang | 83dbd2f | 2012-04-26 12:26:33 -0700 | [diff] [blame] | 42 | ifneq (true,$(LOCAL_KEEP_R_CLASS_IN_STATIC_JAVA_LIBRARY)) |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 43 | LOCAL_JAR_EXCLUDE_FILES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class' |
| 44 | endif |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 45 | endif |
Ying Wang | 83dbd2f | 2012-04-26 12:26:33 -0700 | [diff] [blame] | 46 | endif |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 47 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 48 | include $(BUILD_SYSTEM)/java_library.mk |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 49 | |
| 50 | ifneq (,$(all_resources)) |
| 51 | R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp |
| 52 | |
| 53 | ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) |
| 54 | LOCAL_MANIFEST_FILE := AndroidManifest.xml |
| 55 | endif |
| 56 | full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) |
| 57 | |
Ying Wang | aaa8f06 | 2012-01-03 11:52:26 -0800 | [diff] [blame] | 58 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 59 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 60 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 61 | endif |
| 62 | |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 63 | framework_res_package_export := |
| 64 | framework_res_package_export_deps := |
| 65 | # Please refer to package.mk |
| 66 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
Ying Wang | 0ec188f | 2012-05-10 17:25:51 -0700 | [diff] [blame] | 67 | 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] | 68 | framework_res_package_export := \ |
| 69 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
| 70 | framework_res_package_export_deps := $(framework_res_package_export) |
| 71 | else |
| 72 | framework_res_package_export := \ |
| 73 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
| 74 | framework_res_package_export_deps := \ |
| 75 | $(dir $(framework_res_package_export))src/R.stamp |
| 76 | endif |
| 77 | endif |
| 78 | |
| 79 | $(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 80 | # add --non-constant-id to prevent inlining constants. |
| 81 | $(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id |
| 82 | $(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) |
| 83 | $(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
| 84 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml |
| 85 | $(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) |
| 86 | $(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) |
| 87 | ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) |
| 88 | $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 89 | else |
| 90 | $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 91 | endif |
| 92 | $(R_file_stamp): PRIVATE_ASSET_DIR := |
| 93 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := |
| 94 | $(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME := |
| 95 | $(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := |
| 96 | |
| 97 | $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps) |
| 98 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 99 | $(create-resource-java-files) |
| 100 | $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ |
| 101 | |
| 102 | $(LOCAL_BUILT_MODULE): $(R_file_stamp) |
| 103 | ifneq ($(full_classes_jar),) |
| 104 | $(full_classes_compiled_jar): $(R_file_stamp) |
| 105 | endif |
| 106 | |
| 107 | endif # $(all_resources) not empty |
| 108 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 109 | LOCAL_IS_STATIC_JAVA_LIBRARY := |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 110 | LOCAL_JAR_EXCLUDE_FILES := |