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" |
| 20 | cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$FINAL_PLATFORM_SDK_VERSION.txt" |
| 21 | } |
| 22 | |
Devin Moore | a1339af | 2024-01-11 23:51:22 +0000 | [diff] [blame^] | 23 | function create_new_compat_matrix() { |
| 24 | # The compatibility matrix versions are bumped during vFRC |
| 25 | # These will change every time we have a new vFRC |
| 26 | export CURRENT_COMPATIBILITY_MATRIX_LEVEL='9' |
| 27 | export FINAL_COMPATIBILITY_MATRIX_LEVEL='10' |
| 28 | |
| 29 | local top="$(dirname "$0")"/../../../.. |
| 30 | source $top/build/make/tools/finalization/environment.sh |
| 31 | |
| 32 | local current_file=compatibility_matrix."$CURRENT_COMPATIBILITY_MATRIX_LEVEL".xml |
| 33 | local final_file=compatibility_matrix."$FINAL_COMPATIBILITY_MATRIX_LEVEL".xml |
| 34 | local current_bp_module=framework_$current_file |
| 35 | local final_bp_module=framework_$final_file |
| 36 | local src=$top/hardware/interfaces/compatibility_matrices/$current_file |
| 37 | local dest=$top/hardware/interfaces/compatibility_matrices/$final_file |
| 38 | local bp_file=$top/hardware/interfaces/compatibility_matrices/Android.bp |
| 39 | |
| 40 | # check to see if this script needs to be run |
| 41 | if grep -q $final_bp_module $bp_file; then |
| 42 | echo "Nothing to do because the new module exists" |
| 43 | return |
| 44 | fi |
| 45 | |
| 46 | # build the targets required before touching the Android.bp/Android.mk files |
| 47 | 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" |
| 48 | $build_cmd bpfmt |
| 49 | $build_cmd bpmodify |
| 50 | $build_cmd queryview |
| 51 | |
| 52 | # create the new file and modify the level |
| 53 | sed "s/level=\""$CURRENT_COMPATIBILITY_MATRIX_LEVEL"\"/level=\""$FINAL_COMPATIBILITY_MATRIX_LEVEL"\"/" "$src" > "$dest" |
| 54 | |
| 55 | echo " |
| 56 | vintf_compatibility_matrix { |
| 57 | name: \"$final_bp_module\", |
| 58 | stem: \"$final_file\", |
| 59 | srcs: [ |
| 60 | \"$final_file\", |
| 61 | ], |
| 62 | }" >> $bp_file |
| 63 | |
| 64 | # get the previous kernel_configs properties and add them to the new module |
| 65 | local kernel_configs=$($top/out/host/linux-x86/bin/bazel query --config=queryview //hardware/interfaces/compatibility_matrices:"$current_bp_module"--android_common --output=build | grep kernel_configs | sed 's/[^\[]*\[\(.*\)],/\1/' | sed 's/ //g' | sed 's/\"//g') |
| 66 | |
| 67 | $top/out/host/linux-x86/bin/bpmodify -m $final_bp_module -property kernel_configs -a $kernel_configs -w $bp_file |
| 68 | |
| 69 | $top/out/host/linux-x86/bin/bpfmt -w $bp_file |
| 70 | |
| 71 | local make_file=$top/hardware/interfaces/compatibility_matrices/Android.mk |
| 72 | # replace the current compat matrix in the make file with the final one |
| 73 | # the only place this resides is in the conditional addition |
| 74 | sed -i "s/$current_file/$final_file/g" $make_file |
| 75 | # add the current compat matrix to the unconditional addition |
| 76 | sed -i "/^ framework_compatibility_matrix.device.xml/i \ $current_bp_module \\\\" $make_file |
| 77 | } |
| 78 | |
Steven Moreland | 0f84e4b | 2023-12-16 02:51:26 +0000 | [diff] [blame] | 79 | finalize_vintf_resources |
| 80 | |