• 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)-$(FILE_NAME_TAG).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) cd $(basename $(3)) && \
37	        rm  -f   ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
38	        zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) $(4)/*
39$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
40$(1) += $(4) $(2) \
41    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
42
43$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
44$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
45endef
46
47# Defines the rule to build an SDK repository package when the
48# package directory contains a single platform-related inner directory.
49# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
50# this generates an sdk-repo-linux-samples that contains android-N/*
51#
52# $1=variable where to accumulate args for mk_sdk_repo_xml.
53# $2=OS (e.g. linux, darwin)
54# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
55# $4=package to create (e.g. platforms, samples, etc.)
56#
57# The rule depends on the SDK zip file, which is defined by $2.
58#
59define mk-sdk-repo-pkg-2
60$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
61	@echo "Building SDK repository package $(4) from $(notdir $(3))"
62	$(hide) cd $(basename $(3))/$(4) && \
63	        rm  -f   ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
64	        zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
65$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
66$(1) += $(4) $(2) \
67    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
68
69$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
70$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
71endef
72
73# Defines the rule to build an SDK repository package when the
74# package directory contains 3 levels from the sdk dir, for example
75# to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
76# Because we do not know the intermediary directory name, this only works
77# if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
78# unique.)
79#
80# $1=variable where to accumulate args for mk_sdk_repo_xml.
81# $2=OS (e.g. linux, darwin)
82# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
83# $4=package to create (e.g. system-images, support, etc.)
84# $5=the root of directory to package in the sdk (e.g. extra/android).
85#    this must be a 2-segment path, the last one can be *.
86#
87# The rule depends on the SDK zip file, which is defined by $2.
88#
89define mk-sdk-repo-pkg-3
90$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
91	@echo "Building SDK repository package $(4) from $(notdir $(3))"
92	$(hide) cd $(basename $(3))/$(5) && \
93	        rm  -f   ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
94	        zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
95$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
96$(1) += $(4) $(2) \
97    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
98
99$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
100$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
101endef
102
103# Defines the rule to build an SDK sources package.
104#
105# $1=variable where to accumulate args for mk_sdk_repo_xml.
106# $2=OS (e.g. linux, darwin)
107# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
108# $4=package to create, must be "sources"
109#
110define mk-sdk-repo-sources
111$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) development/build/tools/mk_sources_zip.py $(HOST_OUT)/development/sdk/source_source.properties
112	@echo "Building SDK sources package"
113	development/build/tools/mk_sources_zip.py --exec-zip \
114	            $(HOST_OUT)/development/sdk/source_source.properties \
115	            $$@ .
116$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
117$(1) += $(4) $(2) \
118    $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
119
120$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
121$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3) $(HOST_OUT)/development/sdk/source_source.properties,$(PRODUCT_OUT)/:/)
122endef
123
124# Defines the rule to build an XML file for a package.
125#
126# $1=output file
127# $2=schema file
128# $3=deps
129# $4=args
130define mk-sdk-repo-xml
131$(1): $$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $(2) $(3)
132	XMLLINT=$$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $$@ $(2) $(4)
133
134$$(call dist-for-goals,sdk_repo,$(1))
135
136$(call declare-1p-target,$(1),sdk_repo)
137$(call declare-container-license-deps,$(1),$(2) $(3),$(PRODUCT_OUT)/:/)
138endef
139
140# -----------------------------------------------------------------
141# Rules for main host sdk
142
143ifneq ($(filter sdk,$(MAKECMDGOALS)),)
144
145# All these go in the main repository.xml
146$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
147$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
148$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
149$(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
150
151SDK_REPO_DEPS += \
152    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
153    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
154    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
155    $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
156
157endif
158
159# -----------------------------------------------------------------
160# Pickup the most recent xml schema for repository and add-on
161
162SDK_REPO_XSD := \
163    $(lastword \
164      $(wildcard \
165        prebuilts/devtools/repository/sdk-repository-*.xsd \
166    ))
167
168SDK_ADDON_XSD := \
169    $(lastword \
170      $(wildcard \
171        prebuilts/devtools/repository/sdk-addon-*.xsd \
172    ))
173
174SDK_SYSIMG_XSD := \
175    $(lastword \
176      $(wildcard \
177        prebuilts/devtools/repository/sdk-sys-img-*.xsd \
178    ))
179
180
181# -----------------------------------------------------------------
182# Rules for sdk addon
183
184ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
185ifneq ($(ADDON_SDK_ZIP),)
186
187# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
188# already packaged correctly. All we have to do is dist it with
189# a different destination name.
190
191RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
192
193$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
194
195# Also generate the addon.xml using the latest schema and the renamed addon zip
196
197SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
198
199$(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_XML),$(SDK_ADDON_XSD),$(ADDON_SDK_ZIP),add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)))
200
201SDK_ADDON_XML :=
202RENAMED_ADDON_ZIP :=
203
204endif
205
206ifneq ($(ADDON_SDK_IMG_ZIP),)
207
208# Copy/rename the ADDON_SDK_IMG_ZIP file as an sdk-repo zip in the dist dir
209
210RENAMED_ADDON_IMG_ZIP := $(ADDON_SDK_IMG_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_IMG_ZIP),system-images))
211
212$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_IMG_ZIP))
213
214# Generate the system-image XML for the addon sys-img
215
216SDK_ADDON_IMG_XML := $(dir $(ADDON_SDK_ZIP))/addon-sys-img.xml
217
218$(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)))
219
220SDK_ADDON_IMG_XML :=
221RENAMED_ADDON_IMG_ZIP :=
222
223endif
224endif
225
226# -----------------------------------------------------------------
227# Rules for the SDK Repository XML
228
229SDK_REPO_XML   := $(MAIN_SDK_DIR)/repository.xml
230SDK_EXTRAS_XML := $(MAIN_SDK_DIR)/repo-extras.xml
231SDK_SYSIMG_XML := $(MAIN_SDK_DIR)/repo-sys-img.xml
232
233ifneq ($(SDK_REPO_XML_ARGS),)
234$(eval $(call mk-sdk-repo-xml,$(SDK_REPO_XML),$(SDK_REPO_XSD),$(SDK_REPO_DEPS),$(SDK_REPO_XML_ARGS)))
235else
236SDK_REPO_XML :=
237endif
238
239
240ifneq ($(SDK_EXTRAS_XML_ARGS),)
241$(eval $(call mk-sdk-repo-xml,$(SDK_EXTRAS_XML),$(SDK_ADDON_XSD),$(SDK_EXTRAS_DEPS),$(SDK_EXTRAS_XML_ARGS)))
242else
243SDK_EXTRAS_XML :=
244endif
245
246
247ifneq ($(SDK_SYSIMG_XML_ARGS),)
248$(eval $(call mk-sdk-repo-xml,$(SDK_SYSIMG_XML),$(SDK_SYSIMG_XSD),$(SDK_SYSIMG_DEPS),$(SDK_SYSIMG_XML_ARGS)))
249else
250SDK_SYSIMG_XML :=
251endif
252
253# -----------------------------------------------------------------
254
255sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
256
257SDK_REPO_DEPS :=
258SDK_REPO_XML :=
259SDK_REPO_XML_ARGS :=
260SDK_EXTRAS_DEPS :=
261SDK_EXTRAS_XML :=
262SDK_EXTRAS_XML_ARGS :=
263SDK_SYSIMG_DEPS :=
264SDK_SYSIMG_XML :=
265SDK_SYSIMG_XML_ARGS :=
266
267mk-sdk-repo-pkg-1 :=
268mk-sdk-repo-pkg-2 :=
269mk-sdk-repo-pkg-3 :=
270mk-sdk-repo-sources :=
271mk-sdk-repo-xml :=
272sdk-repo-pkg-zip :=
273