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 := $(HOST_OUT)/development/sdk/doc_source.properties \
7             $(HOST_OUT)/development/sdk/platform_source.properties \
8             $(HOST_OUT)/development/sdk/source_source.properties
9sample_props := $(patsubst \
10                  $(TOPDIR)development/samples/%_source.prop_template, \
11                  $(HOST_OUT)/development/samples/%_source.properties, \
12                  $(wildcard $(TOPDIR)development/samples/*_source.prop_template))
13sys_img_props := $(patsubst \
14                   $(TOPDIR)development/sys-img/%_source.prop_template, \
15                   $(HOST_OUT)/development/sys-img-$(TARGET_CPU_ABI)/%_source.properties, \
16                   $(wildcard $(TOPDIR)development/sys-img/*_source.prop_template))
17ALL_SDK_FILES += $(sdk_props) $(sample_props) $(sys_img_props)
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_EXTENSION_SDK_VERSION} e.g. "7" -- the extension sdk level
25# - ${PLATFORM_IS_BASE_SDK}           bool. -- whether the current extension sdk is the base extension for this api level
26# - ${PLATFORM_VERSION_CODENAME}      e.g. "REL" (transformed into "") or "Cupcake"
27# - ${TARGET_ARCH}                    e.g. "arm", "x86", "mips" and their 64-bit variants.
28# - ${TARGET_CPU_ABI}                 e.g. "armeabi", "x86", "mips" and their 64-bit variants.
29define process_prop_template
30@echo Generate $@
31$(hide) mkdir -p $(dir $@)
32$(hide) sed \
33	-e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
34	-e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
35	-e 's/$${PLATFORM_SDK_EXTENSION_VERSION}/$(PLATFORM_SDK_EXTENSION_VERSION)/' \
36	-e 's/$${PLATFORM_IS_BASE_SDK}/$(if $(filter $(PLATFORM_SDK_EXTENSION_VERSION),$(PLATFORM_BASE_SDK_EXTENSION_VERSION)),true,false)/' \
37	-e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
38	-e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \
39	-e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \
40	$< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
41endef
42
43$(sys_img_props) : $(HOST_OUT)/development/sys-img-$(TARGET_CPU_ABI)/%_source.properties : $(TOPDIR)development/sys-img/%_source.prop_template
44	$(process_prop_template)
45
46$(sdk_props) : $(HOST_OUT)/development/sdk/%_source.properties : $(TOPDIR)development/sdk/%_source.prop_template
47	$(process_prop_template)
48
49$(sample_props) : $(HOST_OUT)/development/samples/%_source.properties : $(TOPDIR)development/samples/%_source.prop_template
50	$(process_prop_template)
51
52# ===== SDK jar file of stubs =====
53# A.k.a the "current" version of the public SDK (android.jar inside the SDK package).
54full_target := $(call intermediates-dir-for,JAVA_LIBRARIES,$(ANDROID_PUBLIC_EXPORTABLE_STUBS),,COMMON)/classes.jar
55full_src_target := $(call intermediates-dir-for,ETC,frameworks-base-api-current.srcjar)/frameworks-base-api-current.srcjar
56
57# android.jar is what we put in the SDK package.
58android_jar_intermediates := $(call intermediates-dir-for,PACKAGING,android_jar,,COMMON)
59android_jar_full_target := $(android_jar_intermediates)/android.jar
60android_jar_src_target := $(android_jar_intermediates)/android-stubs-src.jar
61
62# unzip and zip android.jar before packaging it. (workaround for b/127733650)
63full_target_repackaged := $(android_jar_intermediates)/repackaged/repackaged.jar
64$(full_target_repackaged): $(full_target) | $(ZIPTIME)
65	@echo Repackaging SDK jar: $@
66	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
67	unzip -q $< -d $(dir $@)
68	cd $(dir $@) && zip -rqX $(notdir $@) *
69	$(remove-timestamps-from-package)
70
71$(android_jar_full_target): $(full_target_repackaged)
72	@echo Package SDK Stubs: $@
73	$(copy-file-to-target)
74
75$(android_jar_src_target): $(full_src_target)
76	@echo Package SDK Stubs Source: $@
77	$(hide)mkdir -p $(dir $@)
78	$(hide)$(ACP) $< $@
79
80ALL_SDK_FILES += $(android_jar_full_target)
81ALL_SDK_FILES += $(android_jar_src_target)
82
83# ===== SDK for system modules =====
84# A subset of the public SDK to convert to system modules for use with javac -source 9 -target 9
85ALL_SDK_FILES += $(call intermediates-dir-for,JAVA_LIBRARIES,core-current-stubs-for-system-modules,,COMMON)/classes.jar
86
87# ====================================================
88
89# The uiautomator stubs
90ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/classes.jar
91
92# org.apache.http.legacy.jar stubs
93ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/org.apache.http.legacy.stubs_intermediates/classes.jar
94
95# Android Automotive OS stubs
96ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.car-stubs_intermediates/classes.jar
97
98# test stubs
99ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.mock.stubs_intermediates/classes.jar
100ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.base.stubs_intermediates/classes.jar
101ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android.test.runner.stubs_intermediates/classes.jar
102
103# ======= Lint API XML (complete API) ===========
104full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api_versions_public_generated-api-versions.xml
105ALL_SDK_FILES += $(full_target)
106$(call dist-for-goals,sdk,$(full_target):data/api-versions.xml)
107
108# ======= Lint Annotations zip (complete API) ===========
109full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/sdk-annotations.zip
110$(eval $(call copy-one-file,$(call intermediates-dir-for,ETC,sdk-annotations.zip)/sdk-annotations.zip,$(full_target)))
111ALL_SDK_FILES += $(full_target)
112$(call dist-for-goals,sdk,$(full_target):data/annotations.zip)
113
114# ======= Lint system API XML (complete API) ===========
115full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api_versions_system_generated-api-versions.xml
116$(call dist-for-goals,sdk,$(full_target):system-data/api-versions.xml)
117
118# ======= Lint system Annotations zip (complete API) ===========
119full_target := $(call intermediates-dir-for,ETC,sdk-annotations-system.zip)/sdk-annotations-system.zip
120$(call dist-for-goals,sdk,$(full_target):system-data/annotations.zip)
121
122# ======= Lint module-lib API XML (non-updatable APIs only) ===========
123full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api_versions_module_lib_generated-api-versions.xml
124$(call dist-for-goals,sdk,$(full_target):module-lib-data/api-versions.xml)
125
126# ======= Lint module-lib API XML (complete API) ===========
127full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api_versions_module_lib_complete_generated-api-versions.xml
128$(call dist-for-goals,sdk,$(full_target):module-lib-data/api-versions-complete.xml)
129
130# ======= Lint module-lib Annotations zip (complete API) ===========
131full_target := $(call intermediates-dir-for,ETC,sdk-annotations-module-lib.zip)/sdk-annotations-module-lib.zip
132$(call dist-for-goals,sdk,$(full_target):module-lib-data/annotations.zip)
133
134# ======= Lint system-server API XML (non-updatable APIs only) ===========
135full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api_versions_system_server_generated-api-versions.xml
136$(call dist-for-goals,sdk,$(full_target):system-server-data/api-versions.xml)
137
138# ======= Lint system-server API XML (complete API) ===========
139full_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/api_versions_system_server_complete_generated-api-versions.xml
140$(call dist-for-goals,sdk,$(full_target):system-server-data/api-versions-complete.xml)
141
142# ======= Lint system-server Annotations zip (complete API) ===========
143full_target := $(call intermediates-dir-for,ETC,sdk-annotations-system-server.zip)/sdk-annotations-system-server.zip
144$(call dist-for-goals,sdk,$(full_target):system-server-data/annotations.zip)
145
146# ============ SDK AIDL ============
147$(eval $(call copy-one-file,$(FRAMEWORK_AIDL),$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework.aidl))
148ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework.aidl
149