static_java_library.mk revision aaa8f06fe39052b903e6d8f4c2a7e0802788f5b6
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 24 25# Hack to build static Java library with Android resource 26# See bug 5714516 27all_resources := 28ifdef LOCAL_RESOURCE_DIR 29all_resources := $(strip \ 30 $(foreach dir, $(LOCAL_RESOURCE_DIR), \ 31 $(addprefix $(dir)/, \ 32 $(patsubst res/%,%, \ 33 $(call find-subdir-assets,$(dir)) \ 34 ) \ 35 ) \ 36 )) 37 38ifneq (,$(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. 42LOCAL_JAR_EXCLUDE_FILES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class' 43endif 44endif 45 46include $(BUILD_SYSTEM)/java_library.mk 47 48ifneq (,$(all_resources)) 49R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp 50 51ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) 52LOCAL_MANIFEST_FILE := AndroidManifest.xml 53endif 54full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) 55 56LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) 57ifeq ($(LOCAL_SDK_RES_VERSION),) 58 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) 59endif 60 61framework_res_package_export := 62framework_res_package_export_deps := 63# Please refer to package.mk 64ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 65ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION)),) 66framework_res_package_export := \ 67 $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar 68framework_res_package_export_deps := $(framework_res_package_export) 69else 70framework_res_package_export := \ 71 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 72framework_res_package_export_deps := \ 73 $(dir $(framework_res_package_export))src/R.stamp 74endif 75endif 76 77$(R_file_stamp): PRIVATE_MODULE := $(LOCAL_MODULE) 78# add --non-constant-id to prevent inlining constants. 79$(R_file_stamp): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id 80$(R_file_stamp): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) 81$(R_file_stamp): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) 82$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml 83$(R_file_stamp): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) 84$(R_file_stamp): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) 85ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) 86$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) 87else 88$(R_file_stamp): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) 89endif 90$(R_file_stamp): PRIVATE_ASSET_DIR := 91$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := 92$(R_file_stamp): PRIVATE_MANIFEST_PACKAGE_NAME := 93$(R_file_stamp): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := 94 95$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps) 96 @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" 97 $(create-resource-java-files) 98 $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ 99 100$(LOCAL_BUILT_MODULE): $(R_file_stamp) 101ifneq ($(full_classes_jar),) 102$(full_classes_compiled_jar): $(R_file_stamp) 103endif 104 105endif # $(all_resources) not empty 106 107LOCAL_IS_STATIC_JAVA_LIBRARY := 108LOCAL_JAR_EXCLUDE_FILES := 109