blob: 3399583a71c68f62cf30bbf6b9b4a7868e2b1fd7 [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
17# Run check-flagged-apis for public APIs and the three @SystemApi flavours
18# Usage: lunch <your-target> && source <this script>
19
Michael Wrightc55d79b2024-04-23 17:20:13 +000020source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
21require_top
22
23function m() {
24 $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@"
25}
26
Mårten Kongstad76460bd2024-04-18 16:11:48 +020027function build() {
28 m sdk dist && m \
29 check-flagged-apis \
30 all_aconfig_declarations \
31 frameworks-base-api-current.txt \
32 frameworks-base-api-system-current.txt \
33 frameworks-base-api-system-server-current.txt \
34 frameworks-base-api-module-lib-current.txt
35}
36
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020037function aninja() {
38 local T="$(gettop)"
39 (\cd "${T}" && prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@")
40}
41
42function path_to_api_signature_file {
43 aninja -t query device_"$1"_all_targets | grep -A1 -e input: | tail -n1
44}
45
Mårten Kongstad76460bd2024-04-18 16:11:48 +020046function run() {
47 local errors=0
48
49 echo "# current"
50 check-flagged-apis \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020051 --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020052 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
53 --api-versions $(gettop)/out/dist/data/api-versions.xml
54 (( errors += $? ))
55
56 echo
57 echo "# system-current"
58 check-flagged-apis \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020059 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020060 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
61 --api-versions $(gettop)/out/dist/system-data/api-versions.xml
62 (( errors += $? ))
63
64 echo
65 echo "# system-server-current"
66 check-flagged-apis \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020067 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020068 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
69 --api-versions $(gettop)/out/dist/system-server-data/api-versions.xml
70 (( errors += $? ))
71
72 echo
73 echo "# module-lib"
74 check-flagged-apis \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020075 --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020076 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
77 --api-versions $(gettop)/out/dist/module-lib-data/api-versions.xml
78 (( errors += $? ))
79
80 return $errors
81}
82
83if [[ "$1" != "--skip-build" ]]; then
84 build && run
85else
86 run
87fi