From fee037aac898cdf6f49d8c18edacfde84e4cddaa Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 22 Jan 2019 14:27:50 -0800 Subject: [PATCH] Build DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE. DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE is installed on /product/etc/vintf. It is considered as a replacement of DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE, so only one of them may be defined. At build time, things like SEPolicy versions etc. will be written to /product/etc/vintf/compatibility_matrix.device.xml, just like the /system one. Also, split framework_compatibitity_matrix.xml to system_compatibility_matrix.xml and product_compatibility_matrix.xml. The latter two corresponds to matrices installed to respective partitions only. Test: build with DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE defined Test: boot (sanity) Bug: 120600021 Change-Id: I81f9a8f5028cbb88c45f44df04bccb8ccb483972 --- compatibility_matrices/Android.mk | 59 ++++++++++++++++--- compatibility_matrices/CleanSpec.mk | 47 +++++++++++++++ .../compatibility_matrix.mk | 7 ++- 3 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 compatibility_matrices/CleanSpec.mk diff --git a/compatibility_matrices/Android.mk b/compatibility_matrices/Android.mk index 6be6930023..425e376830 100644 --- a/compatibility_matrices/Android.mk +++ b/compatibility_matrices/Android.mk @@ -17,8 +17,9 @@ LOCAL_PATH := $(call my-dir) BUILD_FRAMEWORK_COMPATIBILITY_MATRIX := $(LOCAL_PATH)/compatibility_matrix.mk +my_empty_manifest := $(LOCAL_PATH)/manifest.empty.xml -# Framework Compatibility Matrix (common to all FCM versions) +# System Compatibility Matrix (common to all FCM versions) include $(CLEAR_VARS) include $(LOCAL_PATH)/clear_vars.mk @@ -26,6 +27,7 @@ LOCAL_MODULE := framework_compatibility_matrix.device.xml LOCAL_MODULE_STEM := compatibility_matrix.device.xml # define LOCAL_MODULE_CLASS for local-generated-sources-dir. LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_RELATIVE_PATH := vintf ifndef DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE LOCAL_SRC_FILES := compatibility_matrix.empty.xml @@ -37,10 +39,9 @@ LOCAL_GENERATED_SOURCES := $(DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE) # Enforce that DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE does not specify required HALs # by checking it against an empty manifest. But the empty manifest needs to contain # BOARD_SEPOLICY_VERS to be compatible with DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE. -my_manifest_src_file := $(LOCAL_PATH)/manifest.empty.xml my_gen_check_manifest := $(local-generated-sources-dir)/manifest.check.xml -$(my_gen_check_manifest): PRIVATE_SRC_FILE := $(my_manifest_src_file) -$(my_gen_check_manifest): $(my_manifest_src_file) $(HOST_OUT_EXECUTABLES)/assemble_vintf +$(my_gen_check_manifest): PRIVATE_SRC_FILE := $(my_empty_manifest) +$(my_gen_check_manifest): $(my_empty_manifest) $(HOST_OUT_EXECUTABLES)/assemble_vintf BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) \ VINTF_IGNORE_TARGET_FCM_VERSION=true \ $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $(PRIVATE_SRC_FILE) -o $@ @@ -49,7 +50,6 @@ LOCAL_GEN_FILE_DEPENDENCIES += $(my_gen_check_manifest) LOCAL_ASSEMBLE_VINTF_FLAGS += -c "$(my_gen_check_manifest)" my_gen_check_manifest := -my_manifest_src_file := endif # DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE @@ -61,18 +61,57 @@ LOCAL_ASSEMBLE_VINTF_ENV_VARS := \ include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) +# Product Compatibility Matrix + +include $(CLEAR_VARS) +include $(LOCAL_PATH)/clear_vars.mk +LOCAL_MODULE := product_compatibility_matrix.xml + +ifndef DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE +my_framework_matrix_deps := +include $(BUILD_PHONY_PACKAGE) +else # DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE + +LOCAL_MODULE_STEM := compatibility_matrix.xml +LOCAL_PRODUCT_MODULE := true +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_RELATIVE_PATH := vintf + +# DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE specify an absolute path +LOCAL_GENERATED_SOURCES := $(DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE) + +# Enforce that DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE does not specify required HALs +# by checking it against an empty manifest. +LOCAL_GEN_FILE_DEPENDENCIES += $(my_empty_manifest) +LOCAL_ASSEMBLE_VINTF_FLAGS += -c "$(my_empty_manifest)" + +my_framework_matrix_deps := $(LOCAL_MODULE) + +include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) + +endif # DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE + my_system_matrix_deps := \ framework_compatibility_matrix.legacy.xml \ framework_compatibility_matrix.1.xml \ framework_compatibility_matrix.2.xml \ framework_compatibility_matrix.3.xml \ framework_compatibility_matrix.current.xml \ - framework_compatibility_matrix.device.xml + framework_compatibility_matrix.device.xml \ -# Phony target that installs all framework compatibility matrix files +my_framework_matrix_deps += \ + $(my_system_matrix_deps) + +# Phony target that installs all system compatibility matrix files +include $(CLEAR_VARS) +LOCAL_MODULE := system_compatibility_matrix.xml +LOCAL_REQUIRED_MODULES := $(my_system_matrix_deps) +include $(BUILD_PHONY_PACKAGE) + +# Phony target that installs all framework compatibility matrix files (system + product) include $(CLEAR_VARS) LOCAL_MODULE := framework_compatibility_matrix.xml -LOCAL_REQUIRED_MODULES := $(my_system_matrix_deps) +LOCAL_REQUIRED_MODULES := $(my_framework_matrix_deps) include $(BUILD_PHONY_PACKAGE) # Final Framework Compatibility Matrix for OTA @@ -80,7 +119,7 @@ include $(CLEAR_VARS) include $(LOCAL_PATH)/clear_vars.mk LOCAL_MODULE := verified_assembled_system_matrix.xml LOCAL_MODULE_PATH := $(PRODUCT_OUT) -LOCAL_REQUIRED_MODULES := $(my_system_matrix_deps) +LOCAL_REQUIRED_MODULES := $(my_framework_matrix_deps) LOCAL_GENERATED_SOURCES := $(call module-installed-files,$(LOCAL_REQUIRED_MODULES)) LOCAL_ADD_VBMETA_VERSION_OVERRIDE := true @@ -97,4 +136,6 @@ include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) BUILT_SYSTEM_MATRIX := $(LOCAL_BUILT_MODULE) my_system_matrix_deps := +my_framework_matrix_deps := +my_empty_manifest := BUILD_FRAMEWORK_COMPATIBILITY_MATRIX := diff --git a/compatibility_matrices/CleanSpec.mk b/compatibility_matrices/CleanSpec.mk new file mode 100644 index 0000000000..9b150ede48 --- /dev/null +++ b/compatibility_matrices/CleanSpec.mk @@ -0,0 +1,47 @@ +# Copyright 2019 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. +# + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/vintf/compatibility_matrix.device.xml) diff --git a/compatibility_matrices/compatibility_matrix.mk b/compatibility_matrices/compatibility_matrix.mk index bafc84b57b..d22e51044d 100644 --- a/compatibility_matrices/compatibility_matrix.mk +++ b/compatibility_matrices/compatibility_matrix.mk @@ -17,7 +17,8 @@ ##### Input Variables: # LOCAL_MODULE: required. Module name for the build system. # LOCAL_MODULE_CLASS: optional. Default is ETC. -# LOCAL_MODULE_PATH: optional. Path of output file. Default is $(TARGET_OUT)/etc/vintf. +# LOCAL_MODULE_PATH / LOCAL_MODULE_RELATIVE_PATH: required. (Relative) path of output file. +# If not defined, LOCAL_MODULE_RELATIVE_PATH will be "vintf". # LOCAL_MODULE_STEM: optional. Name of output file. Default is $(LOCAL_MODULE). # LOCAL_SRC_FILES: required. Local source files provided to assemble_vintf # (command line argument -i). @@ -48,7 +49,9 @@ LOCAL_MODULE_CLASS := ETC endif ifndef LOCAL_MODULE_PATH -LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf +ifndef LOCAL_MODULE_RELATIVE_PATH +$(error Either LOCAL_MODULE_PATH or LOCAL_MODULE_RELATIVE_PATH must be defined.) +endif endif GEN := $(local-generated-sources-dir)/$(LOCAL_MODULE_STEM)