blob: 362d9f7ed410c9077e14ef0caf1fc5b364c975b5 [file] [log] [blame]
Steven Moreland0f84e4b2023-12-16 02:51:26 +00001#!/bin/bash
2
3set -ex
4
5function 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
Inseob Kim9d5066b2024-01-19 21:28:09 +090010
11 # system/sepolicy
12 system/sepolicy/tools/finalize-vintf-resources.sh "$top" "$FINAL_BOARD_API_LEVEL"
Steven Moreland0f84e4b2023-12-16 02:51:26 +000013
Devin Moorea1339af2024-01-11 23:51:22 +000014 create_new_compat_matrix
15
Steven Moreland0f84e4b2023-12-16 02:51:26 +000016 # pre-finalization build target (trunk)
17 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"
18 AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api
Steven Moreland0f84e4b2023-12-16 02:51:26 +000019}
20
Devin Moorea1339af2024-01-11 23:51:22 +000021function create_new_compat_matrix() {
22 # The compatibility matrix versions are bumped during vFRC
23 # These will change every time we have a new vFRC
Devin Moore196c1b52024-01-17 16:40:29 +000024 export CURRENT_COMPATIBILITY_MATRIX_LEVEL='202404'
25 export FINAL_COMPATIBILITY_MATRIX_LEVEL='202504'
Devin Moorea1339af2024-01-11 23:51:22 +000026
27 local top="$(dirname "$0")"/../../../..
28 source $top/build/make/tools/finalization/environment.sh
29
30 local current_file=compatibility_matrix."$CURRENT_COMPATIBILITY_MATRIX_LEVEL".xml
31 local final_file=compatibility_matrix."$FINAL_COMPATIBILITY_MATRIX_LEVEL".xml
32 local current_bp_module=framework_$current_file
33 local final_bp_module=framework_$final_file
34 local src=$top/hardware/interfaces/compatibility_matrices/$current_file
35 local dest=$top/hardware/interfaces/compatibility_matrices/$final_file
36 local bp_file=$top/hardware/interfaces/compatibility_matrices/Android.bp
37
38 # check to see if this script needs to be run
39 if grep -q $final_bp_module $bp_file; then
40 echo "Nothing to do because the new module exists"
41 return
42 fi
43
44 # build the targets required before touching the Android.bp/Android.mk files
45 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"
46 $build_cmd bpfmt
47 $build_cmd bpmodify
48 $build_cmd queryview
49
50 # create the new file and modify the level
51 sed "s/level=\""$CURRENT_COMPATIBILITY_MATRIX_LEVEL"\"/level=\""$FINAL_COMPATIBILITY_MATRIX_LEVEL"\"/" "$src" > "$dest"
52
53 echo "
54 vintf_compatibility_matrix {
55 name: \"$final_bp_module\",
56 stem: \"$final_file\",
57 srcs: [
58 \"$final_file\",
59 ],
60 }" >> $bp_file
61
62 # get the previous kernel_configs properties and add them to the new module
Devin Moore395d5e32024-01-17 16:47:11 +000063 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 Moorea1339af2024-01-11 23:51:22 +000064
65 $top/out/host/linux-x86/bin/bpmodify -m $final_bp_module -property kernel_configs -a $kernel_configs -w $bp_file
66
67 $top/out/host/linux-x86/bin/bpfmt -w $bp_file
68
69 local make_file=$top/hardware/interfaces/compatibility_matrices/Android.mk
70 # replace the current compat matrix in the make file with the final one
71 # the only place this resides is in the conditional addition
72 sed -i "s/$current_file/$final_file/g" $make_file
73 # add the current compat matrix to the unconditional addition
74 sed -i "/^ framework_compatibility_matrix.device.xml/i \ $current_bp_module \\\\" $make_file
75}
76
Steven Moreland0f84e4b2023-12-16 02:51:26 +000077finalize_vintf_resources
78