SDK: generate support library package on build server.
Also fix packaging of system image (it had an extra root
directory in it, e.g. it was packaging android-4/armeabi-v7a/
instead of just armeabu-v7a/)
Change-Id: I0254b2680168d25103222f8871b2af37a7406b58
diff --git a/build/tools/mk_sdk_repo_xml.sh b/build/tools/mk_sdk_repo_xml.sh
index e977a03..a97ecaf 100755
--- a/build/tools/mk_sdk_repo_xml.sh
+++ b/build/tools/mk_sdk_repo_xml.sh
@@ -6,7 +6,7 @@
PROG_DIR=$(dirname $0)
-TYPES="tool platform-tool platform sample doc add-on system-image source"
+TYPES="tool platform-tool platform sample doc add-on system-image source support"
OSES="linux macosx windows any linux-x86 darwin"
TMP_DIR=$(mktemp -d -t sdkrepo.tmp.XXXXXXXX)
@@ -156,6 +156,10 @@
[[ -z $TYPE ]] && error "Unknown archive type '$1'."
shift
+ ELEMENT="$TYPE"
+ # The element name is different for extras:
+ [[ "$TYPE" == "support" ]] && ELEMENT="extra"
+
MAP=""
FIRST="1"
LIBS_XML=""
@@ -230,7 +234,7 @@
MAP=$(parse_attributes "$PROPS" ${ATTRS[@]})
# Time to generate the XML for the package
- echo " <sdk:${TYPE}>" >> "$OUT"
+ echo " <sdk:${ELEMENT}>" >> "$OUT"
output_attributes "$OUT" $MAP
[[ -n "$LIBS_XML" ]] && echo "$LIBS_XML" >> "$OUT"
echo " <sdk:archives>" >> "$OUT"
@@ -259,7 +263,7 @@
if [[ ! "$OS" ]]; then
echo " </sdk:archives>" >> "$OUT"
- echo " </sdk:${TYPE}>" >> "$OUT"
+ echo " </sdk:${ELEMENT}>" >> "$OUT"
fi
done
diff --git a/build/tools/sdk_repo.mk b/build/tools/sdk_repo.mk
index 549b66b..de48e57 100644
--- a/build/tools/sdk_repo.mk
+++ b/build/tools/sdk_repo.mk
@@ -56,6 +56,31 @@
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
endef
+# Defines the rule to build an SDK repository package when the
+# package directory contains 3 levels from the sdk dir, for example
+# to package SDK/extra/android/support or SDK/system-images/android-N/armeabi.
+# Because we do not know the intermediary directory name, this only works
+# if each directory contains a single sub-directory (e.g. sdk/$4/*/* must be
+# unique.)
+#
+# $1=OS (e.g. linux-x86, windows, etc)
+# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
+# $3=package to create (e.g. system-images, support, etc.)
+# $4=the root of directory to package in the sdk (e.g. extra/android).
+# this must be a 2-segment path, the last one can be *.
+#
+# The rule depends on the SDK zip file, which is defined by $2.
+#
+define mk-sdk-repo-pkg-3
+$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
+ @echo "Building SDK repository package $(3) from $(notdir $(2))"
+ $(hide) cd $(basename $(2))/$(4) && \
+ zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) *
+$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
+SDK_REPO_XML_ARGS += $(3) $(1) \
+ $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
+endef
+
# Defines the rule to build an SDK sources package.
#
# $1=OS (e.g. linux-x86, windows, etc)
@@ -99,7 +124,8 @@
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
-$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),system-images))
+$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
+$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
$(eval $(call mk-sdk-repo-sources,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
SDK_REPO_DEPS += \
@@ -109,6 +135,7 @@
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platforms) \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),samples) \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
+ $(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support) \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
endif