blob: dad1236f71c422932249b3d068c15435f293e68b [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
Mårten Kongstad22063d02024-05-03 09:53:22 +020023PUBLIC_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_public_generated-api-versions.xml
24SYSTEM_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_system_generated-api-versions.xml
Paul Duffin771a2012024-05-03 12:13:32 +010025SYSTEM_SERVER_XML_VERSONS=out/target/common/obj/PACKAGING/api_versions_system_server_complete_generated-api-versions.xml
26MODULE_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 +020027
Michael Wrightc55d79b2024-04-23 17:20:13 +000028function m() {
29 $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@"
30}
31
Mårten Kongstad76460bd2024-04-18 16:11:48 +020032function build() {
Mårten Kongstad22063d02024-05-03 09:53:22 +020033 m \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020034 check-flagged-apis \
35 all_aconfig_declarations \
36 frameworks-base-api-current.txt \
37 frameworks-base-api-system-current.txt \
38 frameworks-base-api-system-server-current.txt \
Mårten Kongstad22063d02024-05-03 09:53:22 +020039 frameworks-base-api-module-lib-current.txt \
40 $PUBLIC_XML_VERSIONS \
41 $SYSTEM_XML_VERSIONS \
42 $SYSTEM_SERVER_XML_VERSONS \
43 $MODULE_LIB_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020044}
45
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020046function aninja() {
47 local T="$(gettop)"
48 (\cd "${T}" && prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@")
49}
50
51function path_to_api_signature_file {
52 aninja -t query device_"$1"_all_targets | grep -A1 -e input: | tail -n1
53}
54
Mårten Kongstad76460bd2024-04-18 16:11:48 +020055function run() {
56 local errors=0
57
58 echo "# current"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020059 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020060 --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020061 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020062 --api-versions $PUBLIC_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020063 (( errors += $? ))
64
65 echo
66 echo "# system-current"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020067 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020068 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020069 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020070 --api-versions $SYSTEM_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020071 (( errors += $? ))
72
73 echo
74 echo "# system-server-current"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020075 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020076 --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020077 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020078 --api-versions $SYSTEM_SERVER_XML_VERSONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020079 (( errors += $? ))
80
81 echo
82 echo "# module-lib"
Mårten Kongstadd5ce20f2024-06-10 13:59:46 +020083 check-flagged-apis check \
Mårten Kongstadb9ce4c92024-05-02 10:51:30 +020084 --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
Mårten Kongstad76460bd2024-04-18 16:11:48 +020085 --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
Mårten Kongstad22063d02024-05-03 09:53:22 +020086 --api-versions $MODULE_LIB_XML_VERSIONS
Mårten Kongstad76460bd2024-04-18 16:11:48 +020087 (( errors += $? ))
88
89 return $errors
90}
91
92if [[ "$1" != "--skip-build" ]]; then
93 build && run
94else
95 run
96fi