blob: c709502b222c2f9f8feb4773c0fffb3a2ee653c0 [file] [log] [blame]
Raphael922ee892011-02-15 16:08:36 -08001# Makefile to build the SDK repository packages.
2
3.PHONY: sdk_repo
4
Raphael31d15b92011-02-23 16:46:42 -08005SDK_REPO_DEPS :=
6SDK_REPO_XML_ARGS :=
7
Raphael922ee892011-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
Raphael31d15b92011-02-23 16:46:42 -080014$(dir $(2))/sdk-repo-$(1)-$(3)-$(FILE_NAME_TAG).zip
Raphael922ee892011-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))"
Raphael31d15b92011-02-23 16:46:42 -080031 $(hide) cd $(basename $(2)) && \
32 zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) $(3)/*
Raphael922ee892011-02-15 16:08:36 -080033$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael31d15b92011-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)))
Raphael922ee892011-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))"
Raphael31d15b92011-02-23 16:46:42 -080052 $(hide) cd $(basename $(2))/$(3) && \
53 zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
Raphael922ee892011-02-15 16:08:36 -080054$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
Raphael31d15b92011-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)))
Raphael922ee892011-02-15 16:08:36 -080057endef
58
59
Raphael31d15b92011-02-23 16:46:42 -080060# -----------------------------------------------------------------
Raphael922ee892011-02-15 16:08:36 -080061# Rules for win_sdk
62
63ifneq ($(WIN_SDK_ZIP),)
64
65# docs, platforms and samples have nothing OS-dependent right now.
66$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),tools))
67$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),platform-tools))
68
69SDK_REPO_DEPS += \
70 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),tools) \
71 $(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),platform-tools)
72
73endif
74
Raphael31d15b92011-02-23 16:46:42 -080075# -----------------------------------------------------------------
Raphael922ee892011-02-15 16:08:36 -080076# Rules for main host sdk
77
78ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
79
80$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),tools))
81$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
82$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
83$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
84$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
85
86SDK_REPO_DEPS += \
87 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
88 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
89 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
90 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
91 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
92
93endif
94
Raphael31d15b92011-02-23 16:46:42 -080095# -----------------------------------------------------------------
Raphael922ee892011-02-15 16:08:36 -080096# Rules for sdk addon
97
98ifneq ($(ADDON_SDK_ZIP),)
99
100# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
101# already packaged correctly. All we have to do is dist it with
102# a different destination name.
103
Raphael31d15b92011-02-23 16:46:42 -0800104RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
105
106$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
107
108# Also generate the addon.xml using the latest schema and the renamed addon zip
109
110SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
111
112SDK_ADDON_XSD := \
113 $(lastword \
114 $(wildcard \
115 $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
116 ))
117
118$(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
119 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
120 $(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
121
122$(call dist-for-goals, sdk_repo, $(SDK_ADDON_XML))
Raphael922ee892011-02-15 16:08:36 -0800123
124endif
125
Raphael31d15b92011-02-23 16:46:42 -0800126# -----------------------------------------------------------------
127# Rules for the SDK Repository XML
Raphael922ee892011-02-15 16:08:36 -0800128
Raphael31d15b92011-02-23 16:46:42 -0800129SDK_REPO_XML := $(HOST_OUT)/sdk/repository.xml
130
131ifneq ($(SDK_REPO_XML_ARGS),)
132
133# Pickup the most recent xml schema
134SDK_REPO_XSD := \
135 $(lastword \
136 $(wildcard \
137 $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
138 ))
139
140$(SDK_REPO_XML): $(SDK_REPO_DEPS)
141 $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
142 $(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
143
144$(call dist-for-goals, sdk_repo, $(SDK_REPO_XML))
145
146else
147
148$(SDK_REPO_XML): ;
149
150endif
151
152# -----------------------------------------------------------------
153
154sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML)
Raphael922ee892011-02-15 16:08:36 -0800155 @echo "Packing of SDK repository done"
156