1LOCAL_PATH := $(call my-dir) 2 3# ===== SDK source.property files ===== 4 5# Add all files to be generated from the source.prop templates to the SDK pre-requisites 6ALL_SDK_FILES += $(patsubst \ 7 $(TOPDIR)development/sdk/%_source.prop_template, \ 8 $(HOST_OUT)/development/sdk/%_source.properties, \ 9 $(wildcard $(TOPDIR)development/sdk/*_source.prop_template)) \ 10 $(patsubst \ 11 $(TOPDIR)development/samples/%_source.prop_template, \ 12 $(HOST_OUT)/development/samples/%_source.properties, \ 13 $(wildcard $(TOPDIR)development/samples/*_source.prop_template)) \ 14 $(patsubst \ 15 $(TOPDIR)development/sys-img/%_source.prop_template, \ 16 $(HOST_OUT)/development/sys-img-$(TARGET_CPU_ABI)/%_source.properties, \ 17 $(wildcard $(TOPDIR)development/sys-img/*_source.prop_template)) 18 19# Rule to convert a source.prop template into the desired source.property 20# This needs to vary based on the CPU ABI for the system-image files. 21# Rewritten variables: 22# - ${PLATFORM_VERSION} e.g. "1.0" 23# - ${PLATFORM_SDK_VERSION} e.g. "3", aka the API level 24# - ${PLATFORM_VERSION_CODENAME} e.g. "REL" (transformed into "") or "Cupcake" 25# - ${TARGET_ARCH} e.g. "arm", "x86", "mips" and their 64-bit variants. 26# - ${TARGET_CPU_ABI} e.g. "armeabi", "x86", "mips" and their 64-bit variants. 27$(HOST_OUT)/development/sys-img-$(TARGET_CPU_ABI)/%_source.properties : $(TOPDIR)development/sys-img/%_source.prop_template 28 @echo Generate $@ 29 $(hide) mkdir -p $(dir $@) 30 $(hide) sed \ 31 -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \ 32 -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \ 33 -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \ 34 -e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \ 35 -e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \ 36 $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@ 37 38$(HOST_OUT)/development/sdk/%_source.properties : $(TOPDIR)development/sdk/%_source.prop_template 39 @echo Generate $@ 40 $(hide) mkdir -p $(dir $@) 41 $(hide) sed \ 42 -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \ 43 -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \ 44 -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \ 45 $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@ 46 47$(HOST_OUT)/development/samples/%_source.properties : $(TOPDIR)development/samples/%_source.prop_template 48 @echo Generate $@ 49 $(hide) mkdir -p $(dir $@) 50 $(hide) sed\ 51 -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \ 52 -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \ 53 -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \ 54 $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@ 55 56 57# ===== SDK jar file of stubs ===== 58# A.k.a the "current" version of the public SDK (android.jar inside the SDK package). 59sdk_stub_name := android_stubs_current 60stub_timestamp := $(OUT_DOCS)/api-stubs-timestamp 61include $(LOCAL_PATH)/build_android_stubs.mk 62 63.PHONY: android_stubs 64android_stubs: $(full_target) $(full_src_target) 65 66# The real rules create a javalib.jar that contains a classes.dex file. This 67# code is never going to be run anywhere, so just make a copy of the file. 68# The package installation stuff doesn't know about this file, so nobody will 69# ever be able to write a rule that installs it to a device. 70$(dir $(full_target))javalib.jar: $(full_target) 71 $(copy-file-to-target) 72 73# android.jar is what we put in the SDK package. 74android_jar_intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/android_jar_intermediates 75android_jar_full_target := $(android_jar_intermediates)/android.jar 76android_jar_src_target := $(android_jar_intermediates)/android-stubs-src.jar 77 78$(android_jar_full_target): $(full_target) 79 @echo Package SDK Stubs: $@ 80 $(copy-file-to-target) 81 82$(android_jar_src_target): $(full_src_target) 83 @echo Package SDK Stubs Source: $@ 84 $(hide)mkdir -p $(dir $@) 85 $(hide)$(ACP) $< $@ 86 87ALL_SDK_FILES += $(android_jar_full_target) 88ALL_SDK_FILES += $(android_jar_src_target) 89 90# ==================================================== 91 92# The Jack & Jill compiler jars 93ALL_SDK_FILES += prebuilts/sdk/tools/jacks/jack-$(JACK_SDKTOOL_VERSION).jar 94ALL_SDK_FILES += prebuilts/sdk/tools/jills/jill-$(JACK_SDKTOOL_VERSION).jar 95 96# The Jack reporter tool for code coverage 97ALL_SDK_FILES += prebuilts/sdk/tools/jack-jacoco-reporter.jar 98ALL_SDK_FILES += prebuilts/sdk/tools/jack-coverage-plugin.jar 99 100# The uiautomator stubs 101ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/javalib.jar 102 103# org.apache.http.legacy.jar stubs 104ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/org.apache.http.legacy_intermediates/javalib.jar 105 106# $(1): the Java library name 107define _package_sdk_library 108$(eval _psm_build_module := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(1)_intermediates/javalib.jar) 109$(eval _psm_packaging_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(1)_intermediates/$(1).jar) 110$(_psm_packaging_target) : $(_psm_build_module) 111 @echo "Package $(1).jar: $$@" 112 $$(copy-file-to-target) 113 @# Delete resource generated classes from the jar files. 114 $(hide) zip -d $$@ "*/R.class" "*/R\$$$$*.class" "*/Manifest.class" "*/Manifest\$$$$*.class" >/dev/null 2>&1 || true 115 116ALL_SDK_FILES += $(_psm_packaging_target) 117$(eval _psm_build_module :=) 118$(eval _psm_packaging_target :=) 119endef 120 121# ======= Lint API XML =========== 122 123ALL_SDK_FILES += $(HOST_OUT)/development/sdk/generated-api-versions.xml 124 125api_gen_jar := $(TOPDIR)prebuilts/tools/common/api-generator/api-generator-26.0.0.jar 126api_gen_deps := \ 127 $(TOPDIR)prebuilts/tools/common/m2/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar \ 128 $(TOPDIR)prebuilts/tools/common/m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar \ 129 $(TOPDIR)prebuilts/tools/common/m2/repository/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.jar \ 130 $(TOPDIR)prebuilts/tools/common/m2/repository/com/google/guava/guava/17.0/guava-17.0.jar 131api_gen_classpath := $(subst $(space),:,$(api_gen_jar) $(api_gen_deps)) 132 133 134$(HOST_OUT)/development/sdk/generated-api-versions.xml: $(android_jar_full_target) 135 java -cp $(api_gen_classpath) \ 136 com.android.apigenerator.Main \ 137 --pattern $(TOPDIR)prebuilts/tools/common/api-versions/android-%/android.jar \ 138 --pattern $(TOPDIR)prebuilts/sdk/%/android.jar \ 139 --current-version $(PLATFORM_SDK_VERSION) \ 140 --current-codename $(PLATFORM_VERSION_CODENAME) \ 141 --current-jar $(android_jar_full_target) \ 142 $@ 143 144 145# ============ System SDK ============ 146sdk_stub_name := android_system_stubs_current 147stub_timestamp := $(OUT_DOCS)/system-api-stubs-timestamp 148include $(LOCAL_PATH)/build_android_stubs.mk 149 150.PHONY: android_system_stubs 151android_system_stubs: $(full_target) 152 153# Build and store the android_system.jar. 154$(call dist-for-goals,sdk win_sdk,$(full_target):android_system.jar) 155 156# ============ Test SDK ============ 157sdk_stub_name := android_test_stubs_current 158stub_timestamp := $(OUT_DOCS)/test-api-stubs-timestamp 159include $(LOCAL_PATH)/build_android_stubs.mk 160 161.PHONY: android_test_stubs 162android_test_stubs: $(full_target) 163 164# Build and store the android_test.jar. 165$(call dist-for-goals,sdk win_sdk,$(full_target):android_test.jar) 166