blob: deb3bdc79f31d50c3d6fde65a48d119db5dbdbc3 [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#
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))"
Raphael48023782011-02-23 16:46:42 -080033 $(hide) cd $(basename $(2)) && \
34 zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) $(3)/*
Raphael2ff496b2011-02-15 16:08:36 -080035$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael48023782011-02-23 16:46:42 -080036SDK_REPO_XML_ARGS += $(3) $(1) \
37 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael2ff496b2011-02-15 16:08:36 -080038endef
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))"
Raphael48023782011-02-23 16:46:42 -080054 $(hide) cd $(basename $(2))/$(3) && \
55 zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
Raphael2ff496b2011-02-15 16:08:36 -080056$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael48023782011-02-23 16:46:42 -080057SDK_REPO_XML_ARGS += $(3) $(1) \
58 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael2ff496b2011-02-15 16:08:36 -080059endef
60
Raphael Moll3d308aa2011-10-01 23:44:08 -070061# 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
Raphael Mollda9eabd2011-09-28 11:18:34 -070086# 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
Raphaeld79eab52011-11-15 16:30:14 -080093$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(HOST_OUT)/development/sdk/source_source.properties
Raphael Mollda9eabd2011-09-28 11:18:34 -070094 @echo "Building SDK sources package"
Raphael Molla85a93f2012-03-27 10:45:59 -070095 $(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py --exec-zip \
Raphaeld79eab52011-11-15 16:30:14 -080096 $(HOST_OUT)/development/sdk/source_source.properties \
Raphael Mollda9eabd2011-09-28 11:18:34 -070097 $(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
Raphael2ff496b2011-02-15 16:08:36 -0800103
Raphael48023782011-02-23 16:46:42 -0800104# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800105# 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# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800139# 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 += \
Raphael Moll4dedff62011-09-27 20:17:07 -0700148 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),tools) \
Raphael2ff496b2011-02-15 16:08:36 -0800149 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
150
151endif
152
Raphael48023782011-02-23 16:46:42 -0800153# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800154# Pickup the most recent xml schema for repository and add-on
Raphael2ff496b2011-02-15 16:08:36 -0800155
Raphael Moll9516dc52012-02-27 15:18:29 -0800156SDK_REPO_XSD := \
157 $(lastword \
158 $(wildcard \
159 $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
160 ))
Raphael2ff496b2011-02-15 16:08:36 -0800161
Raphael Moll9516dc52012-02-27 15:18:29 -0800162SDK_ADDON_XSD := \
163 $(lastword \
164 $(wildcard \
165 $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
166 ))
Raphael2ff496b2011-02-15 16:08:36 -0800167
Raphael48023782011-02-23 16:46:42 -0800168# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800169# 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
Raphael48023782011-02-23 16:46:42 -0800177RENAMED_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
Raphael48023782011-02-23 16:46:42 -0800185$(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))
Raphael2ff496b2011-02-15 16:08:36 -0800190
191endif
192
Raphael48023782011-02-23 16:46:42 -0800193# -----------------------------------------------------------------
194# Rules for the SDK Repository XML
Raphael2ff496b2011-02-15 16:08:36 -0800195
Raphael Moll9516dc52012-02-27 15:18:29 -0800196SDK_REPO_XML := $(HOST_OUT)/sdk/repository.xml
197SDK_EXTRAS_XML := $(HOST_OUT)/sdk/repo-extras.xml
Raphael48023782011-02-23 16:46:42 -0800198
199ifneq ($(SDK_REPO_XML_ARGS),)
200
Raphael48023782011-02-23 16:46:42 -0800201$(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
Raphael Moll9516dc52012-02-27 15:18:29 -0800213
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
Raphael48023782011-02-23 16:46:42 -0800228# -----------------------------------------------------------------
229
Raphael Moll9516dc52012-02-27 15:18:29 -0800230sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML)
Raphael2ff496b2011-02-15 16:08:36 -0800231 @echo "Packing of SDK repository done"
232