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 := $(call intermediates-dir-for,PACKAGING,android_jar,,COMMON)
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# ===== SDK for system modules =====
93# A subset of the public SDK to convert to system modules for use with javac -source 9 -target 9
94ALL_SDK_FILES += $(call intermediates-dir-for,JAVA_LIBRARIES,core-current-stubs-for-system-modules,,COMMON)/classes.jar
95
96# ====================================================
97
98# The uiautomator stubs
99ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/classes.jar
100
101# org.apache.http.legacy.jar stubs
102ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/org.apache.http.legacy.stubs_intermediates/classes.jar
103
104# test stubs
105ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.mock.stubs_intermediates/classes.jar
106ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.base.stubs_intermediates/classes.jar
107ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.runner.stubs_intermediates/classes.jar
108
109# core-lambda-stubs
110ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/core-lambda-stubs_intermediates/classes.jar
111
112# shrinkedAndroid.jar for multidex support
113ALL_SDK_FILES += $(HOST_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/shrinkedAndroid_intermediates/shrinkedAndroid.jar
114
115# ======= Lint API XML ===========
116full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework-doc-stubs_generated-api-versions.xml
117ALL_SDK_FILES += $(full_target)
118$(call dist-for-goals,sdk win_sdk,$(full_target):data/api-versions.xml)
119
120# ======= Lint Annotations zip ===========
121full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework-doc-stubs_annotations.zip
122ALL_SDK_FILES += $(full_target)
123$(call dist-for-goals,sdk win_sdk,$(full_target):data/annotations.zip)
124
125# ============ SDK AIDL ============
126$(eval $(call copy-one-file,$(FRAMEWORK_AIDL),$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework.aidl))
127ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework.aidl
128
129# ============ System SDK ============
130full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_system_stubs_current,,COMMON)/classes.jar
131
132.PHONY: android_system_stubs
133android_system_stubs: $(full_target)
134
135# Build and store the android_system.jar.
136$(call dist-for-goals,sdk win_sdk,$(full_target):android_system.jar)
137$(call dist-for-goals,sdk win_sdk,$(full_target):apistubs/android/system/android.jar)
138
139# ============ Test SDK ============
140full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_test_stubs_current,,COMMON)/classes.jar
141
142.PHONY: android_test_stubs
143android_test_stubs: $(full_target)
144
145# Build and store the android_test.jar.
146$(call dist-for-goals,sdk win_sdk,$(full_target):android_test.jar)
147$(call dist-for-goals,sdk win_sdk,$(full_target):apistubs/android/test/android.jar)
148
149# ============ Module Lib SDK ============
150full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_module_lib_stubs_current,,COMMON)/classes.jar
151
152.PHONY: android_module_lib_stubs
153android_module_lib_stubs: $(full_target)
154
155$(call dist-for-goals,sdk win_sdk,$(full_target):apistubs/android/module-lib/android.jar)
156
157# ============ System server SDK ============
158full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,android_system_server_stubs_current,,COMMON)/classes.jar
159
160.PHONY: android_system_server_stubs
161android_system_server_stubs: $(full_target)
162
163$(call dist-for-goals,sdk win_sdk,$(full_target):apistubs/android/system-server/android.jar)
164