am 8aa49aef: am f9f829e5: Merge "SDK: support generating repository XML with latest XSD."

* commit '8aa49aef8adb24a1b977d89b60a48a781e4e6674':
  SDK: support generating repository XML with latest XSD.
This commit is contained in:
Raphael Moll
2014-05-16 20:12:42 +00:00
committed by Android Git Automerger
7 changed files with 143 additions and 61 deletions

View File

@@ -45,7 +45,7 @@ OUT="$1"
[[ -z "$OUT" ]] && error "Missing output.xml name."
shift
# Get the schema type. Must be either "repository" or "addon".
# Get the schema filename. E.g. ".../.../sdk-repository-10.xsd". Can be relative or absolute.
SCHEMA="$1"
[[ ! -f "$SCHEMA" ]] && error "Invalid XML schema name: $SCHEMA."
shift
@@ -106,7 +106,6 @@ ATTRS=(
Platform.MinToolsRev min-tools-rev 1
Platform.MinPlatformToolsRev min-platform-tools-rev 3
Sample.MinApiLevel min-api-level 2
SystemImage.Abi abi 5
Layoutlib.Api layoutlib/api 4
Layoutlib.Revision layoutlib/revision 4
# from source.properties for addon.xml packages
@@ -119,6 +118,10 @@ ATTRS=(
Extra.Path path 1
Extra.OldPaths old-paths 3
Extra.MinApiLevel min-api-level 2
# for system-image
SystemImage.Abi abi r:3,s:1
SystemImage.TagId tag-id r:9,s:2
SystemImage.TagDisplay tag-display r:9,s:2
# from addon manifest.ini for addon.xml packages
# (note that vendor/name are mapped to different XML elements based on the XSD version)
vendor-id vendor-id 4
@@ -135,6 +138,23 @@ ATTRS=(
revision revision 1
)
# Start with repo-10, addon-7 and sys-img-3, we don't encode the os/arch
# in the <archive> attributes anymore. Instead we have separate elements.
function uses_new_host_os() {
if [[ "$ROOT" == "sdk-repository" && "$XSD_VERSION" -ge "10" ]]; then return 0; fi
if [[ "$ROOT" == "sdk-addon" && "$XSD_VERSION" -ge "7" ]]; then return 0; fi
if [[ "$ROOT" == "sdk-sys-img" && "$XSD_VERSION" -ge "3" ]]; then return 0; fi
return 1
}
ATTRS_ARCHIVE=(
Archive.HostOs host-os 1
Archive.HostBits host-bits 1
Archive.JvmBits jvm-bits 1
Archive.MinJvmVers min-jvm-version 1
)
# Starting with XSD repo-7 and addon-5, some revision elements are no longer just
# integers. Instead they are in major.minor.micro.preview format. This defines
@@ -224,6 +244,13 @@ function parse_attributes() {
local VALUE
local REV
local USED
local S
# Get the first letter of the schema name (e.g. sdk-repo => 'r')
# This can be r, a or s and would match the min-XSD per-schema value
# in the ATTRS list.
S=$(basename "$SCHEMA")
S="${S:4:1}"
# $1 here is the ATTRS list above.
while [[ "$1" ]]; do
@@ -234,6 +261,12 @@ function parse_attributes() {
DST=$2
REV=$3
if [[ $REV =~ ([ras0-9:,]+,)?$S:([0-9])(,.*)? ]]; then
# Per-schema type min-XSD revision. Format is "[<type>:rev],*]
# where type is one of r, a or s matching $S above.
REV="${BASH_REMATCH[2]}"
fi
if [[ $XSD_VERSION -ge $REV ]]; then
# Parse the property, if present. Any space is replaced by @
VALUE=$( grep "^$SRC=" "$PROPS" | cut -d = -f 2 | tr ' ' '@' | tr -d '\r' )
@@ -390,13 +423,28 @@ while [[ -n "$1" ]]; do
fi
SHA1=$( sha1sum "$SRC" | cut -d " " -f 1 )
if uses_new_host_os ; then
USE_HOST_OS=1
else
OLD_OS_ATTR=" os='$OS'"
fi
cat >> "$OUT" <<EOFA
<sdk:archive os='$OS' arch='any'>
<sdk:archive$OLD_OS_ATTR>
<sdk:size>$SIZE</sdk:size>
<sdk:checksum type='sha1'>$SHA1</sdk:checksum>
<sdk:url>$DST</sdk:url>
</sdk:archive>
EOFA
if [[ $USE_HOST_OS ]]; then
# parse the Archive.Host/Jvm info from the source.props if present
MAP=$(parse_attributes "$PROPS" ${ATTRS_ARCHIVE[@]})
# Always generate host-os if not present
if [[ "${MAP/ host-os /}" == "$MAP" ]]; then
MAP="$MAP host-os $OS"
fi
output_attributes "archive" "$OUT" $MAP
fi
echo " </sdk:archive>" >> "$OUT"
# Skip to next arch/zip entry.
# If not a valid OS, close the archives/package nodes.

View File

@@ -21,20 +21,21 @@ endef
# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/tools
# this generates an sdk-repo-linux-tools that contains tools/*
#
# $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. tools, docs, etc.)
# $1=variable where to accumulate args for mk_sdk_repo_xml.
# $2=OS (e.g. linux-x86, windows, etc)
# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
# $4=package to create (e.g. tools, docs, etc.)
#
# The rule depends on the SDK zip file, which is defined by $2.
#
define mk-sdk-repo-pkg-1
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
@echo "Building SDK repository package $(3) from $(notdir $(2))"
$(hide) cd $(basename $(2)) && \
zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3))) $(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)))
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
@echo "Building SDK repository package $(4) from $(notdir $(3))"
$(hide) cd $(basename $(3)) && \
zip -9rq ../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) $(4)/*
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
$(1) += $(4) $(2) \
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
endef
# Defines the rule to build an SDK repository package when the
@@ -42,20 +43,21 @@ endef
# E.g. given a folder out/host/linux.../sdk/android-eng-sdk/samples/android-N
# this generates an sdk-repo-linux-samples that contains android-N/*
#
# $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. platforms, samples, etc.)
# $1=variable where to accumulate args for mk_sdk_repo_xml.
# $2=OS (e.g. linux-x86, windows, etc)
# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
# $4=package to create (e.g. platforms, samples, etc.)
#
# The rule depends on the SDK zip file, which is defined by $2.
#
define mk-sdk-repo-pkg-2
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2)
@echo "Building SDK repository package $(3) from $(notdir $(2))"
$(hide) cd $(basename $(2))/$(3) && \
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)))
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
@echo "Building SDK repository package $(4) from $(notdir $(3))"
$(hide) cd $(basename $(3))/$(4) && \
zip -9rq ../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
$(1) += $(4) $(2) \
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
endef
# Defines the rule to build an SDK repository package when the
@@ -65,40 +67,42 @@ endef
# 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).
# $1=variable where to accumulate args for mk_sdk_repo_xml.
# $2=OS (e.g. linux-x86, windows, etc)
# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
# $4=package to create (e.g. system-images, support, etc.)
# $5=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)))
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3)
@echo "Building SDK repository package $(4) from $(notdir $(3))"
$(hide) cd $(basename $(3))/$(5) && \
zip -9rq ../../../$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4))) *
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
$(1) += $(4) $(2) \
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
endef
# Defines the rule to build an SDK sources package.
#
# $1=OS (e.g. linux-x86, windows, etc)
# $2=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
# $3=package to create, must be "sources"
# $1=variable where to accumulate args for mk_sdk_repo_xml.
# $2=OS (e.g. linux-x86, windows, etc)
# $3=sdk zip (e.g. out/host/linux.../android-eng-sdk.zip)
# $4=package to create, must be "sources"
#
define mk-sdk-repo-sources
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(HOST_OUT)/development/sdk/source_source.properties
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)): $(3) $(HOST_OUT)/development/sdk/source_source.properties
@echo "Building SDK sources package"
$(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py --exec-zip \
$(HOST_OUT)/development/sdk/source_source.properties \
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)) \
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)) \
$(TOPDIR).
$(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)))
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
$(1) += $(4) $(2) \
$(call sdk-repo-pkg-zip,$(2),$(3),$(4)):$(notdir $(call sdk-repo-pkg-zip,$(2),$(3),$(4)))
endef
# -----------------------------------------------------------------
@@ -106,23 +110,25 @@ endef
ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
# Note that extras are now located in addon.xml, not in repository.xml,
# so we capture all extras first.
$(eval $(call mk-sdk-repo-pkg-3,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
SDK_EXTRAS_XML_ARGS := $(SDK_REPO_XML_ARGS)
SDK_REPO_XML_ARGS :=
# Extras are now located in addon.xml, not in repository.xml.
$(eval $(call mk-sdk-repo-pkg-3,SDK_EXTRAS_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),support,extras/android))
SDK_EXTRAS_DEPS += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support)
# Similarly capture all sys-img.xml that are now split out of repository.xml
$(eval $(call mk-sdk-repo-pkg-3,SDK_SYSIMG_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools))
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
$(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-3,$(HOST_OS),$(MAIN_SDK_ZIP),system-images,system-images/*))
$(eval $(call mk-sdk-repo-sources,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
SDK_SYSIMG_DEPS += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),system-images) \
# All these go in the main repository.xml
$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools))
$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools))
$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),docs))
$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),platforms))
$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),samples))
$(eval $(call mk-sdk-repo-sources,SDK_REPO_XML_ARGS,$(HOST_OS),$(MAIN_SDK_ZIP),sources))
SDK_REPO_DEPS += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),build-tools) \
@@ -130,7 +136,6 @@ SDK_REPO_DEPS += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),docs) \
$(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),sources)
endif
@@ -141,8 +146,8 @@ endif
ifneq ($(WIN_SDK_ZIP),)
# docs, platforms and samples have nothing OS-dependent right now.
$(eval $(call mk-sdk-repo-pkg-2,windows,$(WIN_SDK_ZIP),build-tools))
$(eval $(call mk-sdk-repo-pkg-1,windows,$(WIN_SDK_ZIP),platform-tools))
$(eval $(call mk-sdk-repo-pkg-2,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),build-tools))
$(eval $(call mk-sdk-repo-pkg-1,SDK_REPO_XML_ARGS,windows,$(WIN_SDK_ZIP),platform-tools))
SDK_REPO_DEPS += \
$(call sdk-repo-pkg-zip,windows,$(WIN_SDK_ZIP),build-tools) \
@@ -165,6 +170,12 @@ SDK_ADDON_XSD := \
$(TOPDIR)prebuilts/devtools/repository/sdk-addon-*.xsd \
))
SDK_SYSIMG_XSD := \
$(lastword \
$(wildcard \
$(TOPDIR)prebuilts/devtools/repository/sdk-sys-img-*.xsd \
))
# -----------------------------------------------------------------
# Rules for sdk addon
@@ -196,6 +207,7 @@ endif
SDK_REPO_XML := $(HOST_OUT)/sdk/repository.xml
SDK_EXTRAS_XML := $(HOST_OUT)/sdk/repo-extras.xml
SDK_SYSIMG_XML := $(HOST_OUT)/sdk/repo-sys-img.xml
ifneq ($(SDK_REPO_XML_ARGS),)
@@ -226,8 +238,23 @@ $(SDK_EXTRAS_XML): ;
endif
ifneq ($(SDK_SYSIMG_XML_ARGS),)
$(SDK_SYSIMG_XML): $(SDK_SYSIMG_DEPS)
$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(SDK_SYSIMG_XML) $(SDK_SYSIMG_XSD) $(SDK_SYSIMG_XML_ARGS)
$(call dist-for-goals, sdk_repo, $(SDK_SYSIMG_XML))
else
$(SDK_SYSIMG_XML): ;
endif
# -----------------------------------------------------------------
sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML)
sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML) $(SDK_SYSIMG_XML)
@echo "Packing of SDK repository done"

View File

@@ -5,3 +5,5 @@ AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=armeabi-v7a
SystemImage.GpuSupport=true
SystemImage.TagId=default

View File

@@ -5,3 +5,5 @@ AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=armeabi
SystemImage.GpuSupport=true
SystemImage.TagId=default

View File

@@ -4,3 +4,5 @@ Pkg.Revision=1
AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=mips
SystemImage.TagId=default

View File

@@ -5,3 +5,5 @@ AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
SystemImage.Abi=x86
SystemImage.GpuSupport=true
SystemImage.TagId=default

View File

@@ -1,4 +1,3 @@
Pkg.Revision=9
Archive.Os=WINDOWS
Archive.Arch=ANY
Archive.HostOs=WINDOWS
Extra.Path=usb_driver