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