diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-27 07:14:36 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-27 07:14:36 +0000 |
commit | 681d7da7c1f0b1674ee87e10fe8a3710acfb6a64 (patch) | |
tree | 8e99348f2c410ff5e63f39094a5bf983ac8a9d7f | |
parent | c246120033d8a268464d41671290faab173fac7e (diff) | |
parent | 6aa84fd36b4ba2ad0427f29e1e395b2955b13616 (diff) | |
download | device_common-681d7da7c1f0b1674ee87e10fe8a3710acfb6a64.tar.gz device_common-681d7da7c1f0b1674ee87e10fe8a3710acfb6a64.tar.bz2 device_common-681d7da7c1f0b1674ee87e10fe8a3710acfb6a64.zip |
Snap for 6338932 from 6aa84fd36b4ba2ad0427f29e1e395b2955b13616 to mainline-release
Change-Id: I76721a060704b50041f1fce81bd48a5f73d582f4
-rwxr-xr-x | generate-android-bp-for-blobs.sh | 122 | ||||
-rwxr-xr-x | generate-packages.sh | 4 |
2 files changed, 126 insertions, 0 deletions
diff --git a/generate-android-bp-for-blobs.sh b/generate-android-bp-for-blobs.sh new file mode 100755 index 0000000..5708c7a --- /dev/null +++ b/generate-android-bp-for-blobs.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# +# Copyright 2020 The Android Open Source Project +# +# 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. +# +# Generate Android.bp for AOSP blob self-extractors. +# +# For example, a blob package may contain: +# ./vendor +# └── qcom +# └── coral +# └── proprietary +# ├── lib64 +# | ├── libfoo.so +# | └── libbar.so +# ├── libfoo.so +# └── libbar.so +# +# Generate prebuilt modules for these blobs: +# $ export SYSTEM_EXT_SPECIFIC=true # If installing prebuilts to system_ext/ partition +# $ ./generate-android-bp-for-blobs.sh ./vendor/qcom/coral/proprietary > Android.bp.txt +# $ mv Android.bp.txt ${ANDROID_BUILD_TOP}/device/google/coral/self-extractors/qcom/staging/ +# +# You may need to review the contents of Android.bp.txt as some of the blobs may +# have unsatisfied dependencies. Add `check_elf_files: false` to bypass this +# kind of build errors. + +set -e + +readonly PREBUILT_DIR="$1" + +readonly elf_files=$( + for file in $(find "$PREBUILT_DIR" -type f); do + if readelf -h "$file" 2>/dev/null 1>&2; then + basename "$file" + fi + done | sort | uniq | xargs +) + +echo "// Copyright (C) $(date +%Y) The Android Open Source Project" +echo "//" +echo "// Licensed under the Apache License, Version 2.0 (the \"License\");" +echo "// you may not use this file except in compliance with the License." +echo "// You may obtain a copy of the License at" +echo "//" +echo "// http://www.apache.org/licenses/LICENSE-2.0" +echo "//" +echo "// Unless required by applicable law or agreed to in writing, software" +echo "// distributed under the License is distributed on an \"AS IS\" BASIS," +echo "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." +echo "// See the License for the specific language governing permissions and" +echo "// limitations under the License." +echo "" +echo "soong_namespace {" +echo "}" + +for file in $elf_files; do + file32=$(find "$PREBUILT_DIR" -type f -name "$file" | grep -v 'lib64' | head) + file64=$(find "$PREBUILT_DIR" -type f -name "$file" | grep 'lib64' | head) + if [[ -n "$file32" ]] && [[ -n "$file64" ]]; then + multilib="both" + elif [[ -n "$file32" ]]; then + multilib="32" + else + multilib="64" + fi + +echo "" +echo "cc_prebuilt_library_shared {" +echo " name: \"${file%.so}\"," +echo " arch: {" + + if [[ -f "$file32" ]]; then + NEEDED=$(readelf -d "$file32" | sed -n -E 's/^.*\(NEEDED\).*\[(.+)\]$/\1/p' | xargs) +echo " arm: {" +echo " srcs: [\"$(realpath --relative-to="$PREBUILT_DIR" "$file32")\"]," + if [[ -n "$NEEDED" ]]; then +echo " shared_libs: [" + for entry in $NEEDED; do +echo " \"${entry%.so}\"," + done +echo " ]," + fi +echo " }," + fi + + if [[ -f "$file64" ]]; then + NEEDED=$(readelf -d "$file64" | sed -n -E 's/^.*\(NEEDED\).*\[(.+)\]$/\1/p' | xargs) +echo " arm64: {" +echo " srcs: [\"$(realpath --relative-to="$PREBUILT_DIR" "$file64")\"]," + if [[ -n "$NEEDED" ]]; then +echo " shared_libs: [" + for entry in $NEEDED; do +echo " \"${entry%.so}\"," + done +echo " ]," + fi +echo " }," + fi + +echo " }," +echo " compile_multilib: \"$multilib\"," + if [[ -n "$SYSTEM_EXT_SPECIFIC" ]]; then +echo " system_ext_specific: true," + fi +echo " strip: {" +echo " none: true," +echo " }," +echo "}" + +done diff --git a/generate-packages.sh b/generate-packages.sh index ca5d53f..dff6aeb 100755 --- a/generate-packages.sh +++ b/generate-packages.sh @@ -160,6 +160,10 @@ do mv ${MAKEFILEDIR}/Android.mk ${FILEDIR}/ fi + if [[ -e "${MAKEFILEDIR}/Android.bp.txt" ]]; then + mv "${MAKEFILEDIR}/Android.bp.txt" "${FILEDIR}/Android.bp" + fi + echo \ \ Generating self-extracting script SCRIPT=extract-$COMPANY-$DEVICE.sh cat PROLOGUE > tmp/$SCRIPT || echo \ \ \ \ Error generating script |