Merge "SDK: generate repo using latest schemas when available."
This commit is contained in:
@@ -21,6 +21,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 +41,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 +86,35 @@ function check_enum() {
|
|||||||
# Parse all archives.
|
# Parse all archives.
|
||||||
|
|
||||||
ATTRS=(
|
ATTRS=(
|
||||||
|
# Columns:
|
||||||
|
# --------------------------+------------------------+----------------------
|
||||||
|
# Name read from | XML element written | Min-XSD version
|
||||||
|
# source.properties | to repository.xml | where XML can be used
|
||||||
|
# --------------------------+------------------------+----------------------
|
||||||
# for repository packages
|
# for repository packages
|
||||||
Pkg.Revision revision
|
Pkg.Revision revision 1
|
||||||
Pkg.Desc description
|
Pkg.Desc description 1
|
||||||
Platform.Version version
|
Platform.Version version 1
|
||||||
AndroidVersion.ApiLevel api-level
|
AndroidVersion.ApiLevel api-level 1
|
||||||
AndroidVersion.CodeName codename
|
AndroidVersion.CodeName codename 1
|
||||||
Platform.IncludedAbi included-abi
|
Platform.IncludedAbi included-abi 5
|
||||||
Platform.MinToolsRev min-tools-rev
|
Platform.MinToolsRev min-tools-rev 1
|
||||||
Platform.MinPlatformToolsRev min-platform-tools-rev
|
Platform.MinPlatformToolsRev min-platform-tools-rev 3
|
||||||
Extra.Vendor vendor
|
Extra.Vendor vendor 1
|
||||||
Extra.Path path
|
Extra.Path path 1
|
||||||
Extra.OldPaths old-paths
|
Extra.OldPaths old-paths 3
|
||||||
Extra.MinApiLevel min-api-level
|
Extra.MinApiLevel min-api-level 2
|
||||||
Sample.MinApiLevel min-api-level
|
Sample.MinApiLevel min-api-level 2
|
||||||
SystemImage.Abi abi
|
SystemImage.Abi abi 5
|
||||||
Layoutlib.Api layoutlib/api
|
Layoutlib.Api layoutlib/api 4
|
||||||
Layoutlib.Revision layoutlib/revision
|
Layoutlib.Revision layoutlib/revision 4
|
||||||
# for addon packages
|
# for addon packages
|
||||||
vendor vendor
|
vendor vendor 1
|
||||||
name name
|
name name 1
|
||||||
description description
|
description description 1
|
||||||
api api-level
|
api api-level 1
|
||||||
version revision
|
version revision 1
|
||||||
revision revision
|
revision revision 1
|
||||||
)
|
)
|
||||||
|
|
||||||
function parse_attributes() {
|
function parse_attributes() {
|
||||||
@@ -111,13 +122,31 @@ 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
|
||||||
|
# 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 @
|
# 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
|
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
|
||||||
|
fi
|
||||||
|
shift
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
@@ -129,20 +158,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
|
||||||
|
NODE=""
|
||||||
|
EXTRA_SPACE=""
|
||||||
|
fi
|
||||||
if [[ "$NODE" != "$LAST_NODE" ]]; then
|
if [[ "$NODE" != "$LAST_NODE" ]]; then
|
||||||
|
EXTRA_SPACE=" "
|
||||||
[[ "$LAST_NODE" ]] && echo " </sdk:$LAST_NODE>" >> "$OUT"
|
[[ "$LAST_NODE" ]] && echo " </sdk:$LAST_NODE>" >> "$OUT"
|
||||||
LAST_NODE="$NODE"
|
LAST_NODE="$NODE"
|
||||||
[[ "$NODE" ]] && echo " <sdk:$NODE>" >> "$OUT"
|
[[ "$NODE" ]] && echo " <sdk:$NODE>" >> "$OUT"
|
||||||
fi
|
fi
|
||||||
echo " <sdk:$KEY>$VALUE</sdk:$KEY>" >> "$OUT"
|
echo "$EXTRA_SPACE <sdk:$KEY>$VALUE</sdk:$KEY>" >> "$OUT"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
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)
|
||||||
@@ -175,16 +194,10 @@ 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"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Pkg.UserSrc=false
|
Pkg.UserSrc=false
|
||||||
Pkg.Revision=6
|
Pkg.Revision=6
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user