Merge "Consolidate sdk version handling"

This commit is contained in:
Colin Cross 2019-02-08 02:30:16 +00:00 committed by Gerrit Code Review
commit 2b526bf7f3
6 changed files with 34 additions and 61 deletions

View File

@ -46,19 +46,8 @@ else
fixed_android_manifest := $(full_android_manifest)
endif
ifdef LOCAL_MIN_SDK_VERSION
$(fixed_android_manifest): PRIVATE_MIN_SDK_VERSION := $(LOCAL_MIN_SDK_VERSION)
else ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
$(fixed_android_manifest): PRIVATE_MIN_SDK_VERSION := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
$(fixed_android_manifest): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
endif
ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
$(fixed_android_manifest): PRIVATE_TARGET_SDK_VERSION := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
$(fixed_android_manifest): PRIVATE_TARGET_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
endif
$(fixed_android_manifest): PRIVATE_MIN_SDK_VERSION := $(call module-min-sdk-version)
$(fixed_android_manifest): PRIVATE_TARGET_SDK_VERSION := $(call module-target-sdk-version)
my_exported_sdk_libs_file := $(call local-intermediates-dir,COMMON)/exported-sdk-libs
$(fixed_android_manifest): PRIVATE_EXPORTED_SDK_LIBS_FILE := $(my_exported_sdk_libs_file)

View File

@ -2195,6 +2195,30 @@ define codename-or-sdk-to-sdk
$(if $(filter $(1),$(PLATFORM_VERSION_CODENAME)),10000,$(1))
endef
# Uses LOCAL_SDK_VERSION and PLATFORM_SDK_VERSION to determine a compileSdkVersion
# in the form of a number or a codename (28 or P)
define module-sdk-version
$(strip \
$(if $(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)), \
$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)), \
$(PLATFORM_SDK_VERSION)))
endef
# Uses LOCAL_SDK_VERSION and DEFAULT_APP_TARGET_SDK to determine
# a targetSdkVersion in the form of a number or a codename (28 or P).
define module-target-sdk-version
$(strip \
$(if $(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)), \
$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)), \
$(DEFAULT_APP_TARGET_SDK)))
endef
# Uses LOCAL_MIN_SDK_VERSION, LOCAL_SDK_VERSION and DEFAULT_APP_TARGET_SDK to determine
# a minSdkVersion in the form of a number or a codename (28 or P).
define module-min-sdk-version
$(if $(LOCAL_MIN_SDK_VERSION),$(LOCAL_MIN_SDK_VERSION),$(call module-target-sdk-version))
endef
define transform-classes.jar-to-dex
@echo "target Dex: $(PRIVATE_MODULE)"

View File

@ -18,11 +18,7 @@ $(built_dpi_apk): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
$(built_dpi_apk): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
$(built_dpi_apk): PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
$(built_dpi_apk): PRIVATE_RESOURCE_LIST := $(all_res_assets)
ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
endif
$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call module-target-sdk-version)
$(built_dpi_apk): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
$(built_dpi_apk): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_INSTRUMENTATION_FOR)
$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)

View File

@ -48,15 +48,7 @@ ifneq ($(FORCE_AAPT2),false)
ifeq (,$(wildcard $(LOCAL_PATH)/AndroidManifest.xml))
# work around missing manifests by creating a default one
LOCAL_FULL_MANIFEST_FILE := $(call local-intermediates-dir,COMMON)/DefaultManifest.xml
ifdef LOCAL_MIN_SDK_VERSION
my_manifest_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
else ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
my_manifest_min_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
my_manifest_min_sdk_version := $(DEFAULT_APP_TARGET_SDK)
endif
$(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE),$(my_manifest_min_sdk_version))
my_manifest_min_sdk_version :=
$(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE),$(call module-min-sdk-version))
endif
endif
endif

View File

@ -183,23 +183,9 @@ $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK)
my_sdk_version := $(PLATFORM_SDK_VERSION)
endif
ifdef LOCAL_MIN_SDK_VERSION
my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
else
my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk))
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call module-target-sdk-version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(call module-sdk-version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(call codename-or-sdk-to-sdk,$(call module-min-sdk-version))
USE_CORE_LIB_BOOTCLASSPATH :=

View File

@ -538,20 +538,6 @@ $(LOCAL_MODULE)-findbugs : $(findbugs_html)
endif # full_classes_jar is defined
ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
else
my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK)
my_sdk_version := $(PLATFORM_SDK_VERSION)
endif
ifdef LOCAL_MIN_SDK_VERSION
my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
else
my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk))
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call module-target-sdk-version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(call module-sdk-version)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(call codename-or-sdk-to-sdk,$(call module-min-sdk-version))