blob: 8078cd80bfe0c0955abacdbc633808d2387bfb19 [file] [log] [blame]
Michael Wrightc55d79b2024-04-23 17:20:13 +00001#!/bin/bash
2
Mårten Kongstad76460bd2024-04-18 16:11:48 +02003# Copyright (C) 2024 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Mårten Kongstad1692a362024-06-10 16:04:34 +020017# Run check-flagged-apis for public APIs and the three @SystemApi flavours.
18#
19# This script expects an argument to tell it which subcommand of
20# check-flagged-apis to execute. Run the script without any arguments to see
21# the valid options.
22#
23# Remember to lunch to select the relevant release config before running this script.
Mårten Kongstad76460bd2024-04-18 16:11:48 +020024
Michael Wrightc55d79b2024-04-23 17:20:13 +000025source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
26require_top
27
Mårten Kongstad22063d02024-05-03 09:53:22 +020028PUBLIC_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_public_generated-api-versions.xml
29SYSTEM_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_system_generated-api-versions.xml
Paul Duffin771a2012024-05-03 12:13:32 +010030SYSTEM_SERVER_XML_VERSONS=out/target/common/obj/PACKAGING/api_versions_system_server_complete_generated-api-versions.xml
31MODULE_LIB_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_module_lib_complete_generated-api-versions.xml
Mårten Kongstad22063d02024-05-03 09:53:22 +020032
Michael Wrightc55d79b2024-04-23 17:20:13 +000033function m() {
34 $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@"
35}
36
Mårten Kongstad76460bd2024-04-18 16:11:48 +020037function build() {
Mårten Kongstad22063d02024-05-03 09:53:22 +020038 m \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020039 check-flagged-apis \
40 all_aconfig_declarations \
41 frameworks-base-api-current.txt \
42 frameworks-base-api-system-current.txt \
43 frameworks-base-api-system-server-current.txt \
Mårten Kongstad22063d02024-05-03 09:53:22 +020044 frameworks-base-api-module-lib-current.txt \
45 $PUBLIC_XML_VERSIONS \
46 $SYSTEM_XML_VERSIONS \
47 $SYSTEM_SERVER_XML_VERSONS \
48 $MODULE_LIB_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020049}
50
Mårten Kongstad1692a362024-06-10 16:04:34 +020051function noop() {
52 true
53}
54
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020055function aninja() {
56 local T="$(gettop)"
57 (\cd "${T}" && prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@")
58}
59
60function path_to_api_signature_file {
61 aninja -t query device_"$1"_all_targets | grep -A1 -e input: | tail -n1
62}
63
Mårten Kongstad1692a362024-06-10 16:04:34 +020064function run_check() {
Mårten Kongstad76460bd2024-04-18 16:11:48 +020065 local errors=0
66
67 echo "# current"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020068 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020069 --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020070 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020071 --api-versions $PUBLIC_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020072 (( errors += $? ))
73
74 echo
75 echo "# system-current"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020076 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020077 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020078 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020079 --api-versions $SYSTEM_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020080 (( errors += $? ))
81
82 echo
83 echo "# system-server-current"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020084 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020085 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020086 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020087 --api-versions $SYSTEM_SERVER_XML_VERSONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020088 (( errors += $? ))
89
90 echo
91 echo "# module-lib"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020092 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020093 --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020094 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020095 --api-versions $MODULE_LIB_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020096 (( errors += $? ))
97
98 return $errors
99}
100
Mårten Kongstad1692a362024-06-10 16:04:34 +0200101function run_list() {
102 echo "# current"
103 check-flagged-apis list \
104 --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
105 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
106
107 echo
108 echo "# system-current"
109 check-flagged-apis list \
110 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
111 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
112
113 echo
114 echo "# system-server-current"
115 check-flagged-apis list \
116 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
117 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
118
119 echo
120 echo "# module-lib"
121 check-flagged-apis list \
122 --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
123 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
124}
125
126build_cmd=build
127if [[ "$1" == "--skip-build" ]]; then
128 build_cmd=noop
129 shift 1
Mårten Kongstad76460bd2024-04-18 16:11:48 +0200130fi
Mårten Kongstad1692a362024-06-10 16:04:34 +0200131
132case "$1" in
133 check) $build_cmd && run_check ;;
134 list) $build_cmd && run_list ;;
135 *) echo "usage: $(basename $0): [--skip-build] check|list"; exit 1
136esac