blob: ec89165674c289dc14ca6c0eddea276f1152dee4 [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 :=
Dan Willemsenf0407b32018-10-10 12:51:43 -07009SDK_SYSIMG_DEPS :=
10SDK_SYSIMG_XML_ARGS :=
Raphael48023782011-02-23 16:46:42 -080011
Raphael2ff496b2011-02-15 16:08:36 -080012# Define the name of a package zip file to generate
13# $1=OS (e.g. linux-x86, windows, etc)
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
Raphael48023782011-02-23 16:46:42 -080018$(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
Raphael2ff496b2011-02-15 16:08:36 -080019endef
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#
Raphael Mollea40d2f2014-04-24 19:13:47 -070026# $1=variable where to accumulate args for mk_sdk_repo_xml.
27# $2=OS (e.g. linux-x86, windows, etc)
28# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
29# $4=package to create (e.g. tools, docs, etc.)
Raphael2ff496b2011-02-15 16:08:36 -080030#
31# The rule depends on the SDK zip file, which is defined by $2.
32#
33define mk-sdk-repo-pkg-1
Raphael Mollea40d2f2014-04-24 19:13:47 -070034$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
35 @echo "Building SDK repository package $(4) from $(notdir $(3))"
36 $(hide) cd $(basename $(3)) && \
Raphael Moll4df9f462014-06-02 17:11:45 -070037 rm -f ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
Raphael Mollea40d2f2014-04-24 19:13:47 -070038 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)))
Raphael2ff496b2011-02-15 16:08:36 -080042endef
43
44# Defines the rule to build an SDK repository package when the
45# package directory contains a single platform-related inner directory.
46# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
47# this generates an sdk-repo-linux-samples that contains android-N/*
48#
Raphael Mollea40d2f2014-04-24 19:13:47 -070049# $1=variable where to accumulate args for mk_sdk_repo_xml.
50# $2=OS (e.g. linux-x86, windows, etc)
51# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
52# $4=package to create (e.g. platforms, samples, etc.)
Raphael2ff496b2011-02-15 16:08:36 -080053#
54# The rule depends on the SDK zip file, which is defined by $2.
55#
56define mk-sdk-repo-pkg-2
Raphael Mollea40d2f2014-04-24 19:13:47 -070057$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
58 @echo "Building SDK repository package $(4) from $(notdir $(3))"
59 $(hide) cd $(basename $(3))/$(4) && \
Raphael Moll4df9f462014-06-02 17:11:45 -070060 rm -f ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
Raphael Mollea40d2f2014-04-24 19:13:47 -070061 zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
62$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
63$(1) += $(4) $(2) \
64 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael2ff496b2011-02-15 16:08:36 -080065endef
66
Raphael Moll3d308aa2011-10-01 23:44:08 -070067# Defines the rule to build an SDK repository package when the
68# package directory contains 3 levels from the sdk dir, for example
69# to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
70# Because we do not know the intermediary directory name, this only works
71# if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
72# unique.)
73#
Raphael Mollea40d2f2014-04-24 19:13:47 -070074# $1=variable where to accumulate args for mk_sdk_repo_xml.
75# $2=OS (e.g. linux-x86, windows, etc)
76# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
77# $4=package to create (e.g. system-images, support, etc.)
78# $5=the root of directory to package in the sdk (e.g. extra/android).
Raphael Moll3d308aa2011-10-01 23:44:08 -070079# this must be a 2-segment path, the last one can be *.
80#
81# The rule depends on the SDK zip file, which is defined by $2.
82#
83define mk-sdk-repo-pkg-3
Raphael Mollea40d2f2014-04-24 19:13:47 -070084$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
85 @echo "Building SDK repository package $(4) from $(notdir $(3))"
86 $(hide) cd $(basename $(3))/$(5) && \
Raphael Moll4df9f462014-06-02 17:11:45 -070087 rm -f ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) && \
Raphael Mollea40d2f2014-04-24 19:13:47 -070088 zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
89$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
90$(1) += $(4) $(2) \
91 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael Moll3d308aa2011-10-01 23:44:08 -070092endef
93
Raphael Mollda9eabd2011-09-28 11:18:34 -070094# Defines the rule to build an SDK sources package.
95#
Raphael Mollea40d2f2014-04-24 19:13:47 -070096# $1=variable where to accumulate args for mk_sdk_repo_xml.
97# $2=OS (e.g. linux-x86, windows, etc)
98# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
99# $4=package to create, must be "sources"
Raphael Mollda9eabd2011-09-28 11:18:34 -0700100#
101define mk-sdk-repo-sources
Dan Willemsenf0407b32018-10-10 12:51:43 -0700102$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) development/build/tools/mk_sources_zip.py $(HOST_OUT)/development/sdk/source_source.properties
Raphael Mollda9eabd2011-09-28 11:18:34 -0700103 @echo "Building SDK sources package"
Dan Willemsenf0407b32018-10-10 12:51:43 -0700104 development/build/tools/mk_sources_zip.py --exec-zip \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800105 $(HOST_OUT)/development/sdk/source_source.properties \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700106 $$@ .
Raphael Mollea40d2f2014-04-24 19:13:47 -0700107$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
108$(1) += $(4) $(2) \
109 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael Mollda9eabd2011-09-28 11:18:34 -0700110endef
Raphael2ff496b2011-02-15 16:08:36 -0800111
Dan Willemsenf0407b32018-10-10 12:51:43 -0700112# Defines the rule to build an XML file for a package.
113#
114# $1=output file
115# $2=schema file
116# $3=deps
117# $4=args
118define mk-sdk-repo-xml
119$(1): $$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $(2) $(3)
120 XMLLINT=$$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $$@ $(2) $(4)
121
122$$(call dist-for-goals,sdk_repo,$(1))
123endef
124
Raphael48023782011-02-23 16:46:42 -0800125# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800126# Rules for main host sdk
127
128ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
129
Raphael Mollea40d2f2014-04-24 19:13:47 -0700130# Similarly capture all sys-img.xml that are now split out of repository.xml
131$(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 -0800132
Ji-Hwan Leee3e3de02014-06-22 04:26:56 +0900133SDK_SYSIMG_DEPS += \
134 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
135
136# All these go in the main repository.xml
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900137$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools))
138$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
139$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
140$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
141$(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 +0900142$(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
Raphael Moll9516dc52012-02-27 15:18:29 -0800143
144SDK_REPO_DEPS += \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800145 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools) \
146 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
147 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
148 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
149 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800150 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
Raphael Moll9516dc52012-02-27 15:18:29 -0800151
152endif
153
154# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800155# Rules for win_sdk
156
157ifneq ($(WIN_SDK_ZIP),)
158
159# docs, platforms and samples have nothing OS-dependent right now.
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900160$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),build-tools))
161$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),platform-tools))
Raphael2ff496b2011-02-15 16:08:36 -0800162
163SDK_REPO_DEPS += \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800164 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),build-tools) \
165 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
Raphael2ff496b2011-02-15 16:08:36 -0800166
167endif
168
Raphael48023782011-02-23 16:46:42 -0800169# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800170# Pickup the most recent xml schema for repository and add-on
Raphael2ff496b2011-02-15 16:08:36 -0800171
Raphael Moll9516dc52012-02-27 15:18:29 -0800172SDK_REPO_XSD := \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800173 $(lastword \
174 $(wildcard \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700175 prebuilts/devtools/repository/sdk-repository-*.xsd \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800176 ))
Raphael2ff496b2011-02-15 16:08:36 -0800177
Raphael Moll9516dc52012-02-27 15:18:29 -0800178SDK_ADDON_XSD := \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800179 $(lastword \
180 $(wildcard \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700181 prebuilts/devtools/repository/sdk-addon-*.xsd \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800182 ))
183
Raphael Mollea40d2f2014-04-24 19:13:47 -0700184SDK_SYSIMG_XSD := \
185 $(lastword \
186 $(wildcard \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700187 prebuilts/devtools/repository/sdk-sys-img-*.xsd \
Raphael Mollea40d2f2014-04-24 19:13:47 -0700188 ))
189
Raphael2ff496b2011-02-15 16:08:36 -0800190
Raphael48023782011-02-23 16:46:42 -0800191# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800192# Rules for sdk addon
193
bohu52e0bf32015-06-01 17:25:11 -0700194ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Raphael2ff496b2011-02-15 16:08:36 -0800195ifneq ($(ADDON_SDK_ZIP),)
196
197# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
198# already packaged correctly. All we have to do is dist it with
199# a different destination name.
200
Raphael48023782011-02-23 16:46:42 -0800201RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
202
203$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
204
205# Also generate the addon.xml using the latest schema and the renamed addon zip
206
207SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
208
Dan Willemsenf0407b32018-10-10 12:51:43 -0700209$(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_XML),$(SDK_ADDON_XSD),$(ADDON_SDK_ZIP),add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)))
Raphael48023782011-02-23 16:46:42 -0800210
Dan Willemsenf0407b32018-10-10 12:51:43 -0700211SDK_ADDON_XML :=
212RENAMED_ADDON_ZIP :=
Raphael2ff496b2011-02-15 16:08:36 -0800213
214endif
215
Raphael Mollfa090e22014-08-21 15:15:02 -0700216ifneq ($(ADDON_SDK_IMG_ZIP),)
217
218# Copy/rename the ADDON_SDK_IMG_ZIP file as an sdk-repo zip in the dist dir
219
220RENAMED_ADDON_IMG_ZIP := $(ADDON_SDK_IMG_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_IMG_ZIP),system-images))
221
222$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_IMG_ZIP))
223
224# Generate the system-image XML for the addon sys-img
225
226SDK_ADDON_IMG_XML := $(dir $(ADDON_SDK_ZIP))/addon-sys-img.xml
227
Dan Willemsenf0407b32018-10-10 12:51:43 -0700228$(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)))
Raphael Mollfa090e22014-08-21 15:15:02 -0700229
Dan Willemsenf0407b32018-10-10 12:51:43 -0700230SDK_ADDON_IMG_XML :=
231RENAMED_ADDON_IMG_ZIP :=
Raphael Mollfa090e22014-08-21 15:15:02 -0700232
233endif
bohu52e0bf32015-06-01 17:25:11 -0700234endif
Raphael Mollfa090e22014-08-21 15:15:02 -0700235
Raphael48023782011-02-23 16:46:42 -0800236# -----------------------------------------------------------------
237# Rules for the SDK Repository XML
Raphael2ff496b2011-02-15 16:08:36 -0800238
Raphael Moll26bcf6a2014-06-03 10:44:56 -0700239SDK_REPO_XML := $(MAIN_SDK_DIR)/repository.xml
240SDK_EXTRAS_XML := $(MAIN_SDK_DIR)/repo-extras.xml
241SDK_SYSIMG_XML := $(MAIN_SDK_DIR)/repo-sys-img.xml
Raphael48023782011-02-23 16:46:42 -0800242
243ifneq ($(SDK_REPO_XML_ARGS),)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700244$(eval $(call mk-sdk-repo-xml,$(SDK_REPO_XML),$(SDK_REPO_XSD),$(SDK_REPO_DEPS),$(SDK_REPO_XML_ARGS)))
Raphael48023782011-02-23 16:46:42 -0800245else
Dan Willemsenf0407b32018-10-10 12:51:43 -0700246SDK_REPO_XML :=
Raphael48023782011-02-23 16:46:42 -0800247endif
248
Raphael Moll9516dc52012-02-27 15:18:29 -0800249
250ifneq ($(SDK_EXTRAS_XML_ARGS),)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700251$(eval $(call mk-sdk-repo-xml,$(SDK_EXTRAS_XML),$(SDK_ADDON_XSD),$(SDK_EXTRAS_DEPS),$(SDK_EXTRAS_XML_ARGS)))
Raphael Moll9516dc52012-02-27 15:18:29 -0800252else
Dan Willemsenf0407b32018-10-10 12:51:43 -0700253SDK_EXTRAS_XML :=
Raphael Moll9516dc52012-02-27 15:18:29 -0800254endif
255
Raphael Mollea40d2f2014-04-24 19:13:47 -0700256
257ifneq ($(SDK_SYSIMG_XML_ARGS),)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700258$(eval $(call mk-sdk-repo-xml,$(SDK_SYSIMG_XML),$(SDK_SYSIMG_XSD),$(SDK_SYSIMG_DEPS),$(SDK_SYSIMG_XML_ARGS)))
Raphael Mollea40d2f2014-04-24 19:13:47 -0700259else
Dan Willemsenf0407b32018-10-10 12:51:43 -0700260SDK_SYSIMG_XML :=
Raphael Mollea40d2f2014-04-24 19:13:47 -0700261endif
262
Raphael48023782011-02-23 16:46:42 -0800263# -----------------------------------------------------------------
264
Raphael Mollea40d2f2014-04-24 19:13:47 -0700265sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
Raphael2ff496b2011-02-15 16:08:36 -0800266
Dan Willemsenf0407b32018-10-10 12:51:43 -0700267SDK_REPO_DEPS :=
268SDK_REPO_XML :=
269SDK_REPO_XML_ARGS :=
270SDK_EXTRAS_DEPS :=
271SDK_EXTRAS_XML :=
272SDK_EXTRAS_XML_ARGS :=
273SDK_SYSIMG_DEPS :=
274SDK_SYSIMG_XML :=
275SDK_SYSIMG_XML_ARGS :=
276
277mk-sdk-repo-pkg-1 :=
278mk-sdk-repo-pkg-2 :=
279mk-sdk-repo-pkg-3 :=
280mk-sdk-repo-sources :=
281mk-sdk-repo-xml :=
282sdk-repo-pkg-zip :=