Steven Moreland | 0f84e4b | 2023-12-16 02:51:26 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | function finalize_vintf_resources() { |
| 6 | local top="$(dirname "$0")"/../../../.. |
| 7 | source $top/build/make/tools/finalization/environment.sh |
| 8 | |
| 9 | # TODO(b/314010764): finalize LL_NDK |
| 10 | # TODO(b/314010177): finalize SELinux |
| 11 | |
Devin Moore | a1339af | 2024-01-11 23:51:22 +0000 | [diff] [blame] | 12 | create_new_compat_matrix |
| 13 | |
Steven Moreland | 0f84e4b | 2023-12-16 02:51:26 +0000 | [diff] [blame] | 14 | # pre-finalization build target (trunk) |
| 15 | local aidl_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=trunk TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" |
| 16 | AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api |
| 17 | |
| 18 | # build/make |
| 19 | sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk" |
Steven Moreland | 0f84e4b | 2023-12-16 02:51:26 +0000 | [diff] [blame] | 20 | } |
| 21 | |
Devin Moore | a1339af | 2024-01-11 23:51:22 +0000 | [diff] [blame] | 22 | function create_new_compat_matrix() { |
| 23 | # The compatibility matrix versions are bumped during vFRC |
| 24 | # These will change every time we have a new vFRC |
Devin Moore | 196c1b5 | 2024-01-17 16:40:29 +0000 | [diff] [blame] | 25 | export CURRENT_COMPATIBILITY_MATRIX_LEVEL='202404' |
| 26 | export FINAL_COMPATIBILITY_MATRIX_LEVEL='202504' |
Devin Moore | a1339af | 2024-01-11 23:51:22 +0000 | [diff] [blame] | 27 | |
| 28 | local top="$(dirname "$0")"/../../../.. |
| 29 | source $top/build/make/tools/finalization/environment.sh |
| 30 | |
| 31 | local current_file=compatibility_matrix."$CURRENT_COMPATIBILITY_MATRIX_LEVEL".xml |
| 32 | local final_file=compatibility_matrix."$FINAL_COMPATIBILITY_MATRIX_LEVEL".xml |
| 33 | local current_bp_module=framework_$current_file |
| 34 | local final_bp_module=framework_$final_file |
| 35 | local src=$top/hardware/interfaces/compatibility_matrices/$current_file |
| 36 | local dest=$top/hardware/interfaces/compatibility_matrices/$final_file |
| 37 | local bp_file=$top/hardware/interfaces/compatibility_matrices/Android.bp |
| 38 | |
| 39 | # check to see if this script needs to be run |
| 40 | if grep -q $final_bp_module $bp_file; then |
| 41 | echo "Nothing to do because the new module exists" |
| 42 | return |
| 43 | fi |
| 44 | |
| 45 | # build the targets required before touching the Android.bp/Android.mk files |
| 46 | local build_cmd="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=trunk TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" |
| 47 | $build_cmd bpfmt |
| 48 | $build_cmd bpmodify |
| 49 | $build_cmd queryview |
| 50 | |
| 51 | # create the new file and modify the level |
| 52 | sed "s/level=\""$CURRENT_COMPATIBILITY_MATRIX_LEVEL"\"/level=\""$FINAL_COMPATIBILITY_MATRIX_LEVEL"\"/" "$src" > "$dest" |
| 53 | |
| 54 | echo " |
| 55 | vintf_compatibility_matrix { |
| 56 | name: \"$final_bp_module\", |
| 57 | stem: \"$final_file\", |
| 58 | srcs: [ |
| 59 | \"$final_file\", |
| 60 | ], |
| 61 | }" >> $bp_file |
| 62 | |
| 63 | # get the previous kernel_configs properties and add them to the new module |
Devin Moore | 395d5e3 | 2024-01-17 16:47:11 +0000 | [diff] [blame] | 64 | local kernel_configs=$($top/out/host/linux-x86/bin/bazel query --config=queryview //hardware/interfaces/compatibility_matrices:"$current_bp_module"--android_common --output=build 2>$1 | grep kernel_configs | sed 's/[^\[]*\[\(.*\)],/\1/' | sed 's/ //g' | sed 's/\"//g') |
Devin Moore | a1339af | 2024-01-11 23:51:22 +0000 | [diff] [blame] | 65 | |
| 66 | $top/out/host/linux-x86/bin/bpmodify -m $final_bp_module -property kernel_configs -a $kernel_configs -w $bp_file |
| 67 | |
| 68 | $top/out/host/linux-x86/bin/bpfmt -w $bp_file |
| 69 | |
| 70 | local make_file=$top/hardware/interfaces/compatibility_matrices/Android.mk |
| 71 | # replace the current compat matrix in the make file with the final one |
| 72 | # the only place this resides is in the conditional addition |
| 73 | sed -i "s/$current_file/$final_file/g" $make_file |
| 74 | # add the current compat matrix to the unconditional addition |
| 75 | sed -i "/^ framework_compatibility_matrix.device.xml/i \ $current_bp_module \\\\" $make_file |
| 76 | } |
| 77 | |
Steven Moreland | 0f84e4b | 2023-12-16 02:51:26 +0000 | [diff] [blame] | 78 | finalize_vintf_resources |
| 79 | |