gen_java_usedby_apex.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash -e
  2. # Copyright 2020 Google Inc. All rights reserved.
  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. printHelp() {
  16. echo "**************************** Usage Instructions ****************************"
  17. echo "This script is used to generate the Mainline modules used-by Java symbols."
  18. echo ""
  19. echo "To run this script use: ./gen_java_usedby_apex.sh \$BINARY_DEXDEPS_PATH \$OUTPUT_FILE_PATH \$JAR_AND_APK_LIST"
  20. 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:"
  21. echo "./gen_java_usedby_apex.sh \$BINARY_DEXDEPS_PATH /myModule.txt /myJar.jar /myApk.apk"
  22. }
  23. genUsedByList() {
  24. dexdeps="$1"
  25. shift
  26. out="$1"
  27. shift
  28. rm -f "$out"
  29. touch "$out"
  30. echo "<externals>" >> "$out"
  31. for x in "$@"; do
  32. "$dexdeps" "$x" >> "$out" || echo "</external>" >> "$out"
  33. done
  34. echo "</externals>" >> "$out"
  35. }
  36. if [[ "$1" == "help" ]]
  37. then
  38. printHelp
  39. elif [[ "$#" -lt 2 ]]
  40. then
  41. 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."
  42. else
  43. genUsedByList "$@"
  44. fi