1#!/bin/bash 2 3set -ex 4 5function finalize_vintf_resources() { 6 if [ $# -gt 1 ]; then 7 echo "No argument or '--steps_for_build_test_only' is allowed" 8 exit 1 9 fi 10 if [ $# -eq 1 ]; then 11 if [ "$1" == "--steps_for_build_test_only" ]; then 12 echo "This is only to verify building a target." 13 echo "Skip LLNDK ABI dump and VINTF check." 14 local build_test_only=true 15 else 16 echo "Unknown argument $1" 17 exit 1 18 fi 19 fi 20 21 local top="$(dirname "$0")"/../../../.. 22 source $top/build/make/tools/finalization/environment.sh 23 # environment needed to build dependencies and run scripts 24 # These should remain the same for all steps here to speed up build time 25 export ANDROID_BUILD_TOP="$top" 26 export ANDROID_HOST_OUT="$ANDROID_BUILD_TOP/out/host/linux-x86" 27 export ANDROID_PRODUCT_OUT="$ANDROID_BUILD_TOP/out/target/product/generic_arm64" 28 export PATH="$PATH:$ANDROID_HOST_OUT/bin/" 29 export TARGET_BUILD_VARIANT=userdebug 30 export DIST_DIR=out/dist 31 export TARGET_RELEASE=fina_0 32 export TARGET_PRODUCT=aosp_arm64 33 34 # build/soong 35 local vendor_api_level_map="case ${FINAL_NEXT_BOARD_API_LEVEL}:" 36 if ! grep -q "$vendor_api_level_map" "$top/build/soong/android/vendor_api_levels.go" ; then 37 sed -i -e "/case ${FINAL_BOARD_API_LEVEL}:/{N;a \\\t$vendor_api_level_map\n\t\tsdkVersion = ${FINAL_NEXT_CORRESPONDING_SDK_VERSION} 38 }" "$top/build/soong/android/vendor_api_levels.go" 39 fi 40 41 # system/sepolicy 42 "$top/system/sepolicy/tools/finalize-vintf-resources.sh" "$top" "$FINAL_BOARD_API_LEVEL" 43 44 local aidl_m="$top/build/soong/soong_ui.bash --make-mode" 45 AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api create_reference_dumps 46 47 finalize_compat_matrix $build_test_only 48 49 if ! [ "$build_test_only" = "true" ]; then 50 # Generate LLNDK ABI dumps 51 # This command depends on ANDROID_BUILD_TOP 52 "$ANDROID_HOST_OUT/bin/create_reference_dumps" -release "$TARGET_RELEASE" --build-variant "$TARGET_BUILD_VARIANT" --lib-variant LLNDK 53 fi 54} 55 56function finalize_compat_matrix() { 57 local build_test_only=$1 58 local CURRENT_COMPATIBILITY_MATRIX_LEVEL="$FINAL_BOARD_API_LEVEL" 59 60 "$top/prebuilts/build-tools/path/linux-x86/python3" "$top/hardware/interfaces/compatibility_matrices/finalize.py" "$CURRENT_COMPATIBILITY_MATRIX_LEVEL" 61 62 if ! [ "$build_test_only" = "true" ]; then 63 # Freeze the current framework manifest file. This relies on the 64 # interfaces already being frozen because we are building with fina_0 which 65 # inherits from `next` where RELEASE_AIDL_USE_UNFROZEN=false 66 "$top/system/libhidl/vintfdata/freeze.sh" "$CURRENT_COMPATIBILITY_MATRIX_LEVEL" 67 fi 68} 69 70function freeze_framework_manifest() { 71 ANDROID_PRODUCT_OUT=~/workspace/internal/main/out/target/product/vsoc_x86 ANDROID_BUILD_TOP=~/workspace/internal/main ANDROID_HOST_OUT=~/workspace/internal/main/out/host/linux-x86 ./freeze.sh 202404 72 73} 74 75 76finalize_vintf_resources $@ 77 78