blob: 37e106e670453ea336ec9aa66c18fc5faf78bfd3 [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 :=
Dan Willemsenf0407b32018-10-10 12:51:43 -07009SDK_SYSIMG_DEPS :=
10SDK_SYSIMG_XML_ARGS :=
Raphael48023782011-02-23 16:46:42 -080011
Raphael2ff496b2011-02-15 16:08:36 -080012# Define the name of a package zip file to generate
Dan Willemsen53052e32021-09-16 14:22:45 -070013# $1=OS (e.g. linux, darwin)
Raphael2ff496b2011-02-15 16:08:36 -080014# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
15# $3=package to create (e.g. tools, docs, etc.)
16#
17define sdk-repo-pkg-zip
Jeongik Cha88895e52023-04-27 09:24:14 +090018$(dir $(2))/sdk-repo-$(1)-$(3).zip
Raphael2ff496b2011-02-15 16:08:36 -080019endef
20
21# Defines the rule to build an SDK repository package by zipping all
22# the content of the given directory.
23# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
24# this generates an sdk-repo-linux-tools that contains tools/*
25#
Raphael Mollea40d2f2014-04-24 19:13:47 -070026# $1=variable where to accumulate args for mk_sdk_repo_xml.
Dan Willemsen53052e32021-09-16 14:22:45 -070027# $2=OS (e.g. linux, darwin)
Raphael Mollea40d2f2014-04-24 19:13:47 -070028# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
29# $4=package to create (e.g. tools, docs, etc.)
Raphael2ff496b2011-02-15 16:08:36 -080030#
31# The rule depends on the SDK zip file, which is defined by $2.
32#
33define mk-sdk-repo-pkg-1
Raphael Mollea40d2f2014-04-24 19:13:47 -070034$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
35 @echo "Building SDK repository package $(4) from $(notdir $(3))"
Cole Faust127efd82023-07-13 15:28:51 -070036 $(hide) rm -f $$@ && \
37 $(SOONG_ZIP) -o $$@ -C $(basename $(3)) -D $(basename $(3))/$(4)
Jeongik Cha88895e52023-04-27 09:24:14 +090038$(call dist-for-goals-with-filenametag, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael Mollea40d2f2014-04-24 19:13:47 -070039$(1) += $(4) $(2) \
40 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Bob Badour4964db92022-09-12 18:13:55 -070041
42$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
43$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
Raphael2ff496b2011-02-15 16:08:36 -080044endef
45
46# Defines the rule to build an SDK repository package when the
47# package directory contains a single platform-related inner directory.
48# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
49# this generates an sdk-repo-linux-samples that contains android-N/*
50#
Raphael Mollea40d2f2014-04-24 19:13:47 -070051# $1=variable where to accumulate args for mk_sdk_repo_xml.
Dan Willemsen53052e32021-09-16 14:22:45 -070052# $2=OS (e.g. linux, darwin)
Raphael Mollea40d2f2014-04-24 19:13:47 -070053# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
54# $4=package to create (e.g. platforms, samples, etc.)
Raphael2ff496b2011-02-15 16:08:36 -080055#
56# The rule depends on the SDK zip file, which is defined by $2.
57#
58define mk-sdk-repo-pkg-2
Raphael Mollea40d2f2014-04-24 19:13:47 -070059$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
60 @echo "Building SDK repository package $(4) from $(notdir $(3))"
Cole Faust127efd82023-07-13 15:28:51 -070061 $(hide) rm -f $$@ && \
62 $(SOONG_ZIP) -o $$@ -C $(basename $(3))/$(4) -D $(basename $(3))/$(4)
Jeongik Cha88895e52023-04-27 09:24:14 +090063$(call dist-for-goals-with-filenametag, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael Mollea40d2f2014-04-24 19:13:47 -070064$(1) += $(4) $(2) \
65 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Bob Badour4964db92022-09-12 18:13:55 -070066
67$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
68$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3),$(PRODUCT_OUT)/:/)
Raphael Moll3d308aa2011-10-01 23:44:08 -070069endef
70
Raphael Mollda9eabd2011-09-28 11:18:34 -070071# Defines the rule to build an SDK sources package.
72#
Raphael Mollea40d2f2014-04-24 19:13:47 -070073# $1=variable where to accumulate args for mk_sdk_repo_xml.
Dan Willemsen53052e32021-09-16 14:22:45 -070074# $2=OS (e.g. linux, darwin)
Raphael Mollea40d2f2014-04-24 19:13:47 -070075# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
76# $4=package to create, must be "sources"
Raphael Mollda9eabd2011-09-28 11:18:34 -070077#
78define mk-sdk-repo-sources
Anton Hanssonac0687b2023-09-22 10:20:19 +000079bcp_srcjar := $(call intermediates-dir-for,ETC,platform-bootclasspath.srcjar)/platform-bootclasspath.srcjar
80source_props := $(HOST_OUT)/development/sdk/source_source.properties
81$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) $$(bcp_srcjar) $$(source_props)
Raphael Mollda9eabd2011-09-28 11:18:34 -070082 @echo "Building SDK sources package"
Anton Hanssona781d692023-10-09 15:22:49 +000083 rm -rf $$(dir $$@)/tmp
84 unzip -qd $$(dir $$@)/tmp $$(bcp_srcjar)
85 $$(SOONG_ZIP) -o $$@ -P src -e source.properties -f $$(source_props) -C $$(dir $$@)/tmp -D $$(dir $$@)/tmp
86 rm -rf $$(dir $$@)/tmp
Jeongik Cha88895e52023-04-27 09:24:14 +090087$(call dist-for-goals-with-filenametag, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Raphael Mollea40d2f2014-04-24 19:13:47 -070088$(1) += $(4) $(2) \
89 $(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
Bob Badour4964db92022-09-12 18:13:55 -070090
91$(call declare-1p-container,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),sdk_repo)
92$(call declare-container-license-deps,$(call sdk-repo-pkg-zip,$(2),$(3),$(4)),$(3) $(HOST_OUT)/development/sdk/source_source.properties,$(PRODUCT_OUT)/:/)
Raphael Mollda9eabd2011-09-28 11:18:34 -070093endef
Raphael2ff496b2011-02-15 16:08:36 -080094
Dan Willemsenf0407b32018-10-10 12:51:43 -070095# Defines the rule to build an XML file for a package.
96#
97# $1=output file
98# $2=schema file
99# $3=deps
100# $4=args
101define mk-sdk-repo-xml
102$(1): $$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $(2) $(3)
103 XMLLINT=$$(XMLLINT) development/build/tools/mk_sdk_repo_xml.sh $$@ $(2) $(4)
104
105$$(call dist-for-goals,sdk_repo,$(1))
Bob Badour4964db92022-09-12 18:13:55 -0700106
107$(call declare-1p-target,$(1),sdk_repo)
108$(call declare-container-license-deps,$(1),$(2) $(3),$(PRODUCT_OUT)/:/)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700109endef
110
Raphael48023782011-02-23 16:46:42 -0800111# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800112# Rules for main host sdk
113
Dan Willemsen53052e32021-09-16 14:22:45 -0700114ifneq ($(filter sdk,$(MAKECMDGOALS)),)
Raphael Moll9516dc52012-02-27 15:18:29 -0800115
Ji-Hwan Leee3e3de02014-06-22 04:26:56 +0900116# All these go in the main repository.xml
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900117$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
118$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
119$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
Ji-Hwan Lee5cd3de12014-06-21 17:19:49 +0900120$(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
Raphael Moll9516dc52012-02-27 15:18:29 -0800121
122SDK_REPO_DEPS += \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800123 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
124 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
125 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
Raphael Moll9ca69cf2013-02-12 13:48:39 -0800126 $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
Raphael Moll9516dc52012-02-27 15:18:29 -0800127
128endif
129
130# -----------------------------------------------------------------
Raphael Moll9516dc52012-02-27 15:18:29 -0800131# Pickup the most recent xml schema for repository and add-on
Raphael2ff496b2011-02-15 16:08:36 -0800132
Raphael Moll9516dc52012-02-27 15:18:29 -0800133SDK_REPO_XSD := \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800134 $(lastword \
135 $(wildcard \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700136 prebuilts/devtools/repository/sdk-repository-*.xsd \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800137 ))
Raphael2ff496b2011-02-15 16:08:36 -0800138
Raphael Moll9516dc52012-02-27 15:18:29 -0800139SDK_ADDON_XSD := \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800140 $(lastword \
141 $(wildcard \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700142 prebuilts/devtools/repository/sdk-addon-*.xsd \
Raphael Mollbc7c8c52013-02-12 13:48:39 -0800143 ))
144
Raphael Mollea40d2f2014-04-24 19:13:47 -0700145SDK_SYSIMG_XSD := \
146 $(lastword \
147 $(wildcard \
Dan Willemsenf0407b32018-10-10 12:51:43 -0700148 prebuilts/devtools/repository/sdk-sys-img-*.xsd \
Raphael Mollea40d2f2014-04-24 19:13:47 -0700149 ))
150
Raphael2ff496b2011-02-15 16:08:36 -0800151
Raphael48023782011-02-23 16:46:42 -0800152# -----------------------------------------------------------------
Raphael2ff496b2011-02-15 16:08:36 -0800153# Rules for sdk addon
154
bohu52e0bf32015-06-01 17:25:11 -0700155ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Raphael2ff496b2011-02-15 16:08:36 -0800156ifneq ($(ADDON_SDK_ZIP),)
157
158# ADDON_SDK_ZIP is defined in build/core/tasks/sdk-addon.sh and is
159# already packaged correctly. All we have to do is dist it with
160# a different destination name.
161
Raphael48023782011-02-23 16:46:42 -0800162RENAMED_ADDON_ZIP := $(ADDON_SDK_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_ZIP),addon))
163
164$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
165
166# Also generate the addon.xml using the latest schema and the renamed addon zip
167
168SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
169
Dan Willemsenf0407b32018-10-10 12:51:43 -0700170$(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_XML),$(SDK_ADDON_XSD),$(ADDON_SDK_ZIP),add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)))
Raphael48023782011-02-23 16:46:42 -0800171
Dan Willemsenf0407b32018-10-10 12:51:43 -0700172SDK_ADDON_XML :=
173RENAMED_ADDON_ZIP :=
Raphael2ff496b2011-02-15 16:08:36 -0800174
175endif
176
Raphael Mollfa090e22014-08-21 15:15:02 -0700177ifneq ($(ADDON_SDK_IMG_ZIP),)
178
179# Copy/rename the ADDON_SDK_IMG_ZIP file as an sdk-repo zip in the dist dir
180
181RENAMED_ADDON_IMG_ZIP := $(ADDON_SDK_IMG_ZIP):$(notdir $(call sdk-repo-pkg-zip,$(HOST_OS),$(ADDON_SDK_IMG_ZIP),system-images))
182
183$(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_IMG_ZIP))
184
185# Generate the system-image XML for the addon sys-img
186
187SDK_ADDON_IMG_XML := $(dir $(ADDON_SDK_ZIP))/addon-sys-img.xml
188
Dan Willemsenf0407b32018-10-10 12:51:43 -0700189$(eval $(call mk-sdk-repo-xml,$(SDK_ADDON_IMG_XML),$(SDK_SYSIMG_XSD),$(ADDON_SDK_IMG_ZIP),system-image $(HOST_OS) $(RENAMED_ADDON_IMG_ZIP)))
Raphael Mollfa090e22014-08-21 15:15:02 -0700190
Dan Willemsenf0407b32018-10-10 12:51:43 -0700191SDK_ADDON_IMG_XML :=
192RENAMED_ADDON_IMG_ZIP :=
Raphael Mollfa090e22014-08-21 15:15:02 -0700193
194endif
bohu52e0bf32015-06-01 17:25:11 -0700195endif
Raphael Mollfa090e22014-08-21 15:15:02 -0700196
Raphael48023782011-02-23 16:46:42 -0800197# -----------------------------------------------------------------
198# Rules for the SDK Repository XML
Raphael2ff496b2011-02-15 16:08:36 -0800199
Raphael Moll26bcf6a2014-06-03 10:44:56 -0700200SDK_REPO_XML := $(MAIN_SDK_DIR)/repository.xml
201SDK_EXTRAS_XML := $(MAIN_SDK_DIR)/repo-extras.xml
202SDK_SYSIMG_XML := $(MAIN_SDK_DIR)/repo-sys-img.xml
Raphael48023782011-02-23 16:46:42 -0800203
204ifneq ($(SDK_REPO_XML_ARGS),)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700205$(eval $(call mk-sdk-repo-xml,$(SDK_REPO_XML),$(SDK_REPO_XSD),$(SDK_REPO_DEPS),$(SDK_REPO_XML_ARGS)))
Raphael48023782011-02-23 16:46:42 -0800206else
Dan Willemsenf0407b32018-10-10 12:51:43 -0700207SDK_REPO_XML :=
Raphael48023782011-02-23 16:46:42 -0800208endif
209
Raphael Moll9516dc52012-02-27 15:18:29 -0800210
211ifneq ($(SDK_EXTRAS_XML_ARGS),)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700212$(eval $(call mk-sdk-repo-xml,$(SDK_EXTRAS_XML),$(SDK_ADDON_XSD),$(SDK_EXTRAS_DEPS),$(SDK_EXTRAS_XML_ARGS)))
Raphael Moll9516dc52012-02-27 15:18:29 -0800213else
Dan Willemsenf0407b32018-10-10 12:51:43 -0700214SDK_EXTRAS_XML :=
Raphael Moll9516dc52012-02-27 15:18:29 -0800215endif
216
Raphael Mollea40d2f2014-04-24 19:13:47 -0700217
218ifneq ($(SDK_SYSIMG_XML_ARGS),)
Dan Willemsenf0407b32018-10-10 12:51:43 -0700219$(eval $(call mk-sdk-repo-xml,$(SDK_SYSIMG_XML),$(SDK_SYSIMG_XSD),$(SDK_SYSIMG_DEPS),$(SDK_SYSIMG_XML_ARGS)))
Raphael Mollea40d2f2014-04-24 19:13:47 -0700220else
Dan Willemsenf0407b32018-10-10 12:51:43 -0700221SDK_SYSIMG_XML :=
Raphael Mollea40d2f2014-04-24 19:13:47 -0700222endif
223
Raphael48023782011-02-23 16:46:42 -0800224# -----------------------------------------------------------------
225
Raphael Mollea40d2f2014-04-24 19:13:47 -0700226sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
Raphael2ff496b2011-02-15 16:08:36 -0800227
Dan Willemsenf0407b32018-10-10 12:51:43 -0700228SDK_REPO_DEPS :=
229SDK_REPO_XML :=
230SDK_REPO_XML_ARGS :=
231SDK_EXTRAS_DEPS :=
232SDK_EXTRAS_XML :=
233SDK_EXTRAS_XML_ARGS :=
234SDK_SYSIMG_DEPS :=
235SDK_SYSIMG_XML :=
236SDK_SYSIMG_XML_ARGS :=
237
238mk-sdk-repo-pkg-1 :=
239mk-sdk-repo-pkg-2 :=
Dan Willemsenf0407b32018-10-10 12:51:43 -0700240mk-sdk-repo-sources :=
241mk-sdk-repo-xml :=
242sdk-repo-pkg-zip :=