SDK: source.properties templates.
This adds support for "templates" source.properties files that can
inherit the platform version/codename/api level from the build.
The purpose is for a given build to always generate SDK files that
match the platform generated in the same branch.
Change-Id: Id623bbef45a04d953da8eade7e8c34c77709f9c3
diff --git a/build/Android.mk b/build/Android.mk
index e4eeb0a..1cb0653 100644
--- a/build/Android.mk
+++ b/build/Android.mk
@@ -1,3 +1,27 @@
+# ===== SDK source.property files =====
+
+# Add all files to be generated from the source.prop templates to the SDK pre-requisites
+ALL_SDK_FILES += $(patsubst \
+ $(TOPDIR)development/sdk/%_source.prop_template, \
+ $(HOST_OUT)/development/sdk/%_source.properties, \
+ $(wildcard $(TOPDIR)development/sdk/*_source.prop_template))
+
+# Rule to convert a source.prop template into the desired source.property
+# Rewritten variables:
+# - ${PLATFORM_VERSION} e.g. "1.0"
+# - ${PLATFORM_SDK_VERSION} e.g. "3", aka the API level
+# - ${PLATFORM_VERSION_CODENAME} e.g. "REL" (transformed into "") or "Cupcake"
+$(HOST_OUT)/development/sdk/%_source.properties : $(TOPDIR)development/sdk/%_source.prop_template
+ @echo Generate $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) sed -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
+ -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
+ -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
+ $< > $@
+
+
+# ===== Android Support/Compatibility Library =====
+
LOCAL_PATH := $(call my-dir)
# The source files for this library are _all_ generated, something we don't do
diff --git a/build/sdk-android-armeabi-v7a.atree b/build/sdk-android-armeabi-v7a.atree
index 8867bf7..e586945 100644
--- a/build/sdk-android-armeabi-v7a.atree
+++ b/build/sdk-android-armeabi-v7a.atree
@@ -18,4 +18,4 @@
prebuilt/android-${TARGET_ARCH}/kernel/kernel-qemu-armv7 system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
# version files for the SDK updater, from development.git
-development/sdk/images_armeabi-v7a_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
+${HOST_OUT}/development/sdk/images_armeabi-v7a_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk-android-armeabi.atree b/build/sdk-android-armeabi.atree
index a31eca6..15f1f58 100644
--- a/build/sdk-android-armeabi.atree
+++ b/build/sdk-android-armeabi.atree
@@ -17,4 +17,4 @@
prebuilt/android-${TARGET_ARCH}/kernel/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
# version files for the SDK updater, from development.git
-development/sdk/images_armeabi_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
+${HOST_OUT}/development/sdk/images_armeabi_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk-android-x86.atree b/build/sdk-android-x86.atree
index 748478a..a309149 100644
--- a/build/sdk-android-x86.atree
+++ b/build/sdk-android-x86.atree
@@ -17,4 +17,4 @@
prebuilt/android-${TARGET_ARCH}/kernel/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
# version files for the SDK updater, from development.git
-development/sdk/images_x86_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
+${HOST_OUT}/development/sdk/images_x86_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk.atree b/build/sdk.atree
index 16c5184..afbffd8 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -61,7 +61,7 @@
##############################################################################
# version files for the SDK updater, from development.git
-development/sdk/platform_source.properties platforms/${PLATFORM_NAME}/source.properties
+${HOST_OUT}/development/sdk/platform_source.properties platforms/${PLATFORM_NAME}/source.properties
# copy build prop from out/.../sdk/
sdk/sdk-build.prop platforms/${PLATFORM_NAME}/build.prop
@@ -132,7 +132,7 @@
##############################################################################
# version files for the SDK updater, from sdk.git
-development/sdk/doc_source.properties docs/source.properties
+${HOST_OUT}/development/sdk/doc_source.properties docs/source.properties
# the docs
docs/offline-sdk docs
diff --git a/build/tools/sdk_repo.mk b/build/tools/sdk_repo.mk
index de48e57..a0d93de 100644
--- a/build/tools/sdk_repo.mk
+++ b/build/tools/sdk_repo.mk
@@ -88,10 +88,10 @@
# $3=package to create, must be "sources"
#
define mk-sdk-repo-sources
-$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(TOPDIR)development/sdk/source_source.properties
+$(call sdk-repo-pkg-zip,$(1),$(2),$(3)): $(2) $(HOST_OUT)/development/sdk/source_source.properties
@echo "Building SDK sources package"
$(hide) $(TOPDIR)development/build/tools/mk_sources_zip.py \
- $(TOPDIR)development/sdk/source_source.properties \
+ $(HOST_OUT)/development/sdk/source_source.properties \
$(call sdk-repo-pkg-zip,$(1),$(2),$(3)) \
$(TOPDIR).
$(call dist-for-goals, sdk_repo, $(call sdk-repo-pkg-zip,$(1),$(2),$(3)))