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

View File

@@ -2,8 +2,10 @@
.PHONY: sdk_repo .PHONY: sdk_repo
SDK_REPO_DEPS := SDK_REPO_DEPS :=
SDK_REPO_XML_ARGS := SDK_REPO_XML_ARGS :=
SDK_EXTRAS_DEPS :=
SDK_EXTRAS_XML_ARGS :=
# Define the name of a package zip file to generate # Define the name of a package zip file to generate
# $1=OS (e.g. linux-x86, windows, etc) # $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))) $(call sdk-repo-pkg-zip,$(1),$(2),$(3)):$(notdir $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))
endef 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 # Rules for win_sdk
@@ -115,30 +151,19 @@ SDK_REPO_DEPS += \
endif 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)) SDK_ADDON_XSD := \
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),platform-tools)) $(lastword \
$(eval $(call mk-sdk-repo-pkg-1,$(HOST_OS),$(MAIN_SDK_ZIP),docs)) $(wildcard \
$(eval $(call mk-sdk-repo-pkg-2,$(HOST_OS),$(MAIN_SDK_ZIP),platforms)) $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
$(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
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# Rules for sdk addon # 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_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) $(SDK_ADDON_XML): $(ADDON_SDK_ZIP)
$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \ $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP) $(SDK_ADDON_XML) $(SDK_ADDON_XSD) add-on $(HOST_OS) $(RENAMED_ADDON_ZIP)
@@ -174,17 +193,11 @@ endif
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# Rules for the SDK Repository XML # Rules for the SDK Repository XML
SDK_REPO_XML := $(HOST_OUT)/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),) 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) $(SDK_REPO_XML): $(SDK_REPO_DEPS)
$(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \ $(hide) $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS) $(SDK_REPO_XML) $(SDK_REPO_XSD) $(SDK_REPO_XML_ARGS)
@@ -197,8 +210,23 @@ $(SDK_REPO_XML): ;
endif 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" @echo "Packing of SDK repository done"

View File

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