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 | ba71aba | 2013-03-26 12:42:32 -0700 | [diff] [blame] | 24 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 25 | |
| 26 | # Hack to build static Java library with Android resource |
| 27 | # See bug 5714516 |
| 28 | all_resources := |
| 29 | ifdef LOCAL_RESOURCE_DIR |
| 30 | all_resources := $(strip \ |
| 31 | $(foreach dir, $(LOCAL_RESOURCE_DIR), \ |
| 32 | $(addprefix $(dir)/, \ |
| 33 | $(patsubst res/%,%, \ |
| 34 | $(call find-subdir-assets,$(dir)) \ |
| 35 | ) \ |
| 36 | ) \ |
| 37 | )) |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 38 | |
| 39 | ifneq (,$(all_resources)) |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame] | 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". |
| 44 | ifndef LOCAL_JAR_EXCLUDE_FILES |
| 45 | LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES) |
Ying Wang | 5758b8e | 2011-12-15 16:36:55 -0800 | [diff] [blame] | 46 | endif |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame] | 47 | ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES)) |
| 48 | LOCAL_JAR_EXCLUDE_FILES := |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 49 | endif |
Ying Wang | ba71aba | 2013-03-26 12:42:32 -0700 | [diff] [blame] | 50 | |
| 51 | proguard_options_file := |
| 52 | |
| 53 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
| 54 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
| 55 | proguard_options_file := $(intermediates.COMMON)/proguard_options |
| 56 | endif |
| 57 | LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) |
| 58 | |
Ying Wang | ae25ec1 | 2012-06-19 10:40:37 -0700 | [diff] [blame] | 59 | endif # all_resources |
| 60 | endif # LOCAL_RESOURCE_DIR |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 61 | |
Ying Wang | 576e014 | 2013-08-28 11:16:06 -0700 | [diff] [blame] | 62 | all_res_assets := $(all_resources) |
| 63 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 64 | include $(BUILD_SYSTEM)/java_library.mk |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 65 | |
| 66 | ifneq (,$(all_resources)) |
| 67 | R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp |
| 68 | |
Ying Wang | dc7fee9 | 2014-02-05 18:24:45 -0800 | [diff] [blame^] | 69 | include $(BUILD_SYSTEM)/android_manifest.mk |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 70 | |
Ying Wang | aaa8f06 | 2012-01-03 11:52:26 -0800 | [diff] [blame] | 71 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 72 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 73 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 74 | endif |
| 75 | |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 76 | framework_res_package_export := |
| 77 | framework_res_package_export_deps := |
| 78 | # Please refer to package.mk |
| 79 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
Ying Wang | 0ec188f | 2012-05-10 17:25:51 -0700 | [diff] [blame] | 80 | 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] | 81 | framework_res_package_export := \ |
| 82 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
| 83 | framework_res_package_export_deps := $(framework_res_package_export) |
| 84 | else |
| 85 | framework_res_package_export := \ |
| 86 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
| 87 | framework_res_package_export_deps := \ |
| 88 | $(dir $(framework_res_package_export))src/R.stamp |
| 89 | endif |
| 90 | endif |
| 91 | |
| 92 | $(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 93 | # add --non-constant-id to prevent inlining constants. |
| 94 | $(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id |
| 95 | $(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) |
| 96 | $(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
| 97 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml |
| 98 | $(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) |
| 99 | $(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) |
| 100 | ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) |
| 101 | $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 102 | else |
| 103 | $(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 104 | endif |
| 105 | $(R_file_stamp): PRIVATE_ASSET_DIR := |
Ying Wang | ba71aba | 2013-03-26 12:42:32 -0700 | [diff] [blame] | 106 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) |
Ying Wang | 20e2083 | 2011-12-14 14:29:28 -0800 | [diff] [blame] | 107 | $(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME := |
| 108 | $(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := |
| 109 | |
| 110 | $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps) |
| 111 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 112 | $(create-resource-java-files) |
| 113 | $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ |
| 114 | |
| 115 | $(LOCAL_BUILT_MODULE): $(R_file_stamp) |
| 116 | ifneq ($(full_classes_jar),) |
| 117 | $(full_classes_compiled_jar): $(R_file_stamp) |
| 118 | endif |
| 119 | |
| 120 | endif # $(all_resources) not empty |
| 121 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 122 | # Reset internal variables. |
| 123 | all_res_assets := |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 124 | LOCAL_IS_STATIC_JAVA_LIBRARY := |