• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Makefile to build the SDK repository packages.
2
3.PHONY: sdk_repo
4
5SDK_REPO_DEPS       :=
6SDK_REPO_XML_ARGS   :=
7SDK_EXTRAS_DEPS     :=
8SDK_EXTRAS_XML_ARGS :=
9SDK_SYSIMG_DEPS     :=
10SDK_SYSIMG_XML_ARGS :=
11
12# Define the name of a package zip file to generate
13# $1=OS (e.g. linux, darwin)
14# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
15# $3=package to create (e.g. tools, docs, etc.)
16#
17define sdk-repo-pkg-zip
18$(dir $(2))/sdk-repo-$(1)-$(3).zip
19endef
20
21# Defines the rule to build an SDK repository package by zipping all
22# the content of the given directory.
23# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
24# this generates an sdk-repo-linux-tools that contains tools/*
25#
26# $1=variable where to accumulate args for mk_sdk_repo_xml.
27# $2=OS (e.g. linux, darwin)
28# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
29# $4=package to create (e.g. tools, docs, etc.)
30#
31# The rule depends on the SDK zip file, which is defined by $2.
32#
33define mk-sdk-repo-pkg-1
34$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
35	@echo "Building SDK repository package $(4) from $(notdir $(3))"
36	$(hide) rm -f $$@ && \
37	        $(SOONG_ZIP) -o $$@ -C $(basename $(3)) -D $(basename $(3))/$(4)
38$(call dist-for-goals-with-filenametag, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
39$(1) += $(4) $(2) \
40    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
41
42$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
43$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
44endef
45
46# Defines the rule to build an SDK repository package when the
47# package directory contains a single platform-related inner directory.
48# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
49# this generates an sdk-repo-linux-samples that contains android-N/*
50#
51# $1=variable where to accumulate args for mk_sdk_repo_xml.
52# $2=OS (e.g. linux, darwin)
53# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
54# $4=package to create (e.g. platforms, samples, etc.)
55#
56# The rule depends on the SDK zip file, which is defined by $2.
57#
58define mk-sdk-repo-pkg-2
59$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
60	@echo "Building SDK repository package $(4) from $(notdir $(3))"
61	$(hide) rm -f $$@ && \
62	        $(SOONG_ZIP) -o $$@ -C $(basename $(3))/$(4) -D $(basename $(3))/$(4)
63$(call dist-for-goals-with-filenametag, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
64$(1) += $(4) $(2) \
65    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
66
67$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
68$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
69endef
70
71# Defines the rule to build an SDK sources package.
72#
73# $1=variable where to accumulate args for mk_sdk_repo_xml.
74# $2=OS (e.g. linux, darwin)
75# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
76# $4=package to create, must be "sources"
77#
78define mk-sdk-repo-sources
79bcp_srcjar := $(call intermediates-dir-for,ETC,platform-bootclasspath.srcjar)/platform-bootclasspath.srcjar
80source_props := $(HOST_OUT)/development/sdk/source_source.properties
81$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) $$(bcp_srcjar) $$(source_props)
82	@echo "Building SDK sources package"
83	rm -rf $$(dir $$@)/tmp
84	unzip -qd $$(dir $$@)/tmp $$(bcp_srcjar)
85	$$(SOONG_ZIP) -o $$@ -P src -e source.properties -f $$(source_props) -C $$(dir $$@)/tmp -D $$(dir $$@)/tmp
86	rm -rf $$(dir $$@)/tmp
87$(call dist-for-goals-with-filenametag, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
88$(1) += $(4) $(2) \
89    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
90
91$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
92$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3) $(HOST_OUT)/development/sdk/source_source.properties,$(PRODUCT_OUT)/:/)
93endef
94
95# Defines the rule to build an XML file for a package.
96#
97# $1=output file
98# $2=schema file
99# $3=deps
100# $4=args
101define mk-sdk-repo-xml
102$(1): $$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $(2) $(3)
103	XMLLINT=$$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $$@ $(2) $(4)
104
105$$(call dist-for-goals,sdk_repo,$(1))
106
107$(call declare-1p-target,$(1),sdk_repo)
108$(call declare-container-license-deps,$(1),$(2) $(3),$(PRODUCT_OUT)/:/)
109endef
110
111# -----------------------------------------------------------------
112# Rules for main host sdk
113
114ifneq ($(filter sdk,$(MAKECMDGOALS)),)
115
116# All these go in the main repository.xml
117$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
118$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
119$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
120$(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
121
122SDK_REPO_DEPS += \
123    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
124    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
125    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
126    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
127
128endif
129
130# -----------------------------------------------------------------
131# Pickup the most recent xml schema for repository and add-on
132
133SDK_REPO_XSD := \
134    $(lastword \
135      $(wildcard \
136        prebuilts/devtools/repository/sdk-repository-*.xsd \
137    ))
138
139SDK_ADDON_XSD := \
140    $(lastword \
141      $(wildcard \
142        prebuilts/devtools/repository/sdk-addon-*.xsd \
143    ))
144
145SDK_SYSIMG_XSD := \
146    $(lastword \
147      $(wildcard \
148        prebuilts/devtools/repository/sdk-sys-img-*.xsd \
149    ))
150
151
152# -----------------------------------------------------------------
153# Rules for sdk addon
154
155ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
156ifneq ($(ADDON_SDK_ZIP),)
157
158# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
159# already packaged correctly. All we have to do is dist it with
160# a different destination name.
161
162RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
163
164$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
165
166# Also generate the addon.xml using the latest schema and the renamed addon zip
167
168SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
169
170$(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_XML),$(SDK_ADDON_XSD),$(ADDON_SDK_ZIP),add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)))
171
172SDK_ADDON_XML :=
173RENAMED_ADDON_ZIP :=
174
175endif
176
177ifneq ($(ADDON_SDK_IMG_ZIP),)
178
179# Copy/rename the ADDON_SDK_IMG_ZIP file as an sdk-repo zip in the dist dir
180
181RENAMED_ADDON_IMG_ZIP := $(ADDON_SDK_IMG_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_IMG_ZIP),system-images))
182
183$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_IMG_ZIP))
184
185# Generate the system-image XML for the addon sys-img
186
187SDK_ADDON_IMG_XML := $(dir $(ADDON_SDK_ZIP))/addon-sys-img.xml
188
189$(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_IMG_XML),$(SDK_SYSIMG_XSD),$(ADDON_SDK_IMG_ZIP),system-image $(HOST_OS) $(RENAMED_ADDON_IMG_ZIP)))
190
191SDK_ADDON_IMG_XML :=
192RENAMED_ADDON_IMG_ZIP :=
193
194endif
195endif
196
197# -----------------------------------------------------------------
198# Rules for the SDK Repository XML
199
200SDK_REPO_XML   := $(MAIN_SDK_DIR)/repository.xml
201SDK_EXTRAS_XML := $(MAIN_SDK_DIR)/repo-extras.xml
202SDK_SYSIMG_XML := $(MAIN_SDK_DIR)/repo-sys-img.xml
203
204ifneq ($(SDK_REPO_XML_ARGS),)
205$(eval $(call mk-sdk-repo-xml,$(SDK_REPO_XML),$(SDK_REPO_XSD),$(SDK_REPO_DEPS),$(SDK_REPO_XML_ARGS)))
206else
207SDK_REPO_XML :=
208endif
209
210
211ifneq ($(SDK_EXTRAS_XML_ARGS),)
212$(eval $(call mk-sdk-repo-xml,$(SDK_EXTRAS_XML),$(SDK_ADDON_XSD),$(SDK_EXTRAS_DEPS),$(SDK_EXTRAS_XML_ARGS)))
213else
214SDK_EXTRAS_XML :=
215endif
216
217
218ifneq ($(SDK_SYSIMG_XML_ARGS),)
219$(eval $(call mk-sdk-repo-xml,$(SDK_SYSIMG_XML),$(SDK_SYSIMG_XSD),$(SDK_SYSIMG_DEPS),$(SDK_SYSIMG_XML_ARGS)))
220else
221SDK_SYSIMG_XML :=
222endif
223
224# -----------------------------------------------------------------
225
226sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
227
228SDK_REPO_DEPS :=
229SDK_REPO_XML :=
230SDK_REPO_XML_ARGS :=
231SDK_EXTRAS_DEPS :=
232SDK_EXTRAS_XML :=
233SDK_EXTRAS_XML_ARGS :=
234SDK_SYSIMG_DEPS :=
235SDK_SYSIMG_XML :=
236SDK_SYSIMG_XML_ARGS :=
237
238mk-sdk-repo-pkg-1 :=
239mk-sdk-repo-pkg-2 :=
240mk-sdk-repo-sources :=
241mk-sdk-repo-xml :=
242sdk-repo-pkg-zip :=
243