blob: 212362e039ae12dcb7d8bc0b3ed9913b04a19412 [file] [log] [blame]
sophiez6bde0b52021-01-09 01:03:42 +00001#!/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# Generates NDK API txt file used by Mainline modules. NDK APIs would have value
18# "UND" in Ndx column and have suffix "@LIB_NAME" in Name column.
19# For example, current line llvm-readelf output is:
20# 1: 00000000 0 FUNC GLOBAL DEFAULT UND dlopen@LIBC
21# After the parse function below "dlopen" would be write to the output file.
22printHelp() {
23 echo "**************************** Usage Instructions ****************************"
sophiez9a6eabf2021-10-14 11:54:26 -070024 echo "This script is used to generate the native libraries backed by Mainline modules."
sophiez6bde0b52021-01-09 01:03:42 +000025 echo ""
sophiez9a6eabf2021-10-14 11:54:26 -070026 echo "To run this script use: ./gen_ndk_backed_by_apex.sh \$OUTPUT_FILE_PATH \$MODULE_LIB1 \$MODULE_LIB2..."
Colin Cross69f0a242021-02-08 16:49:57 -080027 echo "For example: If output write to /backedby.txt then the command would be:"
sophiez9a6eabf2021-10-14 11:54:26 -070028 echo "./gen_ndk_backed_by_apex.sh /backedby.txt lib1.so lib2.so"
sophiez6bde0b52021-01-09 01:03:42 +000029 echo "If the module1 is backing lib1 then the backedby.txt would contains: "
sophiez9a6eabf2021-10-14 11:54:26 -070030 echo "lib1.so lib2.so"
sophiez6bde0b52021-01-09 01:03:42 +000031}
32
sophiez9a6eabf2021-10-14 11:54:26 -070033genAllBackedByList() {
Colin Cross69f0a242021-02-08 16:49:57 -080034 out="$1"
35 shift
Colin Cross69f0a242021-02-08 16:49:57 -080036 rm -f "$out"
37 touch "$out"
sophiez9a6eabf2021-10-14 11:54:26 -070038 echo "$@" >> "$out"
sophiez6bde0b52021-01-09 01:03:42 +000039}
40
41if [[ "$1" == "help" ]]
42then
43 printHelp
sophiez9a6eabf2021-10-14 11:54:26 -070044elif [[ "$#" -lt 1 ]]
sophiez6bde0b52021-01-09 01:03:42 +000045then
sophiez9a6eabf2021-10-14 11:54:26 -070046 echo "Wrong argument length. Expecting at least 1 argument representing output path, followed by a list of libraries in the Mainline module."
sophiez6bde0b52021-01-09 01:03:42 +000047else
sophiez9a6eabf2021-10-14 11:54:26 -070048 genAllBackedByList "$@"
sophiez6bde0b52021-01-09 01:03:42 +000049fi