summaryrefslogtreecommitdiff
path: root/tools/finalization/finalize-vintf-resources.sh
blob: 9660e3fc8ca1faf23a4e53d18d9f3e2d51f70614 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash

set -ex

function finalize_vintf_resources() {
    if [ $# -gt 1 ]; then
        echo "No argument or '--steps_for_build_test_only' is allowed"
        exit 1
    fi
    if [ $# -eq 1 ]; then
        if [ "$1" == "--steps_for_build_test_only" ]; then
            echo "This is only to verify building a target."
            echo "Skip LLNDK ABI dump and VINTF check."
            local build_test_only=true
        else
            echo "Unknown argument $1"
            exit 1
        fi
    fi

    local top="$(dirname "$0")"/../../../..
    source $top/build/make/tools/finalization/environment.sh
    # environment needed to build dependencies and run scripts
    # These should remain the same for all steps here to speed up build time
    export ANDROID_BUILD_TOP="$top"
    export ANDROID_HOST_OUT="$ANDROID_BUILD_TOP/out/host/linux-x86"
    export ANDROID_PRODUCT_OUT="$ANDROID_BUILD_TOP/out/target/product/generic_arm64"
    export PATH="$PATH:$ANDROID_HOST_OUT/bin/"
    export TARGET_BUILD_VARIANT=userdebug
    export DIST_DIR=out/dist
    export TARGET_RELEASE=fina_0
    export TARGET_PRODUCT=aosp_arm64

    # build/soong
    local vendor_api_level_map="case ${FINAL_NEXT_BOARD_API_LEVEL}:"
    if ! grep -q "$vendor_api_level_map" "$top/build/soong/android/vendor_api_levels.go" ; then
        sed -i -e "/case ${FINAL_BOARD_API_LEVEL}:/{N;a \\\t$vendor_api_level_map\n\t\tsdkVersion = ${FINAL_NEXT_CORRESPONDING_SDK_VERSION}
        }" "$top/build/soong/android/vendor_api_levels.go"
    fi

    # system/sepolicy
    "$top/system/sepolicy/tools/finalize-vintf-resources.sh" "$top" "$FINAL_BOARD_API_LEVEL"

    local aidl_m="$top/build/soong/soong_ui.bash --make-mode"
    AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api create_reference_dumps

    finalize_compat_matrix $build_test_only

    if ! [ "$build_test_only" = "true" ]; then
        # Generate LLNDK ABI dumps
        # This command depends on ANDROID_BUILD_TOP
        "$ANDROID_HOST_OUT/bin/create_reference_dumps" -release "$TARGET_RELEASE" --build-variant "$TARGET_BUILD_VARIANT" --lib-variant LLNDK
    fi
}

function finalize_compat_matrix() {
    local build_test_only=$1
    local CURRENT_COMPATIBILITY_MATRIX_LEVEL="$FINAL_BOARD_API_LEVEL"

    "$top/prebuilts/build-tools/path/linux-x86/python3" "$top/hardware/interfaces/compatibility_matrices/finalize.py" "$CURRENT_COMPATIBILITY_MATRIX_LEVEL"

    if ! [ "$build_test_only" = "true" ]; then
        # Freeze the current framework manifest file. This relies on the
        # interfaces already being frozen because we are building with fina_0 which
        # inherits from `next` where RELEASE_AIDL_USE_UNFROZEN=false
        "$top/system/libhidl/vintfdata/freeze.sh" "$CURRENT_COMPATIBILITY_MATRIX_LEVEL"
    fi
}

function freeze_framework_manifest() {
   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

}


finalize_vintf_resources $@