blob: 88645b3ad5537d55a0b75ec751dd5fc6f033ec62 [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
10 # TODO(b/314010177): finalize SELinux
11
Devin Moorea1339af2024-01-11 23:51:22 +000012 create_new_compat_matrix
13
Steven Moreland0f84e4b2023-12-16 02:51:26 +000014 # 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 Moreland0f84e4b2023-12-16 02:51:26 +000020}
21
Devin Moorea1339af2024-01-11 23:51:22 +000022function 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 Moore196c1b52024-01-17 16:40:29 +000025 export CURRENT_COMPATIBILITY_MATRIX_LEVEL='202404'
26 export FINAL_COMPATIBILITY_MATRIX_LEVEL='202504'
Devin Moorea1339af2024-01-11 23:51:22 +000027
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 Moore395d5e32024-01-17 16:47:11 +000064 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 +000065
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 Moreland0f84e4b2023-12-16 02:51:26 +000078finalize_vintf_resources
79