summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-aml-prebuilts.sh16
-rwxr-xr-xscripts/build-mainline-modules.sh9
-rwxr-xr-xscripts/build-ndk-prebuilts.sh9
-rw-r--r--scripts/conv_linker_config.py88
-rwxr-xr-xscripts/gen_ndk_usedby_apex.sh72
5 files changed, 188 insertions, 6 deletions
diff --git a/scripts/build-aml-prebuilts.sh b/scripts/build-aml-prebuilts.sh
index 0c868ea11..1be3b8afe 100755
--- a/scripts/build-aml-prebuilts.sh
+++ b/scripts/build-aml-prebuilts.sh
@@ -54,6 +54,11 @@ PLATFORM_VERSION_ALL_CODENAMES="$(my_get_build_var PLATFORM_VERSION_ALL_CODENAME
PLATFORM_VERSION_ALL_CODENAMES="${PLATFORM_VERSION_ALL_CODENAMES/,/'","'}"
PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]"
+# Get the list of missing <uses-library> modules and convert it to a JSON array
+# (quote module names, add comma separator and wrap in brackets).
+MISSING_USES_LIBRARIES="$(my_get_build_var INTERNAL_PLATFORM_MISSING_USES_LIBRARIES)"
+MISSING_USES_LIBRARIES="[$(echo $MISSING_USES_LIBRARIES | sed -e 's/\([^ ]\+\)/\"\1\"/g' -e 's/[ ]\+/, /g')]"
+
# Logic from build/make/core/goma.mk
if [ "${USE_GOMA}" = true ]; then
if [ -n "${GOMA_DIR}" ]; then
@@ -81,6 +86,7 @@ cat > ${SOONG_VARS}.new << EOF
{
"BuildNumberFile": "build_number.txt",
+ "Platform_version_name": "${PLATFORM_VERSION}",
"Platform_sdk_version": ${PLATFORM_SDK_VERSION},
"Platform_sdk_codename": "${PLATFORM_VERSION}",
"Platform_version_active_codenames": ${PLATFORM_VERSION_ALL_CODENAMES},
@@ -94,7 +100,15 @@ cat > ${SOONG_VARS}.new << EOF
"Allow_missing_dependencies": ${SOONG_ALLOW_MISSING_DEPENDENCIES:-false},
"Unbundled_build": ${TARGET_BUILD_UNBUNDLED:-false},
- "UseGoma": ${USE_GOMA}
+ "UseGoma": ${USE_GOMA},
+
+ "VendorVars": {
+ "art_module": {
+ "source_build": "${ENABLE_ART_SOURCE_BUILD:-false}"
+ }
+ },
+
+ "MissingUsesLibraries": ${MISSING_USES_LIBRARIES}
}
EOF
diff --git a/scripts/build-mainline-modules.sh b/scripts/build-mainline-modules.sh
index b8dd7aaa5..6db870f5a 100755
--- a/scripts/build-mainline-modules.sh
+++ b/scripts/build-mainline-modules.sh
@@ -16,15 +16,16 @@ MAINLINE_MODULES=(
MODULES_SDK_AND_EXPORTS=(
art-module-sdk
art-module-test-exports
+ conscrypt-module-host-exports
conscrypt-module-sdk
conscrypt-module-test-exports
- conscrypt-module-host-exports
- runtime-module-sdk
- runtime-module-host-exports
- i18n-module-test-exports
+ i18n-module-host-exports
i18n-module-sdk
+ i18n-module-test-exports
platform-mainline-sdk
platform-mainline-test-exports
+ runtime-module-host-exports
+ runtime-module-sdk
)
# List of libraries installed on the platform that are needed for ART chroot
diff --git a/scripts/build-ndk-prebuilts.sh b/scripts/build-ndk-prebuilts.sh
index b6ed65940..1a3321900 100755
--- a/scripts/build-ndk-prebuilts.sh
+++ b/scripts/build-ndk-prebuilts.sh
@@ -30,6 +30,11 @@ PLATFORM_VERSION_ALL_CODENAMES=$(get_build_var PLATFORM_VERSION_ALL_CODENAMES)
PLATFORM_VERSION_ALL_CODENAMES=${PLATFORM_VERSION_ALL_CODENAMES/,/'","'}
PLATFORM_VERSION_ALL_CODENAMES="[\"${PLATFORM_VERSION_ALL_CODENAMES}\"]"
+# Get the list of missing <uses-library> modules and convert it to a JSON array
+# (quote module names, add comma separator and wrap in brackets).
+MISSING_USES_LIBRARIES="$(get_build_var INTERNAL_PLATFORM_MISSING_USES_LIBRARIES)"
+MISSING_USES_LIBRARIES="[$(echo $MISSING_USES_LIBRARIES | sed -e 's/\([^ ]\+\)/\"\1\"/g' -e 's/[ ]\+/, /g')]"
+
SOONG_OUT=${OUT_DIR}/soong
SOONG_NDK_OUT=${OUT_DIR}/soong/ndk
rm -rf ${SOONG_OUT}
@@ -49,7 +54,9 @@ cat > ${SOONG_OUT}/soong.variables << EOF
"Safestack": false,
"Ndk_abis": true,
- "Exclude_draft_ndk_apis": true
+ "Exclude_draft_ndk_apis": true,
+
+ "MissingUsesLibraries": ${MISSING_USES_LIBRARIES}
}
EOF
m --skip-make ${SOONG_OUT}/ndk.timestamp
diff --git a/scripts/conv_linker_config.py b/scripts/conv_linker_config.py
index 81425fb35..22fe9f671 100644
--- a/scripts/conv_linker_config.py
+++ b/scripts/conv_linker_config.py
@@ -18,8 +18,10 @@
import argparse
import collections
import json
+import os
import linker_config_pb2
+from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.json_format import ParseDict
from google.protobuf.text_format import MessageToString
@@ -43,6 +45,40 @@ def Print(args):
print(MessageToString(pb))
+def SystemProvide(args):
+ pb = linker_config_pb2.LinkerConfig()
+ with open(args.source, 'rb') as f:
+ pb.ParseFromString(f.read())
+ libraries = args.value.split()
+
+ def IsInLibPath(lib_name):
+ lib_path = os.path.join(args.system, 'lib', lib_name)
+ lib64_path = os.path.join(args.system, 'lib64', lib_name)
+ return os.path.exists(lib_path) or os.path.islink(lib_path) or os.path.exists(lib64_path) or os.path.islink(lib64_path)
+
+ installed_libraries = list(filter(IsInLibPath, libraries))
+ for item in installed_libraries:
+ if item not in getattr(pb, 'provideLibs'):
+ getattr(pb, 'provideLibs').append(item)
+ with open(args.output, 'wb') as f:
+ f.write(pb.SerializeToString())
+
+
+def Append(args):
+ pb = linker_config_pb2.LinkerConfig()
+ with open(args.source, 'rb') as f:
+ pb.ParseFromString(f.read())
+
+ if getattr(type(pb), args.key).DESCRIPTOR.label == FieldDescriptor.LABEL_REPEATED:
+ for value in args.value.split():
+ getattr(pb, args.key).append(value)
+ else:
+ setattr(pb, args.key, args.value)
+
+ with open(args.output, 'wb') as f:
+ f.write(pb.SerializeToString())
+
+
def GetArgParser():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
@@ -73,6 +109,58 @@ def GetArgParser():
help='Source linker configuration file in protobuf.')
print_proto.set_defaults(func=Print)
+ system_provide_libs = subparsers.add_parser(
+ 'systemprovide', help='Append system provide libraries into the configuration.')
+ system_provide_libs.add_argument(
+ '-s',
+ '--source',
+ required=True,
+ type=str,
+ help='Source linker configuration file in protobuf.')
+ system_provide_libs.add_argument(
+ '-o',
+ '--output',
+ required=True,
+ type=str,
+ help='Target linker configuration file to write in protobuf.')
+ system_provide_libs.add_argument(
+ '--value',
+ required=True,
+ type=str,
+ help='Values of the libraries to append. If there are more than one it should be separated by empty space')
+ system_provide_libs.add_argument(
+ '--system',
+ required=True,
+ type=str,
+ help='Path of the system image.')
+ system_provide_libs.set_defaults(func=SystemProvide)
+
+ append = subparsers.add_parser(
+ 'append', help='Append value(s) to given key.')
+ append.add_argument(
+ '-s',
+ '--source',
+ required=True,
+ type=str,
+ help='Source linker configuration file in protobuf.')
+ append.add_argument(
+ '-o',
+ '--output',
+ required=True,
+ type=str,
+ help='Target linker configuration file to write in protobuf.')
+ append.add_argument(
+ '--key',
+ required=True,
+ type=str,
+ help='.')
+ append.add_argument(
+ '--value',
+ required=True,
+ type=str,
+ help='Values of the libraries to append. If there are more than one it should be separated by empty space')
+ append.set_defaults(func=Append)
+
return parser
diff --git a/scripts/gen_ndk_usedby_apex.sh b/scripts/gen_ndk_usedby_apex.sh
new file mode 100755
index 000000000..f143161da
--- /dev/null
+++ b/scripts/gen_ndk_usedby_apex.sh
@@ -0,0 +1,72 @@
+#!/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 ****************************"
+ echo "This script is used to generate the Mainline modules used-by NDK symbols."
+ echo ""
+ echo "To run this script use: ./ndk_usedby_module.sh \$BINARY_IMAGE_DIRECTORY \$BINARY_LLVM_PATH \$OUTPUT_FILE_PATH"
+ echo "For example: If all the module image files that you would like to run is under directory '/myModule' and output write to /myModule.txt then the command would be:"
+ echo "./ndk_usedby_module.sh /myModule \$BINARY_LLVM_PATH /myModule.txt"
+}
+
+parseReadelfOutput() {
+ while IFS= read -r line
+ do
+ if [[ $line = *FUNC*GLOBAL*UND*@* ]] ;
+ then
+ echo "$line" | sed -r 's/.*UND (.*)@.*/\1/g' >> "$2"
+ fi
+ done < "$1"
+ echo "" >> "$2"
+}
+
+unzipJarAndApk() {
+ tmpUnzippedDir="$1"/tmpUnzipped
+ [[ -e "$tmpUnzippedDir" ]] && rm -rf "$tmpUnzippedDir"
+ mkdir -p "$tmpUnzippedDir"
+ find "$1" -name "*.jar" -exec unzip -o {} -d "$tmpUnzippedDir" \;
+ find "$1" -name "*.apk" -exec unzip -o {} -d "$tmpUnzippedDir" \;
+ find "$tmpUnzippedDir" -name "*.MF" -exec rm {} \;
+}
+
+lookForExecFile() {
+ dir="$1"
+ readelf="$2"
+ find "$dir" -type f -name "*.so" -exec "$2" --dyn-symbols {} >> "$dir"/../tmpReadelf.txt \;
+ find "$dir" -type f -perm /111 ! -name "*.so" -exec "$2" --dyn-symbols {} >> "$dir"/../tmpReadelf.txt \;
+}
+
+if [[ "$1" == "help" ]]
+then
+ printHelp
+elif [[ "$#" -ne 3 ]]
+then
+ echo "Wrong argument length. Expecting 3 argument representing image file directory, llvm-readelf tool path, output path."
+else
+ unzipJarAndApk "$1"
+ lookForExecFile "$1" "$2"
+ tmpReadelfOutput="$1/../tmpReadelf.txt"
+ [[ -e "$3" ]] && rm "$3"
+ parseReadelfOutput "$tmpReadelfOutput" "$3"
+ [[ -e "$tmpReadelfOutput" ]] && rm "$tmpReadelfOutput"
+ rm -rf "$1/tmpUnzipped"
+fi \ No newline at end of file