blob: e3985414b4fa6164d0b2e196e5ae66e8b9920f18 [file] [log] [blame]
sophiez02347372021-11-02 17:58:02 -07001#!/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
17printHelp() {
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
26genUsedByList() {
27 dexdeps="$1"
28 shift
29 out="$1"
30 shift
31 rm -f "$out"
32 touch "$out"
sophiez65a98152021-12-10 13:43:04 -080033 echo "<externals>" >> "$out"
sophiez02347372021-11-02 17:58:02 -070034 for x in "$@"; do
sophiezbc82ba52021-12-14 14:01:17 -080035 "$dexdeps" "$x" >> "$out" || echo "</external>" >> "$out"
sophiez02347372021-11-02 17:58:02 -070036 done
sophiez65a98152021-12-10 13:43:04 -080037 echo "</externals>" >> "$out"
sophiez02347372021-11-02 17:58:02 -070038}
39
40if [[ "$1" == "help" ]]
41then
42 printHelp
43elif [[ "$#" -lt 2 ]]
44then
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."
46else
47 genUsedByList "$@"
48fi