am 8d2f79ba: Merge "SDK: generate repo using latest schemas when available."
* commit '8d2f79ba939e0394cf18489503a6f2a3ebcce8f6': SDK: generate repo using latest schemas when available.
This commit is contained in:
committed by
Android Git Automerger
commit
79977b408b
@@ -21,6 +21,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 +41,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 +86,35 @@ function check_enum() {
|
||||
# Parse all archives.
|
||||
|
||||
ATTRS=(
|
||||
# Columns:
|
||||
# --------------------------+------------------------+----------------------
|
||||
# Name read from | XML element written | Min-XSD version
|
||||
# source.properties | to repository.xml | where XML can be used
|
||||
# --------------------------+------------------------+----------------------
|
||||
# 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
|
||||
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
|
||||
Extra.Vendor vendor 1
|
||||
Extra.Path path 1
|
||||
Extra.OldPaths old-paths 3
|
||||
Extra.MinApiLevel min-api-level 2
|
||||
Sample.MinApiLevel min-api-level 2
|
||||
SystemImage.Abi abi 5
|
||||
Layoutlib.Api layoutlib/api 4
|
||||
Layoutlib.Revision layoutlib/revision 4
|
||||
# for addon packages
|
||||
vendor vendor
|
||||
name name
|
||||
description description
|
||||
api api-level
|
||||
version revision
|
||||
revision revision
|
||||
vendor vendor 1
|
||||
name name 1
|
||||
description description 1
|
||||
api api-level 1
|
||||
version revision 1
|
||||
revision revision 1
|
||||
)
|
||||
|
||||
function parse_attributes() {
|
||||
@@ -111,15 +122,33 @@ function parse_attributes() {
|
||||
shift
|
||||
local RESULT=""
|
||||
local VALUE
|
||||
local REV
|
||||
local USED
|
||||
|
||||
# $1 here is the ATTRS list above.
|
||||
while [[ "$1" ]]; do
|
||||
# Parse the property, if present. Any space is replaced by @
|
||||
VALUE=$( grep "^$1=" "$PROPS" | cut -d = -f 2 | tr ' ' '@' | tr -d '\r' )
|
||||
if [[ -n "$VALUE" ]]; then
|
||||
RESULT="$RESULT $2 $VALUE"
|
||||
# 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 "^$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
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
done
|
||||
|
||||
echo "$RESULT"
|
||||
@@ -129,20 +158,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" != "$LAST_NODE" ]]; then
|
||||
[[ "$LAST_NODE" ]] && echo " </sdk:$LAST_NODE>" >> "$OUT"
|
||||
LAST_NODE="$NODE"
|
||||
[[ "$NODE" ]] && echo " <sdk:$NODE>" >> "$OUT"
|
||||
if [[ "$NODE" == "$KEY" ]]; then
|
||||
NODE=""
|
||||
EXTRA_SPACE=""
|
||||
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
|
||||
done
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
.PHONY: sdk_repo
|
||||
|
||||
SDK_REPO_DEPS :=
|
||||
SDK_REPO_XML_ARGS :=
|
||||
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)
|
||||
@@ -174,17 +193,11 @@ endif
|
||||
# -----------------------------------------------------------------
|
||||
# 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),)
|
||||
|
||||
# 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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user