SDK: generate repo in xsd v6. DO NOT MERGE.

Requires change Ib6f5b03c and change I6ba33a96.

Change-Id: Ib42676359289e731d045c4a1e26c85fe5868d633
This commit is contained in:
Raphael Moll
2012-03-30 14:18:12 -07:00
parent 4947ffb99b
commit 2edb02ab24
3 changed files with 155 additions and 74 deletions

View File

@@ -12,6 +12,10 @@ OSES="linux macosx windows any linux-x86 darwin"
TMP_DIR=$(mktemp -d -t sdkrepo.tmp.XXXXXXXX)
trap "rm -rf $TMP_DIR" EXIT
function debug() {
echo "DEBUG: " $@ > /dev/stderr
}
function error() {
echo "*** ERROR: " $@
usage
@@ -21,6 +25,7 @@ function usage() {
cat <<EOFU
Usage: $0 output.xml xml-schema [type [os zip[:dest]]*...]*
where:
- schema is one of 'repository' or 'addon'
- type is one of ${TYPES// /, } (or their plural).
- os is one of ${OSES// /, }.
There can be more than one zip for the same type
@@ -40,15 +45,20 @@ OUT="$1"
[[ -z "$OUT" ]] && error "Missing output.xml name."
shift
# Get the schema type. Must be either "repository" or "addon".
SCHEMA="$1"
[[ ! -f "$SCHEMA" ]] && error "Invalid XML schema name: $SCHEMA."
shift
# Get XML:NS for SDK from the schema
# This will be something like "http://schemas.android.com/sdk/android/addon/3"
XMLNS=$(sed -n '/xmlns:sdk="/s/.*"\(.*\)".*/\1/p' "$SCHEMA")
[[ -z "$XMLNS" ]] && error "Failed to find xmlns:sdk in $SCHEMA."
echo "## Using xmlns:sdk=$XMLNS"
# Extract the schema version number from the XMLNS, e.g. it would extract "3"
VERSION="${XMLNS##*/}"
# Get the root element from the schema. This is the first element
# which name starts with "sdk-" (e.g. sdk-repository, sdk-addon)
ROOT=$(sed -n -e '/xsd:element.*name="sdk-/s/.*name="\(sdk-[^"]*\)".*/\1/p' "$SCHEMA")
@@ -80,30 +90,48 @@ function check_enum() {
# Parse all archives.
ATTRS=(
# for repository packages
Pkg.Revision revision
Pkg.Desc description
Platform.Version version
AndroidVersion.ApiLevel api-level
AndroidVersion.CodeName codename
Platform.IncludedAbi included-abi
Platform.MinToolsRev min-tools-rev
Platform.MinPlatformToolsRev min-platform-tools-rev
Extra.Vendor vendor
Extra.Path path
Extra.OldPaths old-paths
Extra.MinApiLevel min-api-level
Sample.MinApiLevel min-api-level
SystemImage.Abi abi
Layoutlib.Api layoutlib/api
Layoutlib.Revision layoutlib/revision
# for addon packages
vendor vendor
name name
description description
api api-level
version revision
revision revision
# Columns:
# --------------------------+------------------------+----------------------
# Name read from | XML element written | Min-XSD version
# source.properties | to repository.xml | where XML can be used
# --------------------------+------------------------+----------------------
# from source.properties for repository.xml packages
Pkg.Revision revision 1
Pkg.Desc description 1
Platform.Version version 1
AndroidVersion.ApiLevel api-level 1
AndroidVersion.CodeName codename 1
Platform.IncludedAbi included-abi 5
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
# (note that vendor is mapped to different XML elements based on the XSD version)
Extra.VendorDisplay vendor-display 4
Extra.VendorId vendor-id 4
Extra.Vendor vendor-id 4
Extra.Vendor vendor 1
Extra.NameDisplay name-display 4
Extra.Path path 1
Extra.OldPaths old-paths 3
Extra.MinApiLevel min-api-level 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
vendor-display vendor-display 4
vendor vendor-display 4
vendor vendor 1
name-id name-id 4
name-display name-display 4
name name-display 4
name name 1
description description 1
api api-level 1
version revision 1
revision revision 1
)
function parse_attributes() {
@@ -111,13 +139,31 @@ function parse_attributes() {
shift
local RESULT=""
local VALUE
local REV
local USED
# $1 here is the ATTRS list above.
while [[ "$1" ]]; do
# Check the version in which the attribute was introduced and
# ignore things which are too *new* for this schema. This lets
# us generate old schemas for backward compatibility purposes.
SRC=$1
DST=$2
REV=$3
if [[ $VERSION -ge $REV ]]; then
# Parse the property, if present. Any space is replaced by @
VALUE=$( grep "^$1=" "$PROPS" | cut -d = -f 2 | tr ' ' '@' | tr -d '\r' )
VALUE=$( grep "^$SRC=" "$PROPS" | cut -d = -f 2 | tr ' ' '@' | tr -d '\r' )
if [[ -n "$VALUE" ]]; then
RESULT="$RESULT $2 $VALUE"
# In case an XML element would be mapped multiple times,
# only use its first definition.
if [[ "${USED/$DST/}" == "$USED" ]]; then
USED="$USED $DST"
RESULT="$RESULT $DST $VALUE"
fi
fi
fi
shift
shift
shift
done
@@ -129,20 +175,24 @@ function output_attributes() {
local OUT="$1"
shift
local KEY VALUE
local NODE LAST_NODE
local NODE LAST_NODE EXTRA_SPACE
while [[ "$1" ]]; do
KEY="$1"
VALUE="${2//@/ }"
NODE="${KEY%%/*}"
KEY="${KEY##*/}"
[[ "$NODE" == "$KEY" ]] && NODE=""
if [[ "$NODE" == "$KEY" ]]; then
NODE=""
EXTRA_SPACE=""
fi
if [[ "$NODE" != "$LAST_NODE" ]]; then
EXTRA_SPACE=" "
[[ "$LAST_NODE" ]] && echo " </sdk:$LAST_NODE>" >> "$OUT"
LAST_NODE="$NODE"
[[ "$NODE" ]] && echo " <sdk:$NODE>" >> "$OUT"
fi
echo " <sdk:$KEY>$VALUE</sdk:$KEY>" >> "$OUT"
echo "$EXTRA_SPACE <sdk:$KEY>$VALUE</sdk:$KEY>" >> "$OUT"
shift
shift
done

View File

@@ -4,6 +4,8 @@
SDK_REPO_DEPS :=
SDK_REPO_XML_ARGS :=
SDK_EXTRAS_DEPS :=
SDK_EXTRAS_XML_ARGS :=
# Define the name of a package zip file to generate
# $1=OS (e.g. linux-x86, windows, etc)
@@ -99,6 +101,40 @@ SDK_REPO_XML_ARGS += $(3) $(1) \
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
endef
# -----------------------------------------------------------------
# Rules for main host sdk
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 :=
SDK_EXTRAS_DEPS += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),support)
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),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_REPO_DEPS += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
$(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
# -----------------------------------------------------------------
# Rules for win_sdk
@@ -115,30 +151,19 @@ SDK_REPO_DEPS += \
endif
# -----------------------------------------------------------------
# Rules for main host sdk
# Pickup the most recent xml schema for repository and add-on
ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
SDK_REPO_XSD := \
$(lastword \
$(wildcard \
$(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
))
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),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-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 += \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),tools) \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools) \
$(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),support) \
$(call sdk-repo-pkg-zip,$(HOST_OS),$(MAIN_SDK_ZIP),sources)
endif
SDK_ADDON_XSD := \
$(lastword \
$(wildcard \
$(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
))
# -----------------------------------------------------------------
# Rules for sdk addon
@@ -157,12 +182,6 @@ $(call dist-for-goals, sdk_repo, $(RENAMED_ADDON_ZIP))
SDK_ADDON_XML := $(dir $(ADDON_SDK_ZIP))/addon.xml
SDK_ADDON_XSD := \
$(lastword \
$(wildcard \
$(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
))
$(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
@@ -175,16 +194,10 @@ endif
# Rules for the SDK Repository XML
SDK_REPO_XML := $(HOST_OUT)/sdk/repository.xml
SDK_EXTRAS_XML := $(HOST_OUT)/sdk/repo-extras.xml
ifneq ($(SDK_REPO_XML_ARGS),)
# Pickup the most recent xml schema
SDK_REPO_XSD := \
$(lastword \
$(wildcard \
$(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
))
$(SDK_REPO_XML): $(SDK_REPO_DEPS)
$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
@@ -197,8 +210,23 @@ $(SDK_REPO_XML): ;
endif
ifneq ($(SDK_EXTRAS_XML_ARGS),)
$(SDK_EXTRAS_XML): $(SDK_EXTRAS_DEPS)
$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(SDK_EXTRAS_XML) $(SDK_ADDON_XSD) $(SDK_EXTRAS_XML_ARGS)
$(call dist-for-goals, sdk_repo, $(SDK_EXTRAS_XML))
else
$(SDK_EXTRAS_XML): ;
endif
# -----------------------------------------------------------------
sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML)
sdk_repo: $(SDK_REPO_DEPS) $(SDK_REPO_XML) $(SDK_EXTRAS_XML)
@echo "Packing of SDK repository done"

View File

@@ -1,6 +1,9 @@
Pkg.UserSrc=false
Pkg.Revision=7
Extra.Vendor=android
Extra.VendorId=android
Extra.VendorDisplay=Android
Extra.NameDisplay=Android Support Library
Extra.Path=support
Extra.OldPaths=compatibility