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