gen_ndk_backedby_apex.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # Generates NDK API txt file used by Mainline modules. NDK APIs would have value
  16. # "UND" in Ndx column and have suffix "@LIB_NAME" in Name column.
  17. # For example, current line llvm-readelf output is:
  18. # 1: 00000000 0 FUNC GLOBAL DEFAULT UND dlopen@LIBC
  19. # After the parse function below "dlopen" would be write to the output file.
  20. printHelp() {
  21. echo "**************************** Usage Instructions ****************************"
  22. echo "This script is used to generate the native libraries backed by Mainline modules."
  23. echo ""
  24. echo "To run this script use: ./gen_ndk_backed_by_apex.sh \$OUTPUT_FILE_PATH \$MODULE_LIB1 \$MODULE_LIB2..."
  25. echo "For example: If output write to /backedby.txt then the command would be:"
  26. echo "./gen_ndk_backed_by_apex.sh /backedby.txt lib1.so lib2.so"
  27. echo "If the module1 is backing lib1 then the backedby.txt would contains: "
  28. echo "lib1.so lib2.so"
  29. }
  30. genAllBackedByList() {
  31. out="$1"
  32. shift
  33. rm -f "$out"
  34. touch "$out"
  35. echo "$@" >> "$out"
  36. }
  37. if [[ "$1" == "help" ]]
  38. then
  39. printHelp
  40. elif [[ "$#" -lt 1 ]]
  41. then
  42. echo "Wrong argument length. Expecting at least 1 argument representing output path, followed by a list of libraries in the Mainline module."
  43. else
  44. genAllBackedByList "$@"
  45. fi