aboutsummaryrefslogtreecommitdiff
path: root/tools/check-flagged-apis/check-flagged-apis.sh
blob: cd37a2d52ea066dd302ae9616ef407564562b06a (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
78
#!/bin/bash

# Copyright (C) 2024 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Run check-flagged-apis for public APIs and the three @SystemApi flavours
# Usage: lunch <your-target> && source <this script>

source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
require_top

function m() {
    $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@"
}

function build() {
    m sdk dist && m \
        check-flagged-apis \
        all_aconfig_declarations \
        frameworks-base-api-current.txt \
        frameworks-base-api-system-current.txt \
        frameworks-base-api-system-server-current.txt \
        frameworks-base-api-module-lib-current.txt
}

function run() {
    local errors=0

    echo "# current"
    check-flagged-apis \
        --api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt \
        --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
        --api-versions $(gettop)/out/dist/data/api-versions.xml
    (( errors += $? ))

    echo
    echo "# system-current"
    check-flagged-apis \
        --api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-system-current.txt_intermediates/frameworks-base-api-system-current.txt \
        --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
        --api-versions $(gettop)/out/dist/system-data/api-versions.xml
    (( errors += $? ))

    echo
    echo "# system-server-current"
    check-flagged-apis \
        --api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-system-server-current.txt_intermediates/frameworks-base-api-system-server-current.txt \
        --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
        --api-versions $(gettop)/out/dist/system-server-data/api-versions.xml
    (( errors += $? ))

    echo
    echo "# module-lib"
    check-flagged-apis \
        --api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-module-lib-current.txt_intermediates/frameworks-base-api-module-lib-current.txt \
        --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
        --api-versions $(gettop)/out/dist/module-lib-data/api-versions.xml
    (( errors += $? ))

    return $errors
}

if [[ "$1" != "--skip-build" ]]; then
    build && run
else
    run
fi