Merge "Add non-fatal mode for verify_uses_libraries check."
This commit is contained in:
commit
c66465a4b0
|
@ -104,17 +104,19 @@ endif
|
|||
|
||||
my_enforced_uses_libraries :=
|
||||
ifdef LOCAL_ENFORCE_USES_LIBRARIES
|
||||
my_enforced_uses_libraries := $(intermediates.COMMON)/enforce_uses_libraries.timestamp
|
||||
my_enforced_uses_libraries := $(intermediates.COMMON)/enforce_uses_libraries.status
|
||||
$(my_enforced_uses_libraries): PRIVATE_USES_LIBRARIES := $(LOCAL_USES_LIBRARIES)
|
||||
$(my_enforced_uses_libraries): PRIVATE_OPTIONAL_USES_LIBRARIES := $(LOCAL_OPTIONAL_USES_LIBRARIES)
|
||||
$(my_enforced_uses_libraries): PRIVATE_RELAX_CHECK := $(RELAX_USES_LIBRARY_CHECK)
|
||||
$(my_enforced_uses_libraries): $(BUILD_SYSTEM)/verify_uses_libraries.sh $(AAPT)
|
||||
$(my_enforced_uses_libraries): $(my_prebuilt_src_file)
|
||||
@echo Verifying uses-libraries: $<
|
||||
rm -f $@
|
||||
aapt_binary=$(AAPT) \
|
||||
uses_library_names="$(strip $(PRIVATE_USES_LIBRARIES))" \
|
||||
optional_uses_library_names="$(strip $(PRIVATE_OPTIONAL_USES_LIBRARIES))" \
|
||||
$(BUILD_SYSTEM)/verify_uses_libraries.sh $<
|
||||
touch $@
|
||||
relax_check="$(strip $(PRIVATE_RELAX_CHECK))" \
|
||||
$(BUILD_SYSTEM)/verify_uses_libraries.sh $< $@
|
||||
$(built_module) : $(my_enforced_uses_libraries)
|
||||
endif
|
||||
|
||||
|
|
|
@ -479,6 +479,17 @@ USE_PREBUILT_SDK_TOOLS_IN_PLACE := true
|
|||
USE_D8 := true
|
||||
.KATI_READONLY := USE_D8
|
||||
|
||||
# Whether to fail immediately if verify_uses_libraries check fails, or to keep
|
||||
# going and restrict dexpreopt to not compile any code for the failed module.
|
||||
#
|
||||
# The intended use case for this flag is to have a smoother migration path for
|
||||
# the Java modules that need to add <uses-library> information in their build
|
||||
# files. The flag allows to quickly silence build errors. This flag should be
|
||||
# used with caution and only as a temporary measure, as it masks real errors
|
||||
# and affects performance.
|
||||
RELAX_USES_LIBRARY_CHECK ?= false
|
||||
.KATI_READONLY := RELAX_USES_LIBRARY_CHECK
|
||||
|
||||
#
|
||||
# Tools that are prebuilts for TARGET_BUILD_USE_PREBUILT_SDKS
|
||||
#
|
||||
|
|
|
@ -105,6 +105,7 @@ ifeq ($(WRITE_SOONG_VARIABLES),true)
|
|||
$(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT)))
|
||||
$(call add_json_bool, SanitizeLite, $(SANITIZE_LITE))
|
||||
$(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE))
|
||||
$(call add_json_bool, RelaxUsesLibraryCheck, $(filter true,$(RELAX_USES_LIBRARY_CHECK)))
|
||||
$(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX))
|
||||
$(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS))
|
||||
$(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty)
|
||||
|
|
|
@ -278,6 +278,7 @@ ifdef LOCAL_DEX_PREOPT
|
|||
$(call add_json_list, PreoptFlags, $(LOCAL_DEX_PREOPT_FLAGS))
|
||||
$(call add_json_str, ProfileClassListing, $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE)))
|
||||
$(call add_json_bool, ProfileIsTextListing, $(my_profile_is_text_listing))
|
||||
$(call add_json_str, EnforceUsesLibrariesStatusFile, $(intermediates.COMMON)/enforce_uses_libraries.status)
|
||||
$(call add_json_bool, EnforceUsesLibraries, $(LOCAL_ENFORCE_USES_LIBRARIES))
|
||||
$(call add_json_str, ProvidesUsesLibrary, $(firstword $(LOCAL_PROVIDES_USES_LIBRARY) $(LOCAL_MODULE)))
|
||||
$(call add_json_map, ClassLoaderContexts)
|
||||
|
@ -345,6 +346,9 @@ ifdef LOCAL_DEX_PREOPT
|
|||
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/javalib.jar)
|
||||
my_dexpreopt_deps += $(my_dexpreopt_images_deps)
|
||||
my_dexpreopt_deps += $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES)
|
||||
ifeq ($(LOCAL_ENFORCE_USES_LIBRARIES),true)
|
||||
my_dexpreopt_deps += $(intermediates.COMMON)/enforce_uses_libraries.status
|
||||
endif
|
||||
|
||||
$(my_dexpreopt_zip): PRIVATE_MODULE := $(LOCAL_MODULE)
|
||||
$(my_dexpreopt_zip): $(my_dexpreopt_deps)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
set -e
|
||||
local_apk=$1
|
||||
status_file=$2
|
||||
badging=$(${aapt_binary} dump badging "${local_apk}")
|
||||
export sdk_version=$(echo "${badging}" | grep "sdkVersion" | sed -n "s/sdkVersion:'\(.*\)'/\1/p")
|
||||
# Export target_sdk_version to the caller.
|
||||
|
@ -28,20 +29,28 @@ export target_sdk_version=$(echo "${badging}" | grep "targetSdkVersion" | sed -n
|
|||
uses_libraries=$(echo "${badging}" | grep "uses-library" | sed -n "s/uses-library:'\(.*\)'/\1/p")
|
||||
optional_uses_libraries=$(echo "${badging}" | grep "uses-library-not-required" | sed -n "s/uses-library-not-required:'\(.*\)'/\1/p")
|
||||
|
||||
errmsg=
|
||||
|
||||
# Verify that the uses libraries match exactly.
|
||||
# Currently we validate the ordering of the libraries since it matters for resolution.
|
||||
single_line_libs=$(echo "${uses_libraries}" | tr '\n' ' ' | awk '{$1=$1}1')
|
||||
if [[ "${single_line_libs}" != "${uses_library_names}" ]]; then
|
||||
echo "LOCAL_USES_LIBRARIES (${uses_library_names})" \
|
||||
"do not match (${single_line_libs}) in manifest for ${local_apk}"
|
||||
exit 1
|
||||
errmsg="LOCAL_USES_LIBRARIES (${uses_library_names}) do not match (${single_line_libs}) in manifest for ${local_apk}"
|
||||
fi
|
||||
|
||||
# Verify that the optional uses libraries match exactly.
|
||||
single_line_optional_libs=$(echo "${optional_uses_libraries}" | tr '\n' ' ' | awk '{$1=$1}1')
|
||||
if [[ "${single_line_optional_libs}" != "${optional_uses_library_names}" ]]; then
|
||||
echo "LOCAL_OPTIONAL_USES_LIBRARIES (${optional_uses_library_names}) " \
|
||||
"do not match (${single_line_optional_libs}) in manifest for ${local_apk}"
|
||||
exit 1
|
||||
errmsg="LOCAL_OPTIONAL_USES_LIBRARIES (${optional_uses_library_names}) do not match (${single_line_optional_libs}) in manifest for ${local_apk}"
|
||||
fi
|
||||
|
||||
if [[ ! -z "${errmsg}" ]]; then
|
||||
echo "${errmsg}" > "${status_file}"
|
||||
if [[ "${relax_check}" != true ]]; then
|
||||
# fail immediately
|
||||
echo "${errmsg}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
touch "${status_file}"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue