Tudor Magirescu | 9f5ec62 | 2024-08-30 10:45:40 +0000 | [diff] [blame^] | 1 | # |
| 2 | # Copyright (C) 2024 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | # Create a directory for the results and a nested temporary directory. |
| 18 | mkdir -p $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/tmp |
| 19 | |
| 20 | # Create a copy of `AndroidGlobalLintChecker.jar` to restore it afterwards. |
| 21 | cp $ANDROID_BUILD_TOP/prebuilts/cmdline-tools/AndroidGlobalLintChecker.jar \ |
| 22 | $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/AndroidGlobalLintChecker.jar |
| 23 | |
| 24 | # Configure the environment variable required for running the lint check on the entire source tree. |
| 25 | export ANDROID_LINT_CHECK=PermissionAnnotationExemptAidlInterfaces |
| 26 | |
| 27 | # Build the target corresponding to the lint checks present in the `utils` directory. |
| 28 | m AndroidUtilsLintChecker |
| 29 | |
| 30 | # Replace `AndroidGlobalLintChecker.jar` with the newly built `jar` file. |
| 31 | cp $ANDROID_BUILD_TOP/out/host/linux-x86/framework/AndroidUtilsLintChecker.jar \ |
| 32 | $ANDROID_BUILD_TOP/prebuilts/cmdline-tools/AndroidGlobalLintChecker.jar; |
| 33 | |
| 34 | # Run the lint check on the entire source tree. |
| 35 | m lint-check |
| 36 | |
| 37 | # Copy the archive containing the results of `lint-check` into the temporary directory. |
| 38 | cp $ANDROID_BUILD_TOP/out/soong/lint-report-text.zip \ |
| 39 | $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/tmp |
| 40 | |
| 41 | cd $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/tmp |
| 42 | |
| 43 | # Unzip the archive containing the results of `lint-check`. |
| 44 | unzip lint-report-text.zip |
| 45 | |
| 46 | # Concatenate the results of `lint-check` into a single string. |
| 47 | concatenated_reports=$(find . -type f | xargs cat) |
| 48 | |
| 49 | # Extract the fully qualified names of the AIDL Interfaces from the concatenated results. Output |
| 50 | # this list into `out/soong/exempt_aidl_interfaces_generator_output/exempt_aidl_interfaces`. |
| 51 | echo $concatenated_reports | grep -Eo '\"([a-zA-Z0-9_]*\.)+[a-zA-Z0-9_]*\",' | sort | uniq > ../exempt_aidl_interfaces |
| 52 | |
| 53 | # Remove the temporary directory. |
| 54 | rm -rf $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/tmp |
| 55 | |
| 56 | # Restore the original copy of `AndroidGlobalLintChecker.jar` and delete the copy. |
| 57 | cp $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/AndroidGlobalLintChecker.jar \ |
| 58 | $ANDROID_BUILD_TOP/prebuilts/cmdline-tools/AndroidGlobalLintChecker.jar |
| 59 | rm $ANDROID_BUILD_TOP/out/soong/exempt_aidl_interfaces_generator_output/AndroidGlobalLintChecker.jar |