summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-09-08 16:53:00 -0700
committerXin Li <delphij@google.com>2020-09-08 16:53:00 -0700
commitf1c03a0574c75145131ca8bc8aa35a5f85121915 (patch)
tree0d0cda21ad6eca8e88212b860650ec5778c450c7
parent8d426f0cd5ff894743ccdaf851de23b42d5721dc (diff)
parent62a7548a5334757de00fcf4ee706a000fe41ca7f (diff)
downloadcommon-f1c03a0574c75145131ca8bc8aa35a5f85121915.tar.gz
Merge Android R
Bug: 168057903 Merged-In: I58746745416a0abfe332709351ed21a99f5abd3b Change-Id: I5405f2f357fbfd687762c9326a7b64fae60b79d4
-rwxr-xr-xgenerate-android-bp-for-blobs.sh126
-rwxr-xr-xgenerate-packages.sh6
2 files changed, 131 insertions, 1 deletions
diff --git a/generate-android-bp-for-blobs.sh b/generate-android-bp-for-blobs.sh
new file mode 100755
index 0000000..3d0660c
--- /dev/null
+++ b/generate-android-bp-for-blobs.sh
@@ -0,0 +1,126 @@
+#!/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
+# $ export OWNER=qcom # Owner is relevant if PRODUCT_RESTRICT_VENDOR_FILES is set
+# $ ./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
+ if [[ -n "$OWNER" ]]; then
+echo " owner: \"${OWNER}\","
+ fi
+echo " strip: {"
+echo " none: true,"
+echo " },"
+echo "}"
+
+done
diff --git a/generate-packages.sh b/generate-packages.sh
index d597e43..58e85be 100755
--- a/generate-packages.sh
+++ b/generate-packages.sh
@@ -59,7 +59,7 @@ do
do
if test ${ZIP_TYPE} = target_files
then
- ONE_FILE=`echo $ONE_FILE | sed 's/system\//SYSTEM\//g'`
+ ONE_FILE=`echo $ONE_FILE | sed -e 's/system\//SYSTEM\//g' -e 's/system_ext\//SYSTEM_EXT\//g' -e 's/product\//PRODUCT\//g'`
fi
if [[ $ONE_FILE == */lib64/* ]]
@@ -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