Michael Wright | c55d79b | 2024-04-23 17:20:13 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 3 | # 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 Wright | c55d79b | 2024-04-23 17:20:13 +0000 | [diff] [blame] | 20 | source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh |
| 21 | require_top |
| 22 | |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 23 | PUBLIC_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_public_generated-api-versions.xml |
| 24 | SYSTEM_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_system_generated-api-versions.xml |
Paul Duffin | 771a201 | 2024-05-03 12:13:32 +0100 | [diff] [blame] | 25 | SYSTEM_SERVER_XML_VERSONS=out/target/common/obj/PACKAGING/api_versions_system_server_complete_generated-api-versions.xml |
| 26 | MODULE_LIB_XML_VERSIONS=out/target/common/obj/PACKAGING/api_versions_module_lib_complete_generated-api-versions.xml |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 27 | |
Michael Wright | c55d79b | 2024-04-23 17:20:13 +0000 | [diff] [blame] | 28 | function m() { |
| 29 | $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@" |
| 30 | } |
| 31 | |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 32 | function build() { |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 33 | m \ |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 34 | 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 Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 39 | 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 Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 44 | } |
| 45 | |
Mårten Kongstad | b9ce4c9 | 2024-05-02 10:51:30 +0200 | [diff] [blame] | 46 | function aninja() { |
| 47 | local T="$(gettop)" |
| 48 | (\cd "${T}" && prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@") |
| 49 | } |
| 50 | |
| 51 | function path_to_api_signature_file { |
| 52 | aninja -t query device_"$1"_all_targets | grep -A1 -e input: | tail -n1 |
| 53 | } |
| 54 | |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 55 | function run() { |
| 56 | local errors=0 |
| 57 | |
| 58 | echo "# current" |
Mårten Kongstad | d5ce20f | 2024-06-10 13:59:46 +0200 | [diff] [blame^] | 59 | check-flagged-apis check \ |
Mårten Kongstad | b9ce4c9 | 2024-05-02 10:51:30 +0200 | [diff] [blame] | 60 | --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \ |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 61 | --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \ |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 62 | --api-versions $PUBLIC_XML_VERSIONS |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 63 | (( errors += $? )) |
| 64 | |
| 65 | echo |
| 66 | echo "# system-current" |
Mårten Kongstad | d5ce20f | 2024-06-10 13:59:46 +0200 | [diff] [blame^] | 67 | check-flagged-apis check \ |
Mårten Kongstad | b9ce4c9 | 2024-05-02 10:51:30 +0200 | [diff] [blame] | 68 | --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \ |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 69 | --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \ |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 70 | --api-versions $SYSTEM_XML_VERSIONS |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 71 | (( errors += $? )) |
| 72 | |
| 73 | echo |
| 74 | echo "# system-server-current" |
Mårten Kongstad | d5ce20f | 2024-06-10 13:59:46 +0200 | [diff] [blame^] | 75 | check-flagged-apis check \ |
Mårten Kongstad | b9ce4c9 | 2024-05-02 10:51:30 +0200 | [diff] [blame] | 76 | --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \ |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 77 | --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \ |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 78 | --api-versions $SYSTEM_SERVER_XML_VERSONS |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 79 | (( errors += $? )) |
| 80 | |
| 81 | echo |
| 82 | echo "# module-lib" |
Mårten Kongstad | d5ce20f | 2024-06-10 13:59:46 +0200 | [diff] [blame^] | 83 | check-flagged-apis check \ |
Mårten Kongstad | b9ce4c9 | 2024-05-02 10:51:30 +0200 | [diff] [blame] | 84 | --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \ |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 85 | --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \ |
Mårten Kongstad | 22063d0 | 2024-05-03 09:53:22 +0200 | [diff] [blame] | 86 | --api-versions $MODULE_LIB_XML_VERSIONS |
Mårten Kongstad | 76460bd | 2024-04-18 16:11:48 +0200 | [diff] [blame] | 87 | (( errors += $? )) |
| 88 | |
| 89 | return $errors |
| 90 | } |
| 91 | |
| 92 | if [[ "$1" != "--skip-build" ]]; then |
| 93 | build && run |
| 94 | else |
| 95 | run |
| 96 | fi |