| sophiez | 0234737 | 2021-11-02 17:58:02 -0700 | [diff] [blame] | 1 | #!/bin/bash -e | 
|  | 2 |  | 
|  | 3 | # Copyright 2020 Google Inc. All rights reserved. | 
|  | 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 | printHelp() { | 
|  | 18 | echo "**************************** Usage Instructions ****************************" | 
|  | 19 | echo "This script is used to generate the Mainline modules used-by Java symbols." | 
|  | 20 | echo "" | 
|  | 21 | echo "To run this script use: ./gen_java_usedby_apex.sh \$BINARY_DEXDEPS_PATH \$OUTPUT_FILE_PATH \$JAR_AND_APK_LIST" | 
|  | 22 | echo "For example: If all jar and apk files are '/myJar.jar /myApk.apk' and output write to /myModule.txt then the command would be:" | 
|  | 23 | echo "./gen_java_usedby_apex.sh \$BINARY_DEXDEPS_PATH /myModule.txt /myJar.jar /myApk.apk" | 
|  | 24 | } | 
|  | 25 |  | 
|  | 26 | genUsedByList() { | 
|  | 27 | dexdeps="$1" | 
|  | 28 | shift | 
|  | 29 | out="$1" | 
|  | 30 | shift | 
|  | 31 | rm -f "$out" | 
|  | 32 | touch "$out" | 
| sophiez | 65a9815 | 2021-12-10 13:43:04 -0800 | [diff] [blame] | 33 | echo "<externals>" >> "$out" | 
| sophiez | 0234737 | 2021-11-02 17:58:02 -0700 | [diff] [blame] | 34 | for x in "$@"; do | 
| sophiez | bc82ba5 | 2021-12-14 14:01:17 -0800 | [diff] [blame] | 35 | "$dexdeps" "$x" >> "$out" || echo "</external>" >> "$out" | 
| sophiez | 0234737 | 2021-11-02 17:58:02 -0700 | [diff] [blame] | 36 | done | 
| sophiez | 65a9815 | 2021-12-10 13:43:04 -0800 | [diff] [blame] | 37 | echo "</externals>" >> "$out" | 
| sophiez | 0234737 | 2021-11-02 17:58:02 -0700 | [diff] [blame] | 38 | } | 
|  | 39 |  | 
|  | 40 | if [[ "$1" == "help" ]] | 
|  | 41 | then | 
|  | 42 | printHelp | 
|  | 43 | elif [[ "$#" -lt 2 ]] | 
|  | 44 | then | 
|  | 45 | echo "Wrong argument length. Expecting at least 2 argument representing dexdeps path, output path, followed by a list of jar or apk files in the Mainline module." | 
|  | 46 | else | 
|  | 47 | genUsedByList "$@" | 
|  | 48 | fi |