blob: de48e57e427b86ce78a5a9bb661c9b2c071c7cab [file] [log] [blame]
Raphael2ff496b2011-02-15 16:08:36 -08001# Makefile to build the SDK repository packages.
2
3.PHONY: sdk_repo
4
Raphael48023782011-02-23 16:46:42 -08005SDK_REPO_DEPS :=
6SDK_REPO_XML_ARGS :=
7
Raphael2ff496b2011-02-15 16:08:36 -08008# Define the name of a package zip file to generate
9# $1=OS (e.g. linux-x86, windows, etc)
10# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
11# $3=package to create (e.g. tools, docs, etc.)
12#
13define sdk-repo-pkg-zip
Raphael48023782011-02-23 16:46:42 -080014$(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
Raphael2ff496b2011-02-15 16:08:36 -080015endef
16
17# Defines the rule to build an SDK repository package by zipping all
18# the content of the given directory.
19# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
20# this generates an sdk-repo-linux-tools that contains tools/*
21#
22# $1=OS (e.g. linux-x86, windows, etc)
23# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
24# $3=package to create (e.g. tools, docs, etc.)
25#
26# The rule depends on the SDK zip file, which is defined by $2.
27#
28define mk-sdk-repo-pkg-1
29$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
30 @echo "Building SDK repository package $(3) from $(notdir $(2))"
Raphael48023782011-02-23 16:46:42 -080031 $(hide) cd $(basename $(2)) && \
32 zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) $(3)/*
Raphael2ff496b2011-02-15 16:08:36 -080033$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael48023782011-02-23 16:46:42 -080034SDK_REPO_XML_ARGS += $(3) $(1) \
35 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael2ff496b2011-02-15 16:08:36 -080036endef
37
38# Defines the rule to build an SDK repository package when the
39# package directory contains a single platform-related inner directory.
40# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
41# this generates an sdk-repo-linux-samples that contains android-N/*
42#
43# $1=OS (e.g. linux-x86, windows, etc)
44# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
45# $3=package to create (e.g. platforms, samples, etc.)
46#
47# The rule depends on the SDK zip file, which is defined by $2.
48#
49define mk-sdk-repo-pkg-2
50$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
51 @echo "Building SDK repository package $(3) from $(notdir $(2))"
Raphael48023782011-02-23 16:46:42 -080052 $(hide) cd $(basename $(2))/$(3) && \
53 zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
Raphael2ff496b2011-02-15 16:08:36 -080054$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael48023782011-02-23 16:46:42 -080055SDK_REPO_XML_ARGS += $(3) $(1) \
56 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael2ff496b2011-02-15 16:08:36 -080057endef
58
Raphael Moll3d308aa2011-10-01 23:44:08 -070059# Defines the rule to build an SDK repository package when the
60# package directory contains 3 levels from the sdk dir, for example
61# to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
62# Because we do not know the intermediary directory name, this only works
63# if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
64# unique.)
65#
66# $1=OS (e.g. linux-x86, windows, etc)
67# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
68# $3=package to create (e.g. system-images, support, etc.)
69# $4=the root of directory to package in the sdk (e.g. extra/android).
70# this must be a 2-segment path, the last one can be *.
71#
72# The rule depends on the SDK zip file, which is defined by $2.
73#
74define mk-sdk-repo-pkg-3
75$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
76 @echo "Building SDK repository package $(3) from $(notdir $(2))"
77 $(hide) cd $(basename $(2))/$(4) && \
78 zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
79$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
80SDK_REPO_XML_ARGS += $(3) $(1) \
81 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
82endef
83
Raphael Mollda9eabd2011-09-28 11:18:34 -070084# Defines the rule to build an SDK sources package.
85#
86# $1=OS (e.g. linux-x86, windows, etc)
87# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
88# $3=package to create, must be "sources"
89#
90define mk-sdk-repo-sources
91$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(TOPDIR)development/sdk/source_source.properties
92 @echo "Building SDK sources package"
93 $(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py \
94 $(TOPDIR)development/sdk/source_source.properties \
95 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)) \
96 $(TOPDIR).
97$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
98SDK_REPO_XML_ARGS += $(3) $(1) \
99 $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
100endef
Raphael2ff496b2011-02-15 16:08:36 -0800101
Raphael48023782011-02-23 16:46:42 -0800102# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800103# Rules for win_sdk
104
105ifneq ($(WIN_SDK_ZIP),)
106
107# docs, platforms and samples have nothing OS-dependent right now.
108$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),tools))
109$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),platform-tools))
110
111SDK_REPO_DEPS += \
Raphael Moll4dedff62011-09-27 20:17:07 -0700112 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),tools) \
Raphael2ff496b2011-02-15 16:08:36 -0800113 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
114
115endif
116
Raphael48023782011-02-23 16:46:42 -0800117# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800118# Rules for main host sdk
119
120ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
121
122$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),tools))
123$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
124$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
125$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
126$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
Raphael Moll3d308aa2011-10-01 23:44:08 -0700127$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
128$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
Raphael Mollda9eabd2011-09-28 11:18:34 -0700129$(eval $(call mk-sdk-repo-sources,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
Raphael2ff496b2011-02-15 16:08:36 -0800130
131SDK_REPO_DEPS += \
132 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
133 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
134 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
135 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
136 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
Raphael Mollda9eabd2011-09-28 11:18:34 -0700137 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
Raphael Moll3d308aa2011-10-01 23:44:08 -0700138 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support) \
Raphael Mollda9eabd2011-09-28 11:18:34 -0700139 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
Raphael2ff496b2011-02-15 16:08:36 -0800140
141endif
142
Raphael48023782011-02-23 16:46:42 -0800143# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800144# Rules for sdk addon
145
146ifneq ($(ADDON_SDK_ZIP),)
147
148# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
149# already packaged correctly. All we have to do is dist it with
150# a different destination name.
151
Raphael48023782011-02-23 16:46:42 -0800152RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
153
154$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
155
156# Also generate the addon.xml using the latest schema and the renamed addon zip
157
158SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
159
160SDK_ADDON_XSD := \
161 $(lastword \
162 $(wildcard \
163 $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
164 ))
165
166$(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
167 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
168 $(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
169
170$(call dist-for-goals, sdk_repo, $(SDK_ADDON_XML))
Raphael2ff496b2011-02-15 16:08:36 -0800171
172endif
173
Raphael48023782011-02-23 16:46:42 -0800174# -----------------------------------------------------------------
175# Rules for the SDK Repository XML
Raphael2ff496b2011-02-15 16:08:36 -0800176
Raphael48023782011-02-23 16:46:42 -0800177SDK_REPO_XML := $(HOST_OUT)/sdk/repository.xml
178
179ifneq ($(SDK_REPO_XML_ARGS),)
180
181# Pickup the most recent xml schema
182SDK_REPO_XSD := \
183 $(lastword \
184 $(wildcard \
185 $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
186 ))
187
188$(SDK_REPO_XML): $(SDK_REPO_DEPS)
189 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
190 $(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
191
192$(call dist-for-goals, sdk_repo, $(SDK_REPO_XML))
193
194else
195
196$(SDK_REPO_XML): ;
197
198endif
199
200# -----------------------------------------------------------------
201
202sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML)
Raphael2ff496b2011-02-15 16:08:36 -0800203 @echo "Packing of SDK repository done"
204