From c9cc2c279af4432881874b6a9292eb3dca9bf306 Mon Sep 17 00:00:00 2001 From: Arian Date: Thu, 24 Oct 2024 23:40:01 +0200 Subject: [PATCH] marble: Switch to python extract-utils Change-Id: Ia6ea2ea79cb3bcbcbf06f0e6660ac31ea576b524 --- extract-files.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++ extract-files.sh | 45 ---------------------------- setup-makefiles.py | 1 + setup-makefiles.sh | 51 -------------------------------- 4 files changed, 74 insertions(+), 96 deletions(-) create mode 100755 extract-files.py delete mode 100755 extract-files.sh create mode 100755 setup-makefiles.py delete mode 100644 setup-makefiles.sh diff --git a/extract-files.py b/extract-files.py new file mode 100755 index 0000000..b215840 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,73 @@ +#!/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/marble_enhance_motiontuning.xml', + 'vendor/etc/camera/marble_motiontuning.xml', + ): blob_fixup().regex_replace('xml=version', 'xml version'), + '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( + 'marble', + '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 4055469..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/marble_enhance_motiontuning.xml|vendor/etc/camera/marble_motiontuning.xml) - [ "$2" = "" ] && return 0 - sed -i 's/xml=version/xml version/g' "${2}" - ;; - 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=marble -export DEVICE_COMMON=sm8450-common -export VENDOR=xiaomi -export VENDOR_COMMON=${VENDOR} - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/extract-files.sh" "$@" 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 100644 index 518fbc2..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=marble -export DEVICE_COMMON=sm8450-common -export VENDOR=xiaomi -export VENDOR_COMMON=${VENDOR} - -"./../../${VENDOR_COMMON}/${DEVICE_COMMON}/setup-makefiles.sh" "$@"