2021-01-09 02:03:42 +01:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# Copyright 2020 Google Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
# Generates NDK API txt file used by Mainline modules. NDK APIs would have value
|
|
|
|
# "UND" in Ndx column and have suffix "@LIB_NAME" in Name column.
|
|
|
|
# For example, current line llvm-readelf output is:
|
|
|
|
# 1: 00000000 0 FUNC GLOBAL DEFAULT UND dlopen@LIBC
|
|
|
|
# After the parse function below "dlopen" would be write to the output file.
|
|
|
|
printHelp() {
|
|
|
|
echo "**************************** Usage Instructions ****************************"
|
2021-10-14 20:54:26 +02:00
|
|
|
echo "This script is used to generate the native libraries backed by Mainline modules."
|
2021-01-09 02:03:42 +01:00
|
|
|
echo ""
|
2021-10-14 20:54:26 +02:00
|
|
|
echo "To run this script use: ./gen_ndk_backed_by_apex.sh \$OUTPUT_FILE_PATH \$MODULE_LIB1 \$MODULE_LIB2..."
|
2021-02-09 01:49:57 +01:00
|
|
|
echo "For example: If output write to /backedby.txt then the command would be:"
|
2021-10-14 20:54:26 +02:00
|
|
|
echo "./gen_ndk_backed_by_apex.sh /backedby.txt lib1.so lib2.so"
|
2021-01-09 02:03:42 +01:00
|
|
|
echo "If the module1 is backing lib1 then the backedby.txt would contains: "
|
2021-10-14 20:54:26 +02:00
|
|
|
echo "lib1.so lib2.so"
|
2021-01-09 02:03:42 +01:00
|
|
|
}
|
|
|
|
|
2021-10-14 20:54:26 +02:00
|
|
|
genAllBackedByList() {
|
2021-02-09 01:49:57 +01:00
|
|
|
out="$1"
|
|
|
|
shift
|
|
|
|
rm -f "$out"
|
|
|
|
touch "$out"
|
2021-10-14 20:54:26 +02:00
|
|
|
echo "$@" >> "$out"
|
2021-01-09 02:03:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$1" == "help" ]]
|
|
|
|
then
|
|
|
|
printHelp
|
2021-10-14 20:54:26 +02:00
|
|
|
elif [[ "$#" -lt 1 ]]
|
2021-01-09 02:03:42 +01:00
|
|
|
then
|
2021-10-14 20:54:26 +02:00
|
|
|
echo "Wrong argument length. Expecting at least 1 argument representing output path, followed by a list of libraries in the Mainline module."
|
2021-01-09 02:03:42 +01:00
|
|
|
else
|
2021-10-14 20:54:26 +02:00
|
|
|
genAllBackedByList "$@"
|
2021-01-09 02:03:42 +01:00
|
|
|
fi
|