1# ===== SDK source.property files ===== 2 3# Add all files to be generated from the source.prop templates to the SDK pre-requisites 4ALL_SDK_FILES += $(patsubst \ 5 $(TOPDIR)development/sdk/%_source.prop_template, \ 6 $(HOST_OUT)/development/sdk/%_source.properties, \ 7 $(wildcard $(TOPDIR)development/sdk/*_source.prop_template)) \ 8 $(patsubst \ 9 $(TOPDIR)development/samples/%_source.prop_template, \ 10 $(HOST_OUT)/development/samples/%_source.properties, \ 11 $(wildcard $(TOPDIR)development/samples/*_source.prop_template)) 12 13# Rule to convert a source.prop template into the desired source.property 14# Rewritten variables: 15# - ${PLATFORM_VERSION} e.g. "1.0" 16# - ${PLATFORM_SDK_VERSION} e.g. "3", aka the API level 17# - ${PLATFORM_VERSION_CODENAME} e.g. "REL" (transformed into "") or "Cupcake" 18$(HOST_OUT)/development/sdk/%_source.properties : $(TOPDIR)development/sdk/%_source.prop_template 19 @echo Generate $@ 20 $(hide) mkdir -p $(dir $@) 21 $(hide) sed -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \ 22 -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \ 23 -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \ 24 $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@ 25 26$(HOST_OUT)/development/samples/%_source.properties : $(TOPDIR)development/samples/%_source.prop_template 27 @echo Generate $@ 28 $(hide) mkdir -p $(dir $@) 29 $(hide) sed -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \ 30 -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \ 31 -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \ 32 $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@ 33 34 35# ===== Android Support/Compatibility Library ===== 36 37LOCAL_PATH := $(call my-dir) 38 39# The source files for this library are _all_ generated, something we don't do 40# anywhere else, and the rules don't support. Aditionally, the depenencies on 41# these files don't really matter, because they are all generated as part of 42# building the docs. So for the dependency, we just use the 43# api-stubs-timestamp file, which is the $@ of the droiddoc rule. 44# We also need to depend on framework-res.apk, in order to pull the 45# resource files out of there for aapt. 46# 47# Normally the package rule runs aapt, which includes the resource, 48# but we're not running that in our package rule so just copy in the 49# resource files here. 50intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_stubs_current_intermediates 51full_target := $(intermediates)/classes.jar 52src_dir := $(intermediates)/src 53classes_dir := $(intermediates)/classes 54framework_res_package := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 55 56$(full_target): PRIVATE_SRC_DIR := $(src_dir) 57$(full_target): PRIVATE_INTERMEDIATES_DIR := $(intermediates) 58$(full_target): PRIVATE_CLASS_INTERMEDIATES_DIR := $(classes_dir) 59$(full_target): PRIVATE_FRAMEWORK_RES_PACKAGE := $(framework_res_package) 60 61$(full_target): $(OUT_DOCS)/api-stubs-timestamp $(framework_res_package) 62 @echo Compiling SDK Stubs: $@ 63 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) 64 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) 65 $(hide) find $(PRIVATE_SRC_DIR) -name "*.java" > \ 66 $(PRIVATE_INTERMEDIATES_DIR)/java-source-list 67 $(hide) $(TARGET_JAVAC) -encoding ascii -bootclasspath "" \ 68 -g $(xlint_unchecked) \ 69 -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \ 70 \@$(PRIVATE_INTERMEDIATES_DIR)/java-source-list \ 71 || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) 72 $(hide) if [ ! -f $(PRIVATE_FRAMEWORK_RES_PACKAGE) ]; then \ 73 echo Missing file $(PRIVATE_FRAMEWORK_RES_PACKAGE); \ 74 rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR); \ 75 exit 1; \ 76 fi; 77 $(hide) unzip -qo $(PRIVATE_FRAMEWORK_RES_PACKAGE) -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) 78 $(hide) (cd $(PRIVATE_CLASS_INTERMEDIATES_DIR) && rm -rf classes.dex META-INF) 79 $(hide) mkdir -p $(dir $@) 80 $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) . 81 $(hide) jar -u0f $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) resources.arsc 82 83.PHONY: android_stubs 84android_stubs: $(full_target) 85 86# The real rules create a javalib.jar that contains a classes.dex file. This 87# code is never going to be run anywhere, so just make a copy of the file. 88# The package installation stuff doesn't know about this file, so nobody will 89# ever be able to write a rule that installs it to a device. 90$(dir $(full_target))javalib.jar: $(full_target) 91 $(hide)$(ACP) $< $@ 92 93 94android_jar_intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/android_jar_intermediates 95android_jar_full_target := $(android_jar_intermediates)/android.jar 96 97$(android_jar_full_target): $(full_target) 98 @echo Package SDK Stubs: $@ 99 $(hide)mkdir -p $(dir $@) 100 $(hide)$(ACP) $< $@ 101 102ALL_SDK_FILES += $(android_jar_full_target) 103 104# The uiautomator stubs 105ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/javalib.jar 106 107# $(1): the Java library name 108define _package_sdk_library 109$(eval _psm_build_module := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(1)_intermediates/javalib.jar) 110$(eval _psm_packaging_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(1)_intermediates/$(1).jar) 111$(_psm_packaging_target) : $(_psm_build_module) | $(ACP) 112 @echo "Package $(1).jar: $$@" 113 $(hide) mkdir -p $$(dir $$@) 114 $(hide) $(ACP) $$< $$@ 115 116ALL_SDK_FILES += $(_psm_packaging_target) 117$(eval _psm_build_module :=) 118$(eval _psm_packaging_target :=) 119endef 120 121ANDROID_SUPPORT_LIBRARIES := android-support-v4 android-support-v7-gridlayout android-support-v13 122 123$(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib)))) 124