sm8350-common: Sync extract scripts with templates

Change-Id: I98a36854c5a0c0390592911bb2558b34eff77efc
This commit is contained in:
Michael Bestas 2024-08-27 22:05:28 +03:00 committed by Arian
parent 3969a26b43
commit 33ad994764
2 changed files with 56 additions and 39 deletions

View File

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (C) 2016 The CyanogenMod Project # SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# Copyright (C) 2017-2023 The LineageOS Project # SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@ -14,6 +13,10 @@ if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
ANDROID_ROOT="${MY_DIR}/../../.." ANDROID_ROOT="${MY_DIR}/../../.."
# If XML files don't have comments before the XML header, use this flag
# Can still be used with broken XML files by using blob_fixup
export TARGET_DISABLE_XML_FIXING=true
HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}" echo "Unable to find helper script at ${HELPER}"
@ -32,28 +35,29 @@ SECTION=
while [ "${#}" -gt 0 ]; do while [ "${#}" -gt 0 ]; do
case "${1}" in case "${1}" in
--only-common ) --only-common)
ONLY_COMMON=true ONLY_COMMON=true
;; ;;
--only-firmware ) --only-firmware)
ONLY_FIRMWARE=true ONLY_FIRMWARE=true
;; ;;
--only-target ) --only-target)
ONLY_TARGET=true ONLY_TARGET=true
;; ;;
-n | --no-cleanup ) -n | --no-cleanup)
CLEAN_VENDOR=false CLEAN_VENDOR=false
;; ;;
-k | --kang ) -k | --kang)
KANG="--kang" KANG="--kang"
;; ;;
-s | --section ) -s | --section)
SECTION="${2}"; shift SECTION="${2}"
CLEAN_VENDOR=false shift
;; CLEAN_VENDOR=false
* ) ;;
SRC="${1}" *)
;; SRC="${1}"
;;
esac esac
shift shift
done done
@ -65,41 +69,54 @@ fi
function blob_fixup() { function blob_fixup() {
case "${1}" in case "${1}" in
system_ext/lib64/libwfdnative.so) system_ext/lib64/libwfdnative.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --remove-needed "android.hidl.base@1.0.so" "${2}" "${PATCHELF}" --remove-needed "android.hidl.base@1.0.so" "${2}"
;; ;;
vendor/etc/media_lahaina/video_system_specs.json \ vendor/etc/media_lahaina/video_system_specs.json \
|vendor/etc/media_shima_v1/video_system_specs.json \ |vendor/etc/media_shima_v1/video_system_specs.json \
|vendor/etc/media_yupik_v1/video_system_specs.json) |vendor/etc/media_yupik_v1/video_system_specs.json)
[ "$2" = "" ] && return 0
sed -i "/max_retry_alloc_output_timeout/ s/10000/0/" "${2}" sed -i "/max_retry_alloc_output_timeout/ s/10000/0/" "${2}"
;; ;;
vendor/etc/vintf/manifest/c2_manifest_vendor.xml) vendor/etc/vintf/manifest/c2_manifest_vendor.xml)
[ "$2" = "" ] && return 0
sed -ni '/ozoaudio/!p' "${2}" sed -ni '/ozoaudio/!p' "${2}"
sed -ni '/dolby/!p' "${2}" sed -ni '/dolby/!p' "${2}"
;; ;;
vendor/lib64/android.hardware.secure_element@1.0-impl.so) vendor/lib64/android.hardware.secure_element@1.0-impl.so)
[ "$2" = "" ] && return 0
"${PATCHELF}" --remove-needed "android.hidl.base@1.0.so" "${2}" "${PATCHELF}" --remove-needed "android.hidl.base@1.0.so" "${2}"
;; ;;
*)
return 1
;;
esac esac
return 0
}
function blob_fixup_dry() {
blob_fixup "$1" ""
} }
if [ -z "${ONLY_FIRMWARE}" ] && [ -z "${ONLY_TARGET}" ]; then if [ -z "${ONLY_FIRMWARE}" ] && [ -z "${ONLY_TARGET}" ]; then
# Initialize the helper for common device # Initialize the helper for common device
setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}" setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true "${CLEAN_VENDOR}"
extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi fi
if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then if [ -z "${ONLY_COMMON}" ] && [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
# Reinitialize the helper for device # Reinitialize the helper for device
source "${MY_DIR}/../${DEVICE}/extract-files.sh" source "${MY_DIR}/../../${VENDOR}/${DEVICE}/extract-files.sh"
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}"
if [ -z "${ONLY_FIRMWARE}" ]; then if [ -z "${ONLY_FIRMWARE}" ]; then
extract "${MY_DIR}/../${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" extract "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}"
fi fi
if [ -f "${MY_DIR}/../${DEVICE}/proprietary-firmware.txt" ]; then if [ -z "${SECTION}" ] && [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
extract_firmware "${MY_DIR}/../${DEVICE}/proprietary-firmware.txt" "${SRC}" extract_firmware "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" "${SRC}"
fi fi
fi fi

View File

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (C) 2016 The CyanogenMod Project # SPDX-FileCopyrightText: 2016 The CyanogenMod Project
# Copyright (C) 2017-2023 The LineageOS Project # SPDX-FileCopyrightText: 2017-2024 The LineageOS Project
#
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@ -22,7 +21,7 @@ fi
source "${HELPER}" source "${HELPER}"
# Initialize the helper for common # Initialize the helper for common
setup_vendor "${DEVICE_COMMON}" "${VENDOR}" "${ANDROID_ROOT}" true setup_vendor "${DEVICE_COMMON}" "${VENDOR_COMMON:-$VENDOR}" "${ANDROID_ROOT}" true
# Warning headers and guards # Warning headers and guards
write_headers "haydn lisa mars odin redwood renoir star venus" write_headers "haydn lisa mars odin redwood renoir star venus"
@ -33,18 +32,19 @@ write_makefiles "${MY_DIR}/proprietary-files.txt" true
# Finish # Finish
write_footers write_footers
if [ -s "${MY_DIR}/../${DEVICE}/proprietary-files.txt" ]; then if [ -s "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" ]; then
# Reinitialize the helper for device # Reinitialize the helper for device
source "${MY_DIR}/../../${VENDOR}/${DEVICE}/setup-makefiles.sh"
setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false
# Warning headers and guards # Warning headers and guards
write_headers write_headers
# The standard device blobs # The standard device blobs
write_makefiles "${MY_DIR}/../${DEVICE}/proprietary-files.txt" true write_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-files.txt" true
if [ -f "${MY_DIR}/../${DEVICE}/proprietary-firmware.txt" ]; then if [ -f "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt" ]; then
append_firmware_calls_to_makefiles "${MY_DIR}/../${DEVICE}/proprietary-firmware.txt" append_firmware_calls_to_makefiles "${MY_DIR}/../../${VENDOR}/${DEVICE}/proprietary-firmware.txt"
fi fi
# Finish # Finish