Merge "Convert apicheck tool build to Soong."
diff --git a/core/android_manifest.mk b/core/android_manifest.mk
index 7d573d3..1dca7ab 100644
--- a/core/android_manifest.mk
+++ b/core/android_manifest.mk
@@ -23,7 +23,7 @@
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml)
# With aapt2, we'll link in the built resource from the AAR.
-ifndef LOCAL_USE_AAPT2
+ifneq ($(LOCAL_USE_AAPT2),true)
LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res)
endif # LOCAL_USE_AAPT2
diff --git a/core/config.mk b/core/config.mk
index 6a497ab..b94acd5 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -92,8 +92,6 @@
UNAME := $(shell uname -sm)
SRC_TARGET_DIR := $(TOPDIR)build/target
-SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api
-SRC_TEST_API_DIR := $(TOPDIR)prebuilts/sdk/test-api
# Some specific paths to tools
SRC_DROIDDOC_DIR := $(TOPDIR)build/make/tools/droiddoc
diff --git a/core/definitions.mk b/core/definitions.mk
index 1463bc6..a1a178b 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2147,6 +2147,17 @@
$(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-packages '
endef
+define _create-default-manifest-file
+$(1):
+ rm -f $1
+ echo '<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="missing.manifest"></manifest>' > $1
+endef
+
+define create-default-manifest-file
+ $(eval $(call _create-default-manifest-file,$(1)))
+endef
+
+
###########################################################
xlint_unchecked := -Xlint:unchecked
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 5495f62..3b9e4e1 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -175,6 +175,7 @@
stored_class_loader_context_arg="" && \
uses_library_names="$(PRIVATE_USES_LIBRARY_NAMES)" && \
optional_uses_library_names="$(PRIVATE_OPTIONAL_USES_LIBRARY_NAMES)" && \
+aapt_binary="$(AAPT)" && \
$(if $(filter true,$(PRIVATE_ENFORCE_USES_LIBRARIES)), \
source build/make/core/verify_uses_libraries.sh "$(1)" && \
source build/make/core/construct_context.sh "$(PRIVATE_CONDITIONAL_USES_LIBRARIES_HOST)" "$(PRIVATE_CONDITIONAL_USES_LIBRARIES_TARGET)" && \
diff --git a/core/force_aapt2.mk b/core/force_aapt2.mk
new file mode 100644
index 0000000..655ccf5
--- /dev/null
+++ b/core/force_aapt2.mk
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Including this makefile will force AAPT2 on if FORCE_AAPT2==true,
+# rewriting some properties to convert standard AAPT usage to AAPT2.
+
+ifeq ($(FORCE_AAPT2),true)
+ ifneq ($(LOCAL_USE_AAPT2),true)
+ # Force AAPT2 on
+ LOCAL_USE_AAPT2 := true
+ # Move LOCAL_STATIC_JAVA_AAR_LIBRARIES to LOCAL_STATIC_ANDROID_LIBRARIES
+ LOCAL_STATIC_ANDROID_LIBRARIES := $(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES))
+ LOCAL_STATIC_JAVA_AAR_LIBRARIES :=
+ # Filter out support library resources
+ LOCAL_RESOURCE_DIR := $(filter-out \
+ prebuilts/sdk/current/% \
+ frameworks/support/%,\
+ $(LOCAL_RESOURCE_DIR))
+ # Filter out unnecessary aapt flags
+ LOCAL_AAPT_FLAGS := $(subst --extra-packages=,--extra-packages$(space), \
+ $(filter-out \
+ --extra-packages=android.support.% \
+ --extra-packages=androidx.% \
+ --auto-add-overlay,\
+ $(subst --extra-packages$(space),--extra-packages=,$(LOCAL_AAPT_FLAGS))))
+
+ # AAPT2 is pickier about missing resources. Support library may have references to resources
+ # added in current, so always treat LOCAL_SDK_VERSION as LOCAL_SDK_RES_VERSION := current.
+ ifdef LOCAL_SDK_VERSION
+ LOCAL_SDK_RES_VERSION := current
+ endif
+
+ ifeq (,$(strip $(LOCAL_MANIFEST_FILE)$(LOCAL_FULL_MANIFEST_FILE)))
+ ifeq (,$(wildcard $(LOCAL_PATH)/AndroidManifest.xml))
+ # work around missing manifests by creating a default one
+ $(call pretty-warning, Missing manifest file)
+ LOCAL_FULL_MANIFEST_FILE := $(call local-intermediates-dir,COMMON)/DefaultManifest.xml
+ $(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE))
+ endif
+ endif
+ endif
+endif
+
+ifneq ($(LOCAL_USE_AAPT2),true)
+ ifneq ($(LOCAL_USE_AAPT2),false)
+ ifneq ($(LOCAL_USE_AAPT2),)
+ $(call pretty-error,Invalid value for LOCAL_USE_AAPT2: "$(LOCAL_USE_AAPT2)")
+ endif
+ endif
+endif
diff --git a/core/java.mk b/core/java.mk
index 297f0b7..8e5fd1d 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -444,7 +444,7 @@
common_proguard_flags += -dontshrink # don't shrink tests by default
endif # test package
ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
- ifdef LOCAL_USE_AAPT2
+ ifeq ($(LOCAL_USE_AAPT2),true)
common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)
endif
diff --git a/core/java_common.mk b/core/java_common.mk
index 2695aff..d8f679a 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -477,7 +477,7 @@
ifdef LOCAL_AAPT2_ONLY
my_link_type += aapt2_only
endif
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
my_allowed_types += aapt2_only
endif
diff --git a/core/package_internal.mk b/core/package_internal.mk
index f8e610b..18c8f23 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -87,6 +87,8 @@
LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
endif
+include $(BUILD_SYSTEM)/force_aapt2.mk
+
package_resource_overlays := $(strip \
$(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
@@ -153,7 +155,7 @@
endif
my_res_package :=
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
# In aapt2 the last takes precedence.
my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR))
my_res_dir :=
@@ -357,7 +359,7 @@
###############################
## AAPT/AAPT2
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
ifneq (,$(renderscript_target_api))
ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true)
@@ -509,7 +511,7 @@
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
$(my_res_package) : $(all_library_res_package_export_deps)
endif
@@ -593,7 +595,7 @@
$(LOCAL_BUILT_MODULE): PRIVATE_FULL_CLASSES_JAR := $(full_classes_jar)
$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
$(LOCAL_BUILT_MODULE) : $(JAR_ARGS)
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP)
else
@@ -604,7 +606,7 @@
$(LOCAL_BUILT_MODULE) : $(MINIGZIP)
endif
@echo "target Package: $(PRIVATE_MODULE) ($@)"
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
$(call copy-file-to-new-target)
else # ! LOCAL_USE_AAPT2
$(if $(PRIVATE_SOURCE_ARCHIVE),\
@@ -620,7 +622,7 @@
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
else # full_classes_jar
$(add-dex-to-package)
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
$(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR))
endif
endif # full_classes_jar
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 8aa5b96..6a9916a 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -607,11 +607,13 @@
$(common_javalib_jar) : $(common_classes_jar)
$(transform-prebuilt-to-target)
+include $(BUILD_SYSTEM)/force_aapt2.mk
+
ifdef LOCAL_AAPT2_ONLY
LOCAL_USE_AAPT2 := true
endif
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
ifneq ($(my_src_aar),)
$(intermediates.COMMON)/export_proguard_flags : $(my_src_proguard_options)
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index 8ef28b8..332314f 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -28,6 +28,8 @@
my_res_package :=
+include $(BUILD_SYSTEM)/force_aapt2.mk
+
ifdef LOCAL_AAPT2_ONLY
LOCAL_USE_AAPT2 := true
endif
@@ -44,7 +46,7 @@
need_compile_res := true
LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
endif
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
ifneq ($(LOCAL_STATIC_ANDROID_LIBRARIES),)
need_compile_res := true
endif
@@ -82,7 +84,7 @@
R_file_stamp := $(intermediates.COMMON)/src/R.stamp
LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
# For library we treat all the resource equal with no overlay.
my_res_resources := $(all_resources)
my_overlay_resources :=
@@ -117,7 +119,7 @@
endif
endif
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
import_proguard_flag_files := $(strip $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags))
$(intermediates.COMMON)/export_proguard_flags: $(import_proguard_flag_files) $(addprefix $(LOCAL_PATH)/,$(LOCAL_EXPORT_PROGUARD_FLAG_FILES))
@@ -140,7 +142,7 @@
# add --non-constant-id to prevent inlining constants.
# AAR needs text symbol file R.txt.
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --output-text-symbols $(intermediates.COMMON)/R.txt
ifndef LOCAL_AAPT_NAMESPACES
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS += --no-static-lib-packages
@@ -168,7 +170,7 @@
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME :=
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR :=
-ifdef LOCAL_USE_AAPT2
+ifeq ($(LOCAL_USE_AAPT2),true)
# One more level with name res so we can zip up the flat resources that can be linked by apps.
my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res
ifneq (,$(renderscript_target_api))
diff --git a/core/verify_uses_libraries.sh b/core/verify_uses_libraries.sh
index 8135be6..dde0447 100755
--- a/core/verify_uses_libraries.sh
+++ b/core/verify_uses_libraries.sh
@@ -15,11 +15,13 @@
# limitations under the License.
+# apt_binary is $(AAPT) in the build.
+
# Parse sdk, targetSdk, and uses librares in the APK, then cross reference against build specified ones.
set -e
local_apk=$1
-badging=$(aapt dump badging "${local_apk}")
+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.
export target_sdk_version=$(echo "${badging}" | grep "targetSdkVersion" | sed -n "s/targetSdkVersion:'\(.*\)'/\1/p")
diff --git a/tools/releasetools/validate_target_files.py b/tools/releasetools/validate_target_files.py
index e8cea29..acd5b6e 100755
--- a/tools/releasetools/validate_target_files.py
+++ b/tools/releasetools/validate_target_files.py
@@ -66,7 +66,7 @@
file_name, actual_sha1, expected_sha1)
-def ValidateFileConsistency(input_zip, input_tmp):
+def ValidateFileConsistency(input_zip, input_tmp, info_dict):
"""Compare the files from image files and unpacked folders."""
def CheckAllFiles(which):
@@ -103,6 +103,11 @@
logging.info('Validating file consistency.')
+ # TODO(b/79617342): Validate non-sparse images.
+ if info_dict.get('extfs_sparse_flag') != '-s':
+ logging.warning('Skipped due to target using non-sparse images')
+ return
+
# Verify IMAGES/system.img.
CheckAllFiles('system')
@@ -324,10 +329,10 @@
logging.info("Unzipping the input target_files.zip: %s", args.target_files)
input_tmp = common.UnzipTemp(args.target_files)
- with zipfile.ZipFile(args.target_files, 'r') as input_zip:
- ValidateFileConsistency(input_zip, input_tmp)
-
info_dict = common.LoadInfoDict(input_tmp)
+ with zipfile.ZipFile(args.target_files, 'r') as input_zip:
+ ValidateFileConsistency(input_zip, input_tmp, info_dict)
+
ValidateInstallRecoveryScript(input_tmp, info_dict)
ValidateVerifiedBootImages(input_tmp, info_dict, options)