Forráskód Böngészése

cupid: Switch to python extract-utils

Change-Id: Ia6ea2ea79cb3bcbcbf06f0e6660ac31ea576b524
Arian 4 hónapja
szülő
commit
393c9b4ac5
5 módosított fájl, 79 hozzáadás és 97 törlés
  1. 77 0
      extract-files.py
  2. 0 45
      extract-files.sh
  3. 1 1
      proprietary-files.txt
  4. 1 0
      setup-makefiles.py
  5. 0 51
      setup-makefiles.sh

+ 77 - 0
extract-files.py

@@ -0,0 +1,77 @@
+#!/usr/bin/env -S PYTHONPATH=../../../tools/extract-utils python3
+#
+# SPDX-FileCopyrightText: 2024 The LineageOS Project
+# SPDX-License-Identifier: Apache-2.0
+#
+
+import extract_utils.tools
+extract_utils.tools.DEFAULT_PATCHELF_VERSION = '0_18'
+
+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',
+        '[email protected]',
+    ): 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()

+ 0 - 45
extract-files.sh

@@ -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" "$@"

+ 1 - 1
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

+ 1 - 0
setup-makefiles.py

@@ -0,0 +1 @@
+#!./extract-files.py --regenerate_makefiles

+ 0 - 51
setup-makefiles.sh

@@ -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 | \
-        [email protected])
-            ;;
-        *)
-            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" "$@"