• 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 :=
9
10# 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
16$(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
17endef
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#
24# $1=OS (e.g. linux-x86, windows, etc)
25# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
26# $3=package to create (e.g. tools, docs, etc.)
27#
28# The rule depends on the SDK zip file, which is defined by $2.
29#
30define mk-sdk-repo-pkg-1
31$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
32	@echo "Building SDK repository package $(3) from $(notdir $(2))"
33	$(hide) cd $(basename $(2)) && \
34			zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) $(3)/*
35$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
36SDK_REPO_XML_ARGS += $(3) $(1) \
37	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
38endef
39
40# Defines the rule to build an SDK repository package when the
41# package directory contains a single platform-related inner directory.
42# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
43# this generates an sdk-repo-linux-samples that contains android-N/*
44#
45# $1=OS (e.g. linux-x86, windows, etc)
46# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
47# $3=package to create (e.g. platforms, samples, etc.)
48#
49# The rule depends on the SDK zip file, which is defined by $2.
50#
51define mk-sdk-repo-pkg-2
52$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
53	@echo "Building SDK repository package $(3) from $(notdir $(2))"
54	$(hide) cd $(basename $(2))/$(3) && \
55			zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
56$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
57SDK_REPO_XML_ARGS += $(3) $(1) \
58	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
59endef
60
61# Defines the rule to build an SDK repository package when the
62# package directory contains 3 levels from the sdk dir, for example
63# to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
64# Because we do not know the intermediary directory name, this only works
65# if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
66# unique.)
67#
68# $1=OS (e.g. linux-x86, windows, etc)
69# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
70# $3=package to create (e.g. system-images, support, etc.)
71# $4=the root of directory to package in the sdk (e.g. extra/android).
72#    this must be a 2-segment path, the last one can be *.
73#
74# The rule depends on the SDK zip file, which is defined by $2.
75#
76define mk-sdk-repo-pkg-3
77$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
78	@echo "Building SDK repository package $(3) from $(notdir $(2))"
79	$(hide) cd $(basename $(2))/$(4) && \
80			zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
81$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
82SDK_REPO_XML_ARGS += $(3) $(1) \
83	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
84endef
85
86# Defines the rule to build an SDK sources package.
87#
88# $1=OS (e.g. linux-x86, windows, etc)
89# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
90# $3=package to create, must be "sources"
91#
92define mk-sdk-repo-sources
93$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(HOST_OUT)/development/sdk/source_source.properties
94	@echo "Building SDK sources package"
95	$(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py --exec-zip \
96			$(HOST_OUT)/development/sdk/source_source.properties \
97			$(call sdk-repo-pkg-zip,$(1),$(2),$(3)) \
98			$(TOPDIR).
99$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
100SDK_REPO_XML_ARGS += $(3) $(1) \
101	$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
102endef
103
104# -----------------------------------------------------------------
105# Rules for main host sdk
106
107ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
108
109# Note that extras are now located in addon.xml, not in repository.xml,
110# so we capture all extras first.
111$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
112SDK_EXTRAS_XML_ARGS := $(SDK_REPO_XML_ARGS)
113SDK_REPO_XML_ARGS   :=
114
115SDK_EXTRAS_DEPS += \
116		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support)
117
118
119$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),tools))
120$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
121$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
122$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
123$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
124$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
125$(eval $(call mk-sdk-repo-sources,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
126
127SDK_REPO_DEPS += \
128		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
129		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
130		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
131		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
132		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
133		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
134		$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
135
136endif
137
138# -----------------------------------------------------------------
139# Rules for win_sdk
140
141ifneq ($(WIN_SDK_ZIP),)
142
143# docs, platforms and samples have nothing OS-dependent right now.
144$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),tools))
145$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),platform-tools))
146
147SDK_REPO_DEPS += \
148	$(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),tools) \
149        $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
150
151endif
152
153# -----------------------------------------------------------------
154# Pickup the most recent xml schema for repository and add-on
155
156SDK_REPO_XSD := \
157	$(lastword \
158	  $(wildcard \
159	    $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
160	))
161
162SDK_ADDON_XSD := \
163	$(lastword \
164	  $(wildcard \
165	    $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
166	))
167
168# -----------------------------------------------------------------
169# Rules for sdk addon
170
171ifneq ($(ADDON_SDK_ZIP),)
172
173# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
174# already packaged correctly. All we have to do is dist it with
175# a different destination name.
176
177RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
178
179$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
180
181# Also generate the addon.xml using the latest schema and the renamed addon zip
182
183SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
184
185$(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
186	$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
187		$(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
188
189$(call dist-for-goals, sdk_repo, $(SDK_ADDON_XML))
190
191endif
192
193# -----------------------------------------------------------------
194# Rules for the SDK Repository XML
195
196SDK_REPO_XML   := $(HOST_OUT)/sdk/repository.xml
197SDK_EXTRAS_XML := $(HOST_OUT)/sdk/repo-extras.xml
198
199ifneq ($(SDK_REPO_XML_ARGS),)
200
201$(SDK_REPO_XML): $(SDK_REPO_DEPS)
202	$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
203		$(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
204
205$(call dist-for-goals, sdk_repo, $(SDK_REPO_XML))
206
207else
208
209$(SDK_REPO_XML): ;
210
211endif
212
213
214ifneq ($(SDK_EXTRAS_XML_ARGS),)
215
216$(SDK_EXTRAS_XML): $(SDK_EXTRAS_DEPS)
217	$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
218		$(SDK_EXTRAS_XML) $(SDK_ADDON_XSD) $(SDK_EXTRAS_XML_ARGS)
219
220$(call dist-for-goals, sdk_repo, $(SDK_EXTRAS_XML))
221
222else
223
224$(SDK_EXTRAS_XML): ;
225
226endif
227
228# -----------------------------------------------------------------
229
230sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML)
231	@echo "Packing of SDK repository done"
232
233