diff --git a/extract-files.py b/extract-files.py new file mode 100755 index 0000000..ff1a566 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,74 @@ +#!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3 +# +# SPDX-FileCopyrightText: 2024 The LineageOS Project +# SPDX-License-Identifier: Apache-2.0 +# + +from extract_utils.fixups_blob import ( + blob_fixup, + blob_fixups_user_type, +) +from extract_utils.fixups_lib import ( + lib_fixup_remove, + lib_fixup_remove_arch_suffix, + lib_fixup_remove_proto_version_suffix, + lib_fixup_vendorcompat, + lib_fixups_user_type, + libs_clang_rt_ubsan, + libs_proto_3_9_1, + libs_proto_21_12, +) +from extract_utils.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +namespace_imports = [ + 'device/xiaomi/sm8450-common', + 'hardware/qcom-caf/sm8450', + 'hardware/xiaomi', + 'vendor/qcom/opensource/commonsys-intf/display', + 'vendor/xiaomi/sm8450-common', +] + +lib_fixups: lib_fixups_user_type = { + libs_clang_rt_ubsan: lib_fixup_remove_arch_suffix, + libs_proto_3_9_1: lib_fixup_vendorcompat, + libs_proto_21_12: lib_fixup_remove_proto_version_suffix, + ( + 'libagmclient', + 'libagmmixer', + 'vendor.qti.hardware.pal@1.0-impl', + ): lib_fixup_remove, +} + +blob_fixups: blob_fixups_user_type = { + ( + 'vendor/etc/camera/cupid_enhance_motiontuning.xml', + 'vendor/etc/camera/cupid_motiontuning.xml', + ): blob_fixup().regex_replace('xml=version', 'xml version'), + ( + 'vendor/etc/camera/pureShot_parameter.xml', + 'vendor/etc/camera/pureView_parameter.xml', + ): blob_fixup().regex_replace(r'=([0-9]+)>', r'="\1">'), + 'vendor/lib64/libcamximageformatutils.so': blob_fixup().replace_needed( + 'vendor.qti.hardware.display.config-V2-ndk_platform.so', + 'vendor.qti.hardware.display.config-V2-ndk.so', + ), +} + +module = ExtractUtilsModule( + 'cupid', + 'xiaomi', + blob_fixups=blob_fixups, + lib_fixups=lib_fixups, + namespace_imports=namespace_imports, + check_elf=True, + add_firmware_proprietary_file=True, +) + +if __name__ == '__main__': + utils = ExtractUtils.device_with_common( + module, 'sm8450-common', module.vendor + ) + utils.run() diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index 94b4a6e..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# SPDX-FileCopyrightText: 2016 The CyanogenMod Project -# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project -# SPDX-License-Identifier: Apache-2.0 -# - -function blob_fixup() { - case "${1}" in - vendor/etc/camera/cupid_enhance_motiontuning.xml|vendor/etc/camera/cupid_motiontuning.xml) - [ "$2" = "" ] && return 0 - sed -i 's/xml=version/xml version/g' "${2}" - ;; - vendor/etc/camera/pureShot_parameter.xml|vendor/etc/camera/pureView_parameter.xml) - [ "$2" = "" ] && return 0 - sed -i 's/=\([0-9]\+\)>/="\1">/g' "${2}" - ;; - vendor/lib64/libcamximageformatutils.so) - [ "$2" = "" ] && return 0 - "${PATCHELF_0_17_2}" --replace-needed "vendor.qti.hardware.display.config-V2-ndk_platform.so" "vendor.qti.hardware.display.config-V2-ndk.so" "${2}" - ;; - *) - return 1 - ;; - esac -} - -function blob_fixup_dry() { - blob_fixup "$1" "" -} - -# If we're being sourced by the common script that we called, -# stop right here. No need to go down the rabbit hole. -if [ "${BASH_SOURCE[0]}" != "${0}" ]; then - return -fi - -set -e - -export DEVICE=cupid -export DEVICE_COMMON=sm8450-common -export VENDOR=xiaomi -export VENDOR_COMMON=${VENDOR} - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/extract-files.sh" "$@" diff --git a/proprietary-files.txt b/proprietary-files.txt index cb2a5bc..e3f54ac 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -542,7 +542,7 @@ vendor/lib64/camera/fdconfigpreview.bin vendor/lib64/camera/fdconfigpreviewlite.bin vendor/lib64/camera/fdconfigvideo.bin vendor/lib64/camera/fdconfigvideolite.bin -vendor/lib64/camera/libQnnHtpAltPrepV69Stub.so;MODULE_SUFFIX=-camera +vendor/lib64/camera/libQnnHtpAltPrepV69Stub.so;MODULE_SUFFIX=_camera vendor/lib64/camera/plugins/com.xiaomi.plugin.anchor.so vendor/lib64/camera/plugins/com.xiaomi.plugin.arcsoftsll.so vendor/lib64/camera/plugins/com.xiaomi.plugin.capbokeh.so diff --git a/setup-makefiles.py b/setup-makefiles.py new file mode 100755 index 0000000..32947cf --- /dev/null +++ b/setup-makefiles.py @@ -0,0 +1 @@ +#!./extract-files.py --regenerate_makefiles diff --git a/setup-makefiles.sh b/setup-makefiles.sh deleted file mode 100755 index 5e6f225..0000000 --- a/setup-makefiles.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# -# SPDX-FileCopyrightText: 2016 The CyanogenMod Project -# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project -# SPDX-License-Identifier: Apache-2.0 -# - -function vendor_imports() { - cat << EOF >> "$1" - "device/xiaomi/sm8450-common", - "hardware/qcom-caf/sm8450", - "hardware/xiaomi", - "vendor/qcom/opensource/commonsys-intf/display", -EOF -} - -function lib_to_package_fixup_vendor_variants() { - if [ "$2" != "vendor" ]; then - return 1 - fi - - case "$1" in - libagmclient | \ - libagmmixer | \ - vendor.qti.hardware.pal@1.0-impl) - ;; - *) - return 1 - esac -} - -function lib_to_package_fixup() { - lib_to_package_fixup_clang_rt_ubsan_standalone "$1" || \ - lib_to_package_fixup_proto_3_9_1 "$1" || \ - lib_to_package_fixup_vendor_variants "$@" -} - -# If we're being sourced by the common script that we called, -# stop right here. No need to go down the rabbit hole. -if [ "${BASH_SOURCE[0]}" != "${0}" ]; then - return -fi - -set -e - -export DEVICE=cupid -export DEVICE_COMMON=sm8450-common -export VENDOR=xiaomi -export VENDOR_COMMON=${VENDOR} - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/setup-makefiles.sh" "$@"