From 5a44d1f069ad8cfc9afd757e662fd47ee4ed02c3 Mon Sep 17 00:00:00 2001 From: Sundong Ahn Date: Mon, 16 Oct 2017 19:20:34 +0900 Subject: [PATCH 1/2] Add LOCAL_SDK_VERSION := system_$(VER) The system_$(VER) can be set in LOCAL_SDK_VERSION, and the apk will use android_system.jar at build time. If LOCAL_SDK_VERSION is not defined and this module is installed in vendor.img, LOCAL_SDK_VERSION is set to system_current. Bug: 67724799 Test: 1. build && run on taimen 2. LOCAL_SDK_VERSION:=system_27 in ims.apk && build ims.apk && check the vsdk_v27_intermediates. Merged-In: I5b11c78b8fcd4a2f2a5e3b141527cd34dbe80018 Change-Id: I5b11c78b8fcd4a2f2a5e3b141527cd34dbe80018 (cherry picked from commit ef212cbe8d6e628bfc40e2db75522b4f1d794766) --- core/base_rules.mk | 1 + core/binary.mk | 2 +- core/config.mk | 5 +++++ core/definitions.mk | 19 +++++++++++++++++++ core/dpi_specific_apk.mk | 2 +- core/droiddoc.mk | 9 +++++++-- core/host_dalvik_java_library.mk | 4 ++-- core/java.mk | 6 +++--- core/java_common.mk | 12 ++++++++++-- core/local_vsdk.mk | 19 +++++++++++++++++++ core/package_internal.mk | 2 +- core/prebuilt_internal.mk | 2 ++ core/soong_java_prebuilt.mk | 4 ++++ core/static_java_library.mk | 2 +- 14 files changed, 76 insertions(+), 13 deletions(-) create mode 100644 core/local_vsdk.mk diff --git a/core/base_rules.mk b/core/base_rules.mk index ee3ed6c572..50436d1c58 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -86,6 +86,7 @@ $(call pretty-error,Only one of LOCAL_PROPRIETARY_MODULE[$(LOCAL_PROPRIETARY_MOD endif include $(BUILD_SYSTEM)/local_vndk.mk +include $(BUILD_SYSTEM)/local_vsdk.mk my_module_tags := $(LOCAL_MODULE_TAGS) ifeq ($(my_host_cross),true) diff --git a/core/binary.mk b/core/binary.mk index e54edbec86..0a88ca8abb 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -806,7 +806,7 @@ else ifneq (,$(LOCAL_SDK_VERSION)) # Set target-api for LOCAL_SDK_VERSIONs other than current. ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) -renderscript_target_api := $(LOCAL_SDK_VERSION) +renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) endif endif # LOCAL_SDK_VERSION is set endif # LOCAL_RENDERSCRIPT_TARGET_API is set diff --git a/core/config.mk b/core/config.mk index 3f518877ab..ecd87ad5e9 100644 --- a/core/config.mk +++ b/core/config.mk @@ -875,6 +875,11 @@ TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\ $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \ $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar))) +TARGET_AVAILABLE_SDK_VERSIONS := $(addprefix system_,$(call numerically_sort,\ + $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android_system.jar,%, \ + $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android_system.jar)))) \ + $(TARGET_AVAILABLE_SDK_VERSIONS) + # We don't have prebuilt test_current SDK yet. TARGET_AVAILABLE_SDK_VERSIONS := test_current $(TARGET_AVAILABLE_SDK_VERSIONS) diff --git a/core/definitions.mk b/core/definitions.mk index c8368b4313..d578842024 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -3386,3 +3386,22 @@ $(foreach source,$(ENFORCE_RRO_SOURCES), \ $(eval ALL_MODULES.$(enforce_rro_source_module).REQUIRED += $(enforce_rro_module)) \ ) endef + +########################################################### +## Find system_$(VER) in LOCAL_SDK_VERSION +## +## $(1): LOCAL_SDK_VERSION +########################################################### +define has-system-sdk-version +$(filter system_%,$(1)) +endef + +########################################################### +## Get numerical version in LOCAL_SDK_VERSION +## +## $(1): LOCAL_SDK_VERSION +########################################################### +define get-numeric-sdk-version +$(filter-out current,\ + $(if $(call has-system-sdk-version,$(1)),$(patsubst system_%,%,$(1)),$(1))) +endef diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk index ac5c4a916b..e29cde720b 100644 --- a/core/dpi_specific_apk.mk +++ b/core/dpi_specific_apk.mk @@ -19,7 +19,7 @@ $(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, $(LOCAL_SDK_VERSION))) -$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(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 diff --git a/core/droiddoc.mk b/core/droiddoc.mk index 2bac984b47..778a631514 100644 --- a/core/droiddoc.mk +++ b/core/droiddoc.mk @@ -72,8 +72,13 @@ ifneq ($(LOCAL_SDK_VERSION),) LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES) $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_test_stubs_current) else - LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) - $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION)) + ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) + LOCAL_JAVA_LIBRARIES := system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) $(LOCAL_JAVA_LIBRARIES) + $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))) + else + LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) + $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION)) + endif endif else LOCAL_JAVA_LIBRARIES := core-oj core-libart ext framework $(LOCAL_JAVA_LIBRARIES) diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index a522f0bb82..1b3f9677ba 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -186,8 +186,8 @@ $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) endif # !LOCAL_IS_STATIC_JAVA_LIBRARY ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) - my_default_app_target_sdk := $(LOCAL_SDK_VERSION) - my_sdk_version := $(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) diff --git a/core/java.mk b/core/java.mk index 9143bc1248..817f81aee4 100644 --- a/core/java.mk +++ b/core/java.mk @@ -135,7 +135,7 @@ else ifneq (,$(LOCAL_SDK_VERSION)) # Set target-api for LOCAL_SDK_VERSIONs other than current. ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) - renderscript_target_api := $(LOCAL_SDK_VERSION) + renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) endif endif # LOCAL_SDK_VERSION is set endif # LOCAL_RENDERSCRIPT_TARGET_API is set @@ -801,8 +801,8 @@ $(LOCAL_MODULE)-findbugs : $(findbugs_html) endif # full_classes_jar is defined ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) - my_default_app_target_sdk := $(LOCAL_SDK_VERSION) - my_sdk_version := $(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) diff --git a/core/java_common.mk b/core/java_common.mk index 4dd0de65f2..59c5e34790 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -229,8 +229,12 @@ ifndef LOCAL_IS_HOST_MODULE else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current) full_java_bootclasspath_libs := $(call java-lib-header-files,android_test_stubs_current) else - full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION)) - endif # current, system_current, or test_current + ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) + full_java_bootclasspath_libs := $(call java-lib-header-files,system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))) + else + full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION)) + endif + endif # current, system_current, system_${VER} or test_current endif # LOCAL_SDK_VERSION ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) @@ -404,6 +408,10 @@ ifeq ($(LOCAL_SDK_VERSION),system_current) my_link_type := java:system my_warn_types := java:platform my_allowed_types := java:sdk java:system +else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) +my_link_type := java:system +my_warn_types := java:platform +my_allowed_types := java:sdk java:system else ifneq ($(LOCAL_SDK_VERSION),) my_link_type := java:sdk my_warn_types := java:system java:platform diff --git a/core/local_vsdk.mk b/core/local_vsdk.mk new file mode 100644 index 0000000000..f798d47361 --- /dev/null +++ b/core/local_vsdk.mk @@ -0,0 +1,19 @@ + +ifdef BOARD_VSDK_VERSION +# Set LOCAL_SDK_VERSION to system_current, If LOCAL_SDK_VERSION is not defined and LOCAL_VENDOR_MODULE is true + _is_vendor_app := + ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE) $(LOCAL_PROPRIETARY_MODULE))) + _is_vendor_app := true + else + ifneq (,$(filter $(TARGET_OUT_VENDOR)%,$(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64))) + _is_vendor_app := true + endif + endif + ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS))) + ifndef LOCAL_SDK_VERSION + ifeq ($(_is_vendor_app),true) + LOCAL_SDK_VERSION := system_current + endif + endif + endif +endif diff --git a/core/package_internal.mk b/core/package_internal.mk index 9f99c7af40..2a84b4fec7 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -365,7 +365,7 @@ else ifneq (,$(LOCAL_SDK_VERSION)) # Set target-api for LOCAL_SDK_VERSIONs other than current. ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) -renderscript_target_api := $(LOCAL_SDK_VERSION) +renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) endif endif # LOCAL_SDK_VERSION is set endif # LOCAL_RENDERSCRIPT_TARGET_API is set diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 47bd1b26be..f4b143c82d 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -500,6 +500,8 @@ $(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): ifeq ($(LOCAL_SDK_VERSION),system_current) my_link_type := java:system +else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) +my_link_type := java:system else ifneq ($(LOCAL_SDK_VERSION),) my_link_type := java:sdk else diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index 6c27f57413..e7f5fa57fd 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -81,6 +81,10 @@ ifeq ($(LOCAL_SDK_VERSION),system_current) my_link_type := java:system my_warn_types := java:platform my_allowed_types := java:sdk java:system +else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) +my_link_type := java:system +my_warn_types := java:platform +my_allowed_types := java:sdk java:system else ifneq ($(LOCAL_SDK_VERSION),) my_link_type := java:sdk my_warn_types := java:system java:platform diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 5ffb88db8f..6645af5550 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -150,7 +150,7 @@ else ifneq (,$(LOCAL_SDK_VERSION)) # Set target-api for LOCAL_SDK_VERSIONs other than current. ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) -renderscript_target_api := $(LOCAL_SDK_VERSION) +renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) endif endif # LOCAL_SDK_VERSION is set endif # LOCAL_RENDERSCRIPT_TARGET_API is set From 3c113098f7db6c8278f0e8114bdc187ae186d648 Mon Sep 17 00:00:00 2001 From: Sundong Ahn Date: Thu, 30 Nov 2017 16:28:22 +0900 Subject: [PATCH 2/2] Fix build error Fix the build error when TARGET_BUILD_APPS is set Bug: 67724799 Test: m -j TARGET_PRODUCT=full TARGET_BUILD_APPS=TVTestInput Merged-In: I981b0a245d7e8f2dabbd4e51db52d17aeacc6106 Change-Id: I981b0a245d7e8f2dabbd4e51db52d17aeacc6106 (cherry picked from commit 8e7a4c413faa5fb9e812b9b04975b313cc7db8f5) --- core/droiddoc.mk | 9 +++++++-- core/java_common.mk | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/droiddoc.mk b/core/droiddoc.mk index 778a631514..c8d0dc81ec 100644 --- a/core/droiddoc.mk +++ b/core/droiddoc.mk @@ -73,8 +73,13 @@ ifneq ($(LOCAL_SDK_VERSION),) $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_test_stubs_current) else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) - LOCAL_JAVA_LIBRARIES := system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) $(LOCAL_JAVA_LIBRARIES) - $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))) + ifeq (,$(TARGET_BUILD_APPS)) + LOCAL_JAVA_LIBRARIES := system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) $(LOCAL_JAVA_LIBRARIES) + $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))) + else + LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) + $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION)) + endif else LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION)) diff --git a/core/java_common.mk b/core/java_common.mk index 59c5e34790..a90c779b44 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -230,7 +230,11 @@ ifndef LOCAL_IS_HOST_MODULE full_java_bootclasspath_libs := $(call java-lib-header-files,android_test_stubs_current) else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) - full_java_bootclasspath_libs := $(call java-lib-header-files,system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))) + ifeq (,$(TARGET_BUILD_APPS)) + full_java_bootclasspath_libs := $(call java-lib-header-files,system_sdk_v$(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))) + else + full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION)) + endif else full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION)) endif