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
6sdk_props := $(patsubst \
7               $(TOPDIR)development/sdk/%_source.prop_template, \
8               $(HOST_OUT)/development/sdk/%_source.properties, \
9               $(wildcard $(TOPDIR)development/sdk/*_source.prop_template))
10sample_props := $(patsubst \
11                  $(TOPDIR)development/samples/%_source.prop_template, \
12                  $(HOST_OUT)/development/samples/%_source.properties, \
13                  $(wildcard $(TOPDIR)development/samples/*_source.prop_template))
14sys_img_props := $(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))
18ALL_SDK_FILES += $(sdk_props) $(sample_props) $(sys_img_props)
19
20# Rule to convert a source.prop template into the desired source.property
21# This needs to vary based on the CPU ABI for the system-image files.
22# Rewritten variables:
23# - ${PLATFORM_VERSION}          e.g. "1.0"
24# - ${PLATFORM_SDK_VERSION}      e.g. "3", aka the API level
25# - ${PLATFORM_VERSION_CODENAME} e.g. "REL" (transformed into "") or "Cupcake"
26# - ${TARGET_ARCH}               e.g. "arm", "x86", "mips" and their 64-bit variants.
27# - ${TARGET_CPU_ABI}            e.g. "armeabi", "x86", "mips" and their 64-bit variants.
28$(sys_img_props) : $(HOST_OUT)/development/sys-img-$(TARGET_CPU_ABI)/%_source.properties : $(TOPDIR)development/sys-img/%_source.prop_template
29	@echo Generate $@
30	$(hide) mkdir -p $(dir $@)
31	$(hide) sed \
32		-e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
33		-e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
34		-e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
35		-e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \
36		-e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \
37		$< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
38
39$(sdk_props) : $(HOST_OUT)/development/sdk/%_source.properties : $(TOPDIR)development/sdk/%_source.prop_template
40	@echo Generate $@
41	$(hide) mkdir -p $(dir $@)
42	$(hide) sed \
43		-e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
44		-e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
45		-e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
46		$< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
47
48$(sample_props) : $(HOST_OUT)/development/samples/%_source.properties : $(TOPDIR)development/samples/%_source.prop_template
49	@echo Generate $@
50	$(hide) mkdir -p $(dir $@)
51	$(hide) sed\
52		-e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
53		-e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
54		-e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
55		$< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
56
57
58# ===== SDK jar file of stubs =====
59# A.k.a the "current" version of the public SDK (android.jar inside the SDK package).
60full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_stubs_current,,COMMON)/classes.jar
61full_src_target := $(OUT_DOCS)/api-stubs-docs-stubs.srcjar
62
63.PHONY: android_stubs
64android_stubs: $(full_target) $(full_src_target)
65
66# android.jar is what we put in the SDK package.
67android_jar_intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/android_jar_intermediates
68android_jar_full_target := $(android_jar_intermediates)/android.jar
69android_jar_src_target := $(android_jar_intermediates)/android-stubs-src.jar
70
71# unzip and zip android.jar before packaging it. (workaround for b/127733650)
72full_target_repackaged := $(android_jar_intermediates)/repackaged/repackaged.jar
73$(full_target_repackaged): $(full_target) | $(ZIPTIME)
74	@echo Repackaging SDK jar: $@
75	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
76	unzip -q $< -d $(dir $@)
77	cd $(dir $@) && zip -rqX $(notdir $@) *
78	$(remove-timestamps-from-package)
79
80$(android_jar_full_target): $(full_target_repackaged)
81	@echo Package SDK Stubs: $@
82	$(copy-file-to-target)
83
84$(android_jar_src_target): $(full_src_target)
85	@echo Package SDK Stubs Source: $@
86	$(hide)mkdir -p $(dir $@)
87	$(hide)$(ACP) $< $@
88
89ALL_SDK_FILES += $(android_jar_full_target)
90ALL_SDK_FILES += $(android_jar_src_target)
91
92# ====================================================
93
94# The uiautomator stubs
95ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/classes.jar
96
97# org.apache.http.legacy.jar stubs
98ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/org.apache.http.legacy.stubs_intermediates/classes.jar
99
100# test stubs
101ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.mock.stubs_intermediates/classes.jar
102ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.base.stubs_intermediates/classes.jar
103ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.runner.stubs_intermediates/classes.jar
104
105# core-lambda-stubs
106ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/core-lambda-stubs_intermediates/classes.jar
107
108# shrinkedAndroid.jar for multidex support
109ALL_SDK_FILES += $(HOST_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/shrinkedAndroid_intermediates/shrinkedAndroid.jar
110
111# ======= Lint API XML ===========
112ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api-stubs-docs_generated-api-versions.xml
113
114# ============ SDK AIDL ============
115$(eval $(call copy-one-file,$(FRAMEWORK_AIDL),$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework.aidl))
116ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework.aidl
117
118# ============ System SDK ============
119full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_system_stubs_current,,COMMON)/classes.jar
120
121.PHONY: android_system_stubs
122android_system_stubs: $(full_target)
123
124# Build and store the android_system.jar.
125$(call dist-for-goals,sdk win_sdk,$(full_target):android_system.jar)
126$(call dist-for-goals,sdk win_sdk,$(full_target):apistubs/android/system/android.jar)
127
128# ============ Test SDK ============
129full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_test_stubs_current,,COMMON)/classes.jar
130
131.PHONY: android_test_stubs
132android_test_stubs: $(full_target)
133
134# Build and store the android_test.jar.
135$(call dist-for-goals,sdk win_sdk,$(full_target):android_test.jar)
136$(call dist-for-goals,sdk win_sdk,$(full_target):apistubs/android/test/android.jar)
137