From 9bd5404a9d30b82ba3d2750c0cb8cae88b33f82d Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 15 May 2009 18:01:20 -0700 Subject: [PATCH] Use new aapt feature to add default version info to .apks. --- core/definitions.mk | 13 ++++++++++++- core/version_defaults.mk | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index 17ec646b5a..5631fb99f7 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1122,7 +1122,11 @@ $(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m -z \ $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \ $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ - $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) + $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ + $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ + $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ + $(addprefix --version-code , $(PLATFORM_SDK_VERSION)) \ + $(addprefix --version-name , $(PLATFORM_VERSION)) endef ifeq ($(HOST_OS),windows) @@ -1250,6 +1254,9 @@ endef # A list of dynamic and static parameters; build layers for # dynamic params that lay over the static ones. #TODO: update the manifest to point to the package file +#Note that the version numbers are given to aapt as simple default +#values; applications can override these by explicitly stating +#them in their manifest. define add-assets-to-package $(hide) $(AAPT) package -z -u $(PRIVATE_AAPT_FLAGS) \ $(addprefix -c , $(PRODUCT_AAPT_CONFIG)) \ @@ -1257,6 +1264,10 @@ $(hide) $(AAPT) package -z -u $(PRIVATE_AAPT_FLAGS) \ $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ $(addprefix -A , $(PRIVATE_ASSET_DIR)) \ $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \ + $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ + $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \ + $(addprefix --version-code , $(PLATFORM_SDK_VERSION)) \ + $(addprefix --version-name , $(PLATFORM_VERSION)) \ -F $@ endef diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 902afedab6..ca8487f49c 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -20,6 +20,8 @@ # Guarantees that the following are defined: # PLATFORM_VERSION # PLATFORM_SDK_VERSION +# PLATFORM_VERSION_CODENAME +# DEFAULT_APP_TARGET_SDK # BUILD_ID # BUILD_NUMBER # @@ -55,11 +57,24 @@ ifeq "" "$(PLATFORM_SDK_VERSION)" endif ifeq "" "$(PLATFORM_VERSION_CODENAME)" - # This is the current development code-name, if the build is not a final - # release build. If this is a final release build, it is simply "REL". + # If the build is not a final release build, then this is the current + # development code-name. If this is a final release build, it is simply "REL". PLATFORM_VERSION_CODENAME := Donut endif +ifeq "" "$(DEFAULT_APP_TARGET_SDK)" + # This is the default minSdkVersion and targetSdkVersion to use for + # all .apks created by the build system. It can be overridden by explicitly + # setting these in the .apk's AndroidManifest.xml. It is either the code + # name of the development build or, if this is a release build, the official + # SDK version of this release. + ifeq "REL" "$(PLATFORM_VERSION_CODENAME)" + DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION) + else + DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME) + endif +endif + ifeq "" "$(BUILD_ID)" # Used to signify special builds. E.g., branches and/or releases, # like "M5-RC7". Can be an arbitrary string, but must be a single