1# 2# Copyright (C) 2018 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17##### Input Variables: 18# LOCAL_MODULE: required. Module name for the build system. 19# LOCAL_MODULE_CLASS: optional. Default is ETC. 20# LOCAL_MODULE_PATH / LOCAL_MODULE_RELATIVE_PATH: required. (Relative) path of output file. 21# If not defined, LOCAL_MODULE_RELATIVE_PATH will be "vintf". 22# LOCAL_MODULE_STEM: optional. Name of output file. Default is $(LOCAL_MODULE). 23# LOCAL_SRC_FILES: required. Local source files provided to assemble_vintf 24# (command line argument -i). 25# LOCAL_GENERATED_SOURCES: optional. Global source files provided to assemble_vintf 26# (command line argument -i). 27# 28# LOCAL_ADD_VBMETA_VERSION: Use AVBTOOL to add avb version to the output matrix 29# (corresponds to <avb><vbmeta-version> tag) 30# LOCAL_ASSEMBLE_VINTF_ENV_VARS: Add a list of environment variable names from global variables in 31# the build system that is lazily evaluated (e.g. PRODUCT_ENFORCE_VINTF_MANIFEST). 32# LOCAL_ASSEMBLE_VINTF_ENV_VARS_OVERRIDE: Add a list of environment variables that is local to 33# assemble_vintf invocation. Format is "VINTF_ENFORCE_NO_UNUSED_HALS=true". 34# LOCAL_ASSEMBLE_VINTF_FLAGS: Add additional command line arguments to assemble_vintf invocation. 35# LOCAL_KERNEL_CONFIG_DATA_PATHS: Paths to search for kernel config requirements. Format for each is 36# <kernel version x.y.z>:<path that contains android-base*.config>. 37# LOCAL_GEN_FILE_DEPENDENCIES: A list of additional dependencies for the generated file. 38 39ifndef LOCAL_MODULE 40$(error LOCAL_MODULE must be defined.) 41endif 42 43ifndef LOCAL_MODULE_STEM 44LOCAL_MODULE_STEM := $(LOCAL_MODULE) 45endif 46 47ifndef LOCAL_MODULE_CLASS 48LOCAL_MODULE_CLASS := ETC 49endif 50 51ifndef LOCAL_MODULE_PATH 52ifndef LOCAL_MODULE_RELATIVE_PATH 53$(error Either LOCAL_MODULE_PATH or LOCAL_MODULE_RELATIVE_PATH must be defined.) 54endif 55endif 56 57GEN := $(local-generated-sources-dir)/$(LOCAL_MODULE_STEM) 58 59$(GEN): PRIVATE_ENV_VARS := $(LOCAL_ASSEMBLE_VINTF_ENV_VARS) 60$(GEN): PRIVATE_FLAGS := $(LOCAL_ASSEMBLE_VINTF_FLAGS) 61 62$(GEN): $(LOCAL_GEN_FILE_DEPENDENCIES) 63 64ifeq (true,$(strip $(LOCAL_ADD_VBMETA_VERSION))) 65ifeq (true,$(BOARD_AVB_ENABLE)) 66$(GEN): $(AVBTOOL) 67# INTERNAL_AVB_SYSTEM_SIGNING_ARGS consists of BOARD_AVB_SYSTEM_KEY_PATH and 68# BOARD_AVB_SYSTEM_ALGORITHM. We should add the dependency of key path, which 69# is a file, here. 70$(GEN): $(BOARD_AVB_SYSTEM_KEY_PATH) 71# Use deferred assignment (=) instead of immediate assignment (:=). 72# Otherwise, cannot get INTERNAL_AVB_SYSTEM_SIGNING_ARGS. 73$(GEN): FRAMEWORK_VBMETA_VERSION = $$("$(AVBTOOL)" add_hashtree_footer \ 74 --print_required_libavb_version \ 75 $(INTERNAL_AVB_SYSTEM_SIGNING_ARGS) \ 76 $(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)) 77else 78$(GEN): FRAMEWORK_VBMETA_VERSION := 0.0 79endif # BOARD_AVB_ENABLE 80$(GEN): PRIVATE_ENV_VARS += FRAMEWORK_VBMETA_VERSION 81endif # LOCAL_ADD_VBMETA_VERSION 82 83ifeq (true,$(strip $(LOCAL_ADD_VBMETA_VERSION_OVERRIDE))) 84ifneq ($(BOARD_OTA_FRAMEWORK_VBMETA_VERSION_OVERRIDE),) 85$(GEN): FRAMEWORK_VBMETA_VERSION_OVERRIDE := $(BOARD_OTA_FRAMEWORK_VBMETA_VERSION_OVERRIDE) 86$(GEN): PRIVATE_ENV_VARS += FRAMEWORK_VBMETA_VERSION_OVERRIDE 87endif 88endif 89 90ifneq (,$(strip $(LOCAL_KERNEL_CONFIG_DATA_PATHS))) 91$(GEN): PRIVATE_KERNEL_CONFIG_DATA_PATHS := $(LOCAL_KERNEL_CONFIG_DATA_PATHS) 92$(GEN): $(foreach pair,$(LOCAL_KERNEL_CONFIG_DATA_PATHS),\ 93 $(wildcard $(call word-colon,2,$(pair))/android-base*.config)) 94$(GEN): PRIVATE_FLAGS += $(foreach pair,$(PRIVATE_KERNEL_CONFIG_DATA_PATHS),\ 95 --kernel=$(call word-colon,1,$(pair)):$(call normalize-path-list,\ 96 $(wildcard $(call word-colon,2,$(pair))/android-base*.config))) 97endif 98 99my_matrix_src_files := \ 100 $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES)) \ 101 $(LOCAL_GENERATED_SOURCES) 102 103$(GEN): PRIVATE_ADDITIONAL_ENV_VARS := $(LOCAL_ASSEMBLE_VINTF_ENV_VARS_OVERRIDE) 104 105ifneq (,$(strip $(LOCAL_ASSEMBLE_VINTF_ERROR_MESSAGE))) 106$(GEN): PRIVATE_COMMAND_TAIL := || (echo $(strip $(LOCAL_ASSEMBLE_VINTF_ERROR_MESSAGE)) && false) 107endif 108 109$(GEN): PRIVATE_SRC_FILES := $(my_matrix_src_files) 110$(GEN): $(my_matrix_src_files) $(HOST_OUT_EXECUTABLES)/assemble_vintf 111 $(foreach varname,$(PRIVATE_ENV_VARS),\ 112 $(if $(findstring $(varname),$(PRIVATE_ADDITIONAL_ENV_VARS)),\ 113 $(error $(varname) should not be overridden by LOCAL_ASSEMBLE_VINTF_ENV_VARS_OVERRIDE.))) 114 $(foreach varname,$(PRIVATE_ENV_VARS),$(varname)="$($(varname))") \ 115 $(PRIVATE_ADDITIONAL_ENV_VARS) \ 116 $(HOST_OUT_EXECUTABLES)/assemble_vintf \ 117 -i $(call normalize-path-list,$(PRIVATE_SRC_FILES)) \ 118 -o $@ \ 119 $(PRIVATE_FLAGS) $(PRIVATE_COMMAND_TAIL) 120 121LOCAL_PREBUILT_MODULE_FILE := $(GEN) 122LOCAL_SRC_FILES := 123LOCAL_GENERATED_SOURCES := 124 125include $(LOCAL_PATH)/clear_vars.mk 126my_matrix_src_files := 127 128include $(BUILD_PREBUILT) 129