blob: db8808a3b4a4fed30d3ad169aad4ce5e920b01ef [file] [log] [blame]
Raphael2ff496b2011-02-15 16:08:36 -08001# Makefile to build the SDK repository packages.
2
3.PHONY: sdk_repo
4
Raphael Moll9516dc52012-02-27 15:18:29 -08005SDK_REPO_DEPS :=
6SDK_REPO_XML_ARGS :=
7SDK_EXTRAS_DEPS :=
8SDK_EXTRAS_XML_ARGS :=
Raphael48023782011-02-23 16:46:42 -08009
Raphael2ff496b2011-02-15 16:08:36 -080010# Define the name of a package zip file to generate
11# $1=OS (e.g. linux-x86, windows, etc)
12# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
13# $3=package to create (e.g. tools, docs, etc.)
14#
15define sdk-repo-pkg-zip
Raphael48023782011-02-23 16:46:42 -080016$(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
Raphael2ff496b2011-02-15 16:08:36 -080017endef
18
19# Defines the rule to build an SDK repository package by zipping all
20# the content of the given directory.
21# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
22# this generates an sdk-repo-linux-tools that contains tools/*
23#
Raphael Mollea40d2f2014-04-24 19:13:47 -070024# $1=variable where to accumulate args for mk_sdk_repo_xml.
25# $2=OS (e.g. linux-x86, windows, etc)
26# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
27# $4=package to create (e.g. tools, docs, etc.)
Raphael2ff496b2011-02-15 16:08:36 -080028#
29# The rule depends on the SDK zip file, which is defined by $2.
30#
31define mk-sdk-repo-pkg-1
Raphael Mollea40d2f2014-04-24 19:13:47 -070032$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
33 @echo "Building SDK repository package $(4) from $(notdir $(3))"
34 $(hide) cd $(basename $(3)) && \
Raphael Moll4df9f462014-06-02 17:11:45 -070035 rm -f ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
Raphael Mollea40d2f2014-04-24 19:13:47 -070036 zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) $(4)/*
37$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
38$(1) += $(4) $(2) \
39 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael2ff496b2011-02-15 16:08:36 -080040endef
41
42# Defines the rule to build an SDK repository package when the
43# package directory contains a single platform-related inner directory.
44# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
45# this generates an sdk-repo-linux-samples that contains android-N/*
46#
Raphael Mollea40d2f2014-04-24 19:13:47 -070047# $1=variable where to accumulate args for mk_sdk_repo_xml.
48# $2=OS (e.g. linux-x86, windows, etc)
49# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
50# $4=package to create (e.g. platforms, samples, etc.)
Raphael2ff496b2011-02-15 16:08:36 -080051#
52# The rule depends on the SDK zip file, which is defined by $2.
53#
54define mk-sdk-repo-pkg-2
Raphael Mollea40d2f2014-04-24 19:13:47 -070055$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
56 @echo "Building SDK repository package $(4) from $(notdir $(3))"
57 $(hide) cd $(basename $(3))/$(4) && \
Raphael Moll4df9f462014-06-02 17:11:45 -070058 rm -f ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
Raphael Mollea40d2f2014-04-24 19:13:47 -070059 zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
60$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
61$(1) += $(4) $(2) \
62 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael2ff496b2011-02-15 16:08:36 -080063endef
64
Raphael Moll3d308aa2011-10-01 23:44:08 -070065# Defines the rule to build an SDK repository package when the
66# package directory contains 3 levels from the sdk dir, for example
67# to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
68# Because we do not know the intermediary directory name, this only works
69# if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
70# unique.)
71#
Raphael Mollea40d2f2014-04-24 19:13:47 -070072# $1=variable where to accumulate args for mk_sdk_repo_xml.
73# $2=OS (e.g. linux-x86, windows, etc)
74# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
75# $4=package to create (e.g. system-images, support, etc.)
76# $5=the root of directory to package in the sdk (e.g. extra/android).
Raphael Moll3d308aa2011-10-01 23:44:08 -070077# this must be a 2-segment path, the last one can be *.
78#
79# The rule depends on the SDK zip file, which is defined by $2.
80#
81define mk-sdk-repo-pkg-3
Raphael Mollea40d2f2014-04-24 19:13:47 -070082$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
83 @echo "Building SDK repository package $(4) from $(notdir $(3))"
84 $(hide) cd $(basename $(3))/$(5) && \
Raphael Moll4df9f462014-06-02 17:11:45 -070085 rm -f ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
Raphael Mollea40d2f2014-04-24 19:13:47 -070086 zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
87$(call dist-for-goals, 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)))
Raphael Moll3d308aa2011-10-01 23:44:08 -070090endef
91
Raphael Mollda9eabd2011-09-28 11:18:34 -070092# Defines the rule to build an SDK sources package.
93#
Raphael Mollea40d2f2014-04-24 19:13:47 -070094# $1=variable where to accumulate args for mk_sdk_repo_xml.
95# $2=OS (e.g. linux-x86, windows, etc)
96# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
97# $4=package to create, must be "sources"
Raphael Mollda9eabd2011-09-28 11:18:34 -070098#
99define mk-sdk-repo-sources
Raphael Mollea40d2f2014-04-24 19:13:47 -0700100$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) $(HOST_OUT)/development/sdk/source_source.properties
Raphael Mollda9eabd2011-09-28 11:18:34 -0700101 @echo "Building SDK sources package"
Raphael Molla85a93f2012-03-27 10:45:59 -0700102 $(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py --exec-zip \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800103 $(HOST_OUT)/development/sdk/source_source.properties \
Raphael Mollea40d2f2014-04-24 19:13:47 -0700104 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)) \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800105 $(TOPDIR).
Raphael Mollea40d2f2014-04-24 19:13:47 -0700106$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
107$(1) += $(4) $(2) \
108 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael Mollda9eabd2011-09-28 11:18:34 -0700109endef
Raphael2ff496b2011-02-15 16:08:36 -0800110
Raphael48023782011-02-23 16:46:42 -0800111# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800112# Rules for main host sdk
113
114ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
115
Raphael Mollea40d2f2014-04-24 19:13:47 -0700116# Extras are now located in addon.xml, not in repository.xml.
117$(eval $(call mk-sdk-repo-pkg-3,SDK_EXTRAS_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
Raphael Moll9516dc52012-02-27 15:18:29 -0800118
119SDK_EXTRAS_DEPS += \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800120 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support)
Raphael Moll9516dc52012-02-27 15:18:29 -0800121
Raphael Mollea40d2f2014-04-24 19:13:47 -0700122# Similarly capture all sys-img.xml that are now split out of repository.xml
123$(eval $(call mk-sdk-repo-pkg-3,SDK_SYSIMG_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
Raphael Moll9516dc52012-02-27 15:18:29 -0800124
Ji-Hwan Leee3e3de02014-06-22 04:26:56 +0900125SDK_SYSIMG_DEPS += \
126 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
127
128# All these go in the main repository.xml
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900129$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools))
130$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
131$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
132$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
133$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900134$(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
Raphael Moll9516dc52012-02-27 15:18:29 -0800135
136SDK_REPO_DEPS += \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800137 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools) \
138 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
139 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
140 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
141 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800142 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
Raphael Moll9516dc52012-02-27 15:18:29 -0800143
144endif
145
146# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800147# Rules for win_sdk
148
149ifneq ($(WIN_SDK_ZIP),)
150
151# docs, platforms and samples have nothing OS-dependent right now.
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900152$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),build-tools))
153$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),platform-tools))
Raphael2ff496b2011-02-15 16:08:36 -0800154
155SDK_REPO_DEPS += \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800156 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),build-tools) \
157 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
Raphael2ff496b2011-02-15 16:08:36 -0800158
159endif
160
Raphael48023782011-02-23 16:46:42 -0800161# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800162# Pickup the most recent xml schema for repository and add-on
Raphael2ff496b2011-02-15 16:08:36 -0800163
Raphael Moll9516dc52012-02-27 15:18:29 -0800164SDK_REPO_XSD := \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800165 $(lastword \
166 $(wildcard \
167 $(TOPDIR)prebuilts/devtools/repository/sdk-repository-*.xsd \
168 ))
Raphael2ff496b2011-02-15 16:08:36 -0800169
Raphael Moll9516dc52012-02-27 15:18:29 -0800170SDK_ADDON_XSD := \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800171 $(lastword \
172 $(wildcard \
173 $(TOPDIR)prebuilts/devtools/repository/sdk-addon-*.xsd \
174 ))
175
Raphael Mollea40d2f2014-04-24 19:13:47 -0700176SDK_SYSIMG_XSD := \
177 $(lastword \
178 $(wildcard \
179 $(TOPDIR)prebuilts/devtools/repository/sdk-sys-img-*.xsd \
180 ))
181
Raphael2ff496b2011-02-15 16:08:36 -0800182
Raphael48023782011-02-23 16:46:42 -0800183# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800184# Rules for sdk addon
185
186ifneq ($(ADDON_SDK_ZIP),)
187
188# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
189# already packaged correctly. All we have to do is dist it with
190# a different destination name.
191
Raphael48023782011-02-23 16:46:42 -0800192RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
193
194$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
195
196# Also generate the addon.xml using the latest schema and the renamed addon zip
197
198SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
199
Raphael48023782011-02-23 16:46:42 -0800200$(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
201 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800202 $(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
Raphael48023782011-02-23 16:46:42 -0800203
204$(call dist-for-goals, sdk_repo, $(SDK_ADDON_XML))
Raphael2ff496b2011-02-15 16:08:36 -0800205
206endif
207
Raphael Mollfa090e22014-08-21 15:15:02 -0700208ifneq ($(ADDON_SDK_IMG_ZIP),)
209
210# Copy/rename the ADDON_SDK_IMG_ZIP file as an sdk-repo zip in the dist dir
211
212RENAMED_ADDON_IMG_ZIP := $(ADDON_SDK_IMG_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_IMG_ZIP),system-images))
213
214$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_IMG_ZIP))
215
216# Generate the system-image XML for the addon sys-img
217
218SDK_ADDON_IMG_XML := $(dir $(ADDON_SDK_ZIP))/addon-sys-img.xml
219
220$(SDK_ADDON_IMG_XML): $(ADDON_SDK_IMG_ZIP)
221 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
222 $(SDK_ADDON_IMG_XML) $(SDK_SYSIMG_XSD) system-image $(HOST_OS) $(RENAMED_ADDON_IMG_ZIP)
223
224$(call dist-for-goals, sdk_repo, $(SDK_ADDON_IMG_XML))
225
226endif
227
Raphael48023782011-02-23 16:46:42 -0800228# -----------------------------------------------------------------
229# Rules for the SDK Repository XML
Raphael2ff496b2011-02-15 16:08:36 -0800230
Raphael Moll26bcf6a2014-06-03 10:44:56 -0700231SDK_REPO_XML := $(MAIN_SDK_DIR)/repository.xml
232SDK_EXTRAS_XML := $(MAIN_SDK_DIR)/repo-extras.xml
233SDK_SYSIMG_XML := $(MAIN_SDK_DIR)/repo-sys-img.xml
Raphael48023782011-02-23 16:46:42 -0800234
235ifneq ($(SDK_REPO_XML_ARGS),)
236
Raphael48023782011-02-23 16:46:42 -0800237$(SDK_REPO_XML): $(SDK_REPO_DEPS)
238 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800239 $(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
Raphael48023782011-02-23 16:46:42 -0800240
241$(call dist-for-goals, sdk_repo, $(SDK_REPO_XML))
242
243else
244
245$(SDK_REPO_XML): ;
246
247endif
248
Raphael Moll9516dc52012-02-27 15:18:29 -0800249
250ifneq ($(SDK_EXTRAS_XML_ARGS),)
251
252$(SDK_EXTRAS_XML): $(SDK_EXTRAS_DEPS)
253 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800254 $(SDK_EXTRAS_XML) $(SDK_ADDON_XSD) $(SDK_EXTRAS_XML_ARGS)
Raphael Moll9516dc52012-02-27 15:18:29 -0800255
256$(call dist-for-goals, sdk_repo, $(SDK_EXTRAS_XML))
257
258else
259
260$(SDK_EXTRAS_XML): ;
261
262endif
263
Raphael Mollea40d2f2014-04-24 19:13:47 -0700264
265ifneq ($(SDK_SYSIMG_XML_ARGS),)
266
267$(SDK_SYSIMG_XML): $(SDK_SYSIMG_DEPS)
268 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
269 $(SDK_SYSIMG_XML) $(SDK_SYSIMG_XSD) $(SDK_SYSIMG_XML_ARGS)
270
271$(call dist-for-goals, sdk_repo, $(SDK_SYSIMG_XML))
272
273else
274
275$(SDK_SYSIMG_XML): ;
276
277endif
278
Raphael48023782011-02-23 16:46:42 -0800279# -----------------------------------------------------------------
280
Raphael Mollea40d2f2014-04-24 19:13:47 -0700281sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
Raphael2ff496b2011-02-15 16:08:36 -0800282 @echo "Packing of SDK repository done"
283