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	$(hide)$(ACP) $< $@
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	$(hide)mkdir -p $(dir $@)
81	$(hide)$(ACP) $< $@
82
83$(android_jar_src_target): $(full_src_target)
84	@echo Package SDK Stubs Source: $@
85	$(hide)mkdir -p $(dir $@)
86	$(hide)$(ACP) $< $@
87
88ALL_SDK_FILES += $(android_jar_full_target)
89ALL_SDK_FILES += $(android_jar_src_target)
90
91# ====================================================
92
93# The Jack & Jill compiler jars
94ALL_SDK_FILES += prebuilts/sdk/tools/jacks/jack-$(JACK_SDKTOOL_VERSION).jar
95ALL_SDK_FILES += prebuilts/sdk/tools/jills/jill-$(JACK_SDKTOOL_VERSION).jar
96
97# The Jack reporter tool for code coverage
98ALL_SDK_FILES += prebuilts/sdk/tools/jack-jacoco-reporter.jar
99ALL_SDK_FILES += prebuilts/sdk/tools/jack-coverage-plugin.jar
100
101# The uiautomator stubs
102ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/javalib.jar
103
104# org.apache.http.legacy.jar stubs
105ALL_SDK_FILES += $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/org.apache.http.legacy_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	@# Delete resource generated classes from the jar files.
116	$(hide) zip -d $$@ "*/R.class" "*/R\$$$$*.class" "*/Manifest.class" "*/Manifest\$$$$*.class" >/dev/null 2>&1 || true
117
118ALL_SDK_FILES += $(_psm_packaging_target)
119$(eval _psm_build_module :=)
120$(eval _psm_packaging_target :=)
121endef
122
123ANDROID_SUPPORT_LIBRARIES := \
124    android-support-annotations \
125    android-support-v4 \
126    android-support-v7-appcompat \
127    android-support-v7-cardview \
128    android-support-v7-gridlayout \
129    android-support-v7-mediarouter \
130    android-support-v7-palette \
131    android-support-v7-preference \
132    android-support-v7-recyclerview \
133    android-support-v13 \
134    android-support-v14-preference \
135    android-support-v17-leanback \
136    android-support-v17-preference-leanback \
137    android-support-multidex \
138    android-support-multidex-instrumentation \
139    android-support-design \
140    android-support-percent \
141    android-support-recommendation \
142    android-support-customtabs \
143    android-support-documents-archive \
144    android-support-vectordrawable \
145    android-support-animatedvectordrawable
146
147$(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib))))
148
149# ======= Lint API XML ===========
150
151ALL_SDK_FILES += $(HOST_OUT)/development/sdk/generated-api-versions.xml
152
153api_gen_jar := $(TOPDIR)prebuilts/tools/common/api-generator/api-generator-25.0.0.jar
154api_gen_deps := \
155  $(TOPDIR)prebuilts/tools/common/m2/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar \
156  $(TOPDIR)prebuilts/tools/common/m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar \
157  $(TOPDIR)prebuilts/tools/common/m2/repository/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.jar \
158  $(TOPDIR)prebuilts/tools/common/m2/repository/com/google/guava/guava/17.0/guava-17.0.jar
159api_gen_classpath := $(subst $(space),:,$(api_gen_jar) $(api_gen_deps))
160
161
162$(HOST_OUT)/development/sdk/generated-api-versions.xml: $(android_jar_full_target)
163	java -cp $(api_gen_classpath) \
164	  com.android.apigenerator.Main \
165	  --pattern $(TOPDIR)prebuilts/tools/common/api-versions/android-%/android.jar \
166	  --pattern $(TOPDIR)prebuilts/sdk/%/android.jar \
167	  --current-version $(PLATFORM_SDK_VERSION) \
168	  --current-codename $(PLATFORM_VERSION_CODENAME) \
169	  --current-jar $(android_jar_full_target) \
170	  $@
171
172
173# ============ System SDK ============
174sdk_stub_name := android_system_stubs_current
175stub_timestamp := $(OUT_DOCS)/system-api-stubs-timestamp
176include $(LOCAL_PATH)/build_android_stubs.mk
177
178.PHONY: android_system_stubs
179android_system_stubs: $(full_target)
180
181# Build and store the android_system.jar.
182$(call dist-for-goals,sdk win_sdk,$(full_target):android_system.jar)
183
184# ============ Test SDK ============
185sdk_stub_name := android_test_stubs_current
186stub_timestamp := $(OUT_DOCS)/test-api-stubs-timestamp
187include $(LOCAL_PATH)/build_android_stubs.mk
188
189.PHONY: android_test_stubs
190android_test_stubs: $(full_target)
191
192# Build and store the android_test.jar.
193$(call dist-for-goals,sdk win_sdk,$(full_target):android_test.jar)
194