from pathlib import Path
from typing import Any
from functools import wraps
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import core.logger as logger
log = logger.get_logger()
from database.base import BaseConfig, AutoInstanceDecorator
from database.options import ReleaseOptions
from database.common import *

@AutoInstanceDecorator
class DirAlias(BaseConfig):
    """给alkaid相关的目录文件其一个别名，方便其他配置进行使用。
    1. 所有的路径都是相对于ReleaseOptions.AlkaidRootPath的相对路径
    2. 所有的路径都是字符串
    3. 所有的路径都是列表
    """
    _config = {
        "mi_default": [
            "sdk/makefile",
            "sdk/sdk.mk",
            "sdk/.clang-format",
            "sdk/.clang-tidy",
            "sdk/interface/add-config.mk",
            "sdk/interface/clear-config.mk",
            "sdk/interface/compile_options.mk",
            "sdk/interface/hal-impl-config.mk",
            "sdk/interface/makefile",
            "sdk/interface/modules.mk",
            "sdk/interface/raw-impl-config.mk",
            "sdk/interface/tag-maker.mk",
            "sdk/interface/tidy_ignore.mk",
            "sdk/interface/tidy_ruler.mk",
            "sdk/interface/include_scanner.sh",
            "sdk/interface/header_blacklist.txt",
            "sdk/interface/src_whitelist.txt",
            "sdk/interface/sdk_coding_style_sanitize.py",
            "sdk/interface/.scan_header_whitelist.json",
            "sdk/interface/include/common/",
            "sdk/interface/include/internal/kernel/",
            "sdk/interface/include/internal/rtos/",
            "sdk/interface/include/internal/user/",
            "sdk/interface/include/sys/",
        ],
        "mi_ai": [
            "sdk/interface/include/aio/",
            "sdk/interface/include/ai/",
            "sdk/interface/src/ai/",
            "sdk/impl/ai/",
        ],
        "mi_aio": [
            "sdk/interface/include/aio/",
            "sdk/interface/src/aio/",
            "sdk/impl/aio/",
        ],
        "mi_ao": [
            "sdk/interface/include/aio/",
            "sdk/interface/include/ao/",
            "sdk/interface/src/ao/",
            "sdk/impl/ao/",
        ],
        "mi_alsa": [
            "sdk/interface/include/alsa/",
            "sdk/interface/src/alsa/",
            "sdk/impl/alsa/",
        ],
        "mi_cipher": [
            "sdk/interface/include/cipher/",
            "sdk/interface/src/cipher/",
            "sdk/impl/cipher/",
        ],
        "mi_common": [
            "sdk/interface/src/common/",
            "sdk/impl/common/",
        ],
        "mi_cus3a": [
            "sdk/interface/include/cus3a/",
            "sdk/interface/src/cus3a/",
        ],
        "mi_debug": [
            "sdk/interface/include/debug/",
            "sdk/interface/src/debug/",
            "sdk/impl/debug/",
        ],
        "mi_dummy": [
            "sdk/interface/include/dummy/",
            "sdk/interface/src/dummy/",
            "sdk/impl/dummy/",
        ],
        "mi_disp": [
            "sdk/interface/include/disp/",
            "sdk/interface/src/disp/",
            "sdk/impl/disp/",
        ],
        "mi_dpu": [
            "sdk/interface/include/dpu/",
            "sdk/interface/src/dpu/",
            "sdk/impl/dpu/",
        ],
        "mi_dsp": [
            "sdk/interface/include/dsp/",
            "sdk/interface/src/dsp/",
            "sdk/impl/dsp/",
        ],
        "mi_fb": [
            "sdk/interface/include/fb/",
            "sdk/interface/src/fb/",
            "sdk/impl/fb/",
        ],
        "mi_gfx": [
            "sdk/interface/include/gfx/",
            "sdk/interface/src/gfx/",
            "sdk/impl/gfx/",
        ],
        "mi_hdmi": [
            "sdk/interface/include/hdmi/",
            "sdk/interface/src/hdmi/",
            "sdk/impl/hdmi/",
        ],
        "mi_hdmirx": [
            "sdk/interface/include/hdmirx/",
            "sdk/interface/src/hdmirx/",
            "sdk/impl/hdmirx/",
        ],
        "mi_hvp": [
            "sdk/interface/include/hvp/",
            "sdk/interface/src/hvp/",
            "sdk/impl/hvp/",
        ],
        "mi_ipu": [
            "sdk/interface/include/ipu/",
            "sdk/interface/src/ipu/",
            "sdk/impl/ipu/",
        ],
        "mi_iqserver": [
            "sdk/interface/include/iqserver/",
            "sdk/interface/src/iqserver/",
        ],
        "mi_isp": [
            "sdk/interface/include/isp/",
            "sdk/interface/src/isp/",
            "sdk/impl/isp/",
        ],
        "mi_ispalgo": [
            "sdk/interface/include/ispalgo/",
            "sdk/interface/src/ispalgo/",
        ],
        "mi_ive": [
            "sdk/interface/include/ive/",
            "sdk/interface/src/ive/",
            "sdk/impl/ive/",
        ],
        "mi_jpd": [
            "sdk/interface/include/jpd/",
            "sdk/interface/src/jpd/",
            "sdk/impl/jpd",
        ],
        "mi_ldc": [
            "sdk/interface/include/ldc/",
            "sdk/interface/src/ldc/",
            "sdk/impl/ldc/",
        ],
        "mi_mipitx": [
            "sdk/interface/include/mipitx/",
            "sdk/interface/src/mipitx/",
            "sdk/impl/mipitx/",
        ],
        "mi_nir": [
            "sdk/interface/include/nir/",
            "sdk/interface/src/nir/",
            "sdk/impl/nir/",
        ],
        "mi_panel": [
            "sdk/interface/include/panel/",
            "sdk/interface/src/panel/",
            "sdk/impl/panel/",
        ],
        "mi_pcie": [
            "sdk/interface/include/pcie/",
            "sdk/interface/src/pcie/",
            "sdk/impl/pcie/",
        ],
        "mi_pspi": [
            "sdk/interface/include/pspi/",
            "sdk/interface/src/pspi/",
            "sdk/impl/pspi/",
        ],
        "mi_rgn": [
            "sdk/interface/include/rgn/",
            "sdk/interface/src/rgn/",
            "sdk/impl/rgn/",
        ],
        "mi_scl": [
            "sdk/interface/include/scl/",
            "sdk/interface/src/scl/",
            "sdk/impl/scl/",
        ],
        "mi_sed": [
            "sdk/interface/include/sed/",
            "sdk/interface/include/vg/",
            "sdk/interface/src/sed/",
        ],
        "mi_sensor": [
            "sdk/interface/include/sensor/",
            "sdk/interface/src/sensor/",
            "sdk/impl/sensor/",
        ],
        "mi_shadow": [
            "sdk/interface/include/shadow/",
            "sdk/interface/src/shadow/",
            "sdk/impl/shadow/",
        ],
        "mi_sys": [
            "sdk/interface/include/sys/",
            "sdk/interface/src/sys/",
            "sdk/impl/sys/",
        ],
        "mi_sys_earlyinit": [
            "sdk/interface/include/sys_earlyinit/",
            "sdk/interface/src/sys_earlyinit/",
            "sdk/impl/sys_earlyinit/",
        ],
        "mi_vdec": [
            "sdk/interface/include/vdec/",
            "sdk/interface/src/vdec/",
            "sdk/impl/vdec/",
        ],
        "mi_vdf": [
            "sdk/interface/include/md/",
            "sdk/interface/include/od/",
            "sdk/interface/include/vg/",
            "sdk/interface/include/vdf/",
            "sdk/interface/src/vdf/",
        ],
        "mi_vcodec": [
            "sdk/interface/src/vcodec/",
            "sdk/interface/src/vcodec/config.mk",
        ],
        "mi_vdisp": [
            "sdk/interface/include/vdisp/",
            "sdk/interface/src/vdisp/",
            "sdk/impl/vdisp/",
        ],
        "mi_venc": [
            "sdk/interface/include/venc/",
            "sdk/interface/src/venc/",
            "sdk/impl/venc/",
        ],
        "mi_vif": [
            "sdk/interface/include/vif/",
            "sdk/interface/src/vif/",
            "sdk/impl/vif/",
        ],
        "mi_wlan": [
            "sdk/interface/include/wlan/",
            "sdk/interface/src/wlan/",
        ],
        "bench": [
            "rtos/proj/sc/application/bench"
        ],
        "bootloader": [
            "rtos/proj/sc/application/bootloader"
        ],
        "coremark": [
            "rtos/proj/sc/application/coremark"
        ],
        "common": [
            "rtos/proj/sc/application/pipeline_demo/common"
        ],
        "font": [
            "rtos/proj/sc/application/pipeline_demo/font"
        ],
        "iqserver": [
            "rtos/proj/sc/application/pipeline_demo/iqserver"
        ],
        "audio_app": [
            "rtos/proj/sc/application/pipeline_demo/audio_app"
        ],
        "disp_app": [
            "rtos/proj/sc/application/pipeline_demo/disp_app"
        ],
        "dualos_camera": [
            "rtos/proj/sc/application/pipeline_demo/dualos_camera"
        ],
        "dualos_pipeline": [
            "rtos/proj/sc/application/pipeline_demo/dualos_pipeline"
        ],
        "application_selector": [
            "rtos/proj/sc/application/pipeline_demo/application_selector"
        ],
        "ptree": [
            "sdk/verify/ptree"
        ],
        "rtos_bsp_demo": [
            "sdk/verify/bsp_demo/rtos_bsp_demo"
        ],
        "preload_rtos": [
            r"sdk/verify/sample_code/source/{SWBoardAlias}/preload/rtos"
        ],
        "preload_sample": [
            r"sdk/verify/sample_code/source/{SWBoardAlias}/preload_sample/rtos"
        ],
        "aov_preload": [
            r"sdk/verify/sample_code/source/{SWBoardAlias}/aov/preload/rtos/aov_preload"
        ],
        "cm4_preload": [
            r"sdk/verify/sample_code/source/{SWBoardAlias}/cm4/preload/rtos/cm4_preload"
        ],
        "sample_code": [
            "sdk/verify/sample_code/build"
        ],
        "sensordriver": [
            "sdk/driver/SensorDriver"
        ],
        "lvgl": [
            "rtos/proj/sc/application/pipeline_demo/lvgl"
        ],
        "usb_gadget_app": [
            "rtos/proj/sc/application/pipeline_demo/usb_gadget_app"
        ],
        "usb_gadget_app_uvc": [
            "rtos/proj/sc/application/pipeline_demo/usb_gadget_app"
        ],
        "cust_isp": [
            "rtos/proj/sc/customer/cust_isp"
        ],
        "cust_usb_gadget": [
            "rtos/proj/sc/customer/usb_gadget"
        ],
        "adc": [
            "rtos/proj/sc/driver/sysdriver_common/adc"
        ],
        "aesdma": [
            "rtos/proj/sc/driver/sysdriver/aesdma"
        ],
        "bdma": [
            "rtos/proj/sc/driver/sysdriver/bdma",
            "rtos/proj/sc/driver/sysdriver_common/bdma"
        ],
        "capture": [
            "rtos/proj/sc/driver/sysdriver_common/capture"
        ],
        "crypto": [
            "rtos/proj/sc/driver/sysdriver_common/crypto"
        ],
        "camclk": [
            "rtos/proj/sc/driver/sysdriver/camclk",
            "rtos/proj/sc/driver/sysdriver_common/clk"
        ],
        "cpufreq": [
            "rtos/proj/sc/driver/sysdriver/cpufreq"
        ],
        "drvutil": [
            "rtos/proj/sc/driver/sysdriver/drvutil"
        ],
        "dualos": [
            "rtos/proj/sc/driver/sysdriver/dualos",
            "rtos/proj/sc_priv/driver/sysdriver/dualos"
        ],
        "earlyinit_setting": [
            "rtos/proj/sc/customer/earlyinit_setting"
        ],
        "earlyinit_main": [
            "rtos/proj/sc/driver/sysdriver/earlyinit_main"
        ],
        "earlyinit_impl": [
            "rtos/proj/sc/driver/sysdriver/earlyinit_impl",
            "rtos/proj/sc/driver/sysdriver/sensor_init/impl"
        ],
        "earlyinit_rtos_api": [
            "rtos/proj/sc/driver/sysdriver/earlyinit_rtos_api",
            "rtos/proj/sc/driver/sysdriver/sensor_init/rtos_api"
        ],
        "earlyinit_vsrc": [
            "rtos/proj/sc/driver/sysdriver/sensor_init/vsrc"
        ],
        "ipl_early_fw": [
            "rtos/proj/sc/driver/sysdriver/ipl_early_fw"
        ],
        "emac": [
            "rtos/proj/sc/driver/sysdriver/emac"
        ],
        "fcie": [
            "rtos/proj/sc/driver/sysdriver/fcie",
            "rtos/proj/sc/driver/sysdriver_common/fcie"
        ],
        "flash": [
            "rtos/proj/sc/driver/sysdriver/flash",
            "rtos/proj/sc/driver/sysdriver_common/flash"
        ],
        "fsp_qspi": [
            "rtos/proj/sc/driver/sysdriver/fsp_qspi",
            "rtos/proj/sc/driver/sysdriver_common/fsp_qspi"
        ],
        "gpio": [
            "rtos/proj/sc/driver/sysdriver/gpio",
            "rtos/proj/sc/driver/sysdriver_common/gpio"
        ],
        "i2c": [
            "rtos/proj/sc/driver/sysdriver/i2c",
            "rtos/proj/sc/driver/sysdriver_common/i2c"
        ],
        "input": [
            "rtos/proj/sc/driver/sysdriver/input"
        ],
        "int": [
            "rtos/proj/sc/driver/sysdriver/int"
        ],
        "ir": [
            "rtos/proj/sc/driver/sysdriver/ir",
            "rtos/proj/sc/driver/sysdriver_common/ir"
        ],
        "ive": [
            "rtos/proj/sc/driver/sysdriver/ive",
            "rtos/proj/sc_priv/driver/sysdriver/ive"
        ],
        "kernel": [
            "rtos/proj/sc/driver/sysdriver/kernel"
        ],
        "loadns": [
            "rtos/proj/sc/driver/sysdriver/loadns"
        ],
        "mbx": [
            "rtos/proj/sc/driver/sysdriver/mbx"
        ],
        "miu": [
            "rtos/proj/sc/driver/sysdriver/miu",
            "rtos/proj/sc/driver/sysdriver_common/miu",
            "rtos/proj/sc/driver/sysdriver_common/miu_dq"
        ],
        "mmupte": [
            "rtos/proj/sc/driver/sysdriver/mmupte"
        ],
        "mspi": [
            "rtos/proj/sc/driver/sysdriver/mspi",
            "rtos/proj/sc/driver/sysdriver_common/mspi"
        ],
        "riu": [
            "rtos/proj/sc/driver/sysdriver/riu"
        ],
        "msys": [
            "rtos/proj/sc/driver/sysdriver/msys"
        ],
        "otp": [
            "rtos/proj/sc/driver/sysdriver/otp",
            "rtos/proj/sc_priv/driver/sysdriver/otp"
        ],
        "padmux": [
            "rtos/proj/sc/driver/sysdriver/padmux",
            "rtos/proj/sc/driver/sysdriver_common/padmux"
        ],
        "pcie": [
            "rtos/proj/sc/driver/sysdriver/pcie"
        ],
        "pl011": [
            "rtos/proj/sc/driver/sysdriver/pl011"
        ],
        "power_manag": [
            "rtos/proj/sc/driver/sysdriver/power_manag",
            "rtos/proj/sc_priv/driver/sysdriver/power_manag"
        ],
        "pwm": [
            "rtos/proj/sc/driver/sysdriver/pwm",
            "rtos/proj/sc/driver/sysdriver_common/pwm"
        ],
        "rpmsg_lite": [
            "rtos/proj/sc/driver/sysdriver/rpmsg-lite",
            "rtos/proj/sc_priv/driver/sysdriver/rpmsg-lite"
        ],
        "rtc": [
            "rtos/proj/sc/driver/sysdriver/rtc"
        ],
        "rtcpwc": [
            "rtos/proj/sc/driver/sysdriver/rtcpwc",
            "rtos/proj/sc/driver/sysdriver_common/rtcpwc"
        ],
        "saradc": [
            "rtos/proj/sc/driver/sysdriver/saradc"
        ],
        "sdmmc": [
            "rtos/proj/sc/driver/sysdriver/sdmmc",
            "rtos/proj/sc/driver/sysdriver_common/sdmmc"
        ],
        "str": [
            "rtos/proj/sc/driver/sysdriver/str"
        ],
        "sysdesc": [
            "rtos/proj/sc/driver/sysdriver/sysdesc",
            "rtos/proj/sc/driver/sysdriver_common/include"
        ],
        "timer": [
            "rtos/proj/sc/driver/sysdriver/timer",
            "rtos/proj/sc/driver/sysdriver_common/timer"
        ],
        "tsensor": [
            "rtos/proj/sc/driver/sysdriver/tsensor",
            "rtos/proj/sc/driver/sysdriver_common/tsensor"
        ],
        "uart": [
            "rtos/proj/sc/driver/sysdriver/uart"
        ],
        "usb_gadget_udc_usb20": [
            "rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usb20",
            "rtos/proj/sc_priv/driver/sysdriver/usb_gadget/udc/usb20"
        ],
        "usb_gadget_udc_usb30": [
            "rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usb30",
            "rtos/proj/sc_priv/driver/sysdriver/usb_gadget/udc/usb30"
        ],
        "usbphy_drv": [
            "rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usbphy",
            "rtos/proj/sc_priv/driver/sysdriver/usb_gadget/udc/usbphy"
        ],
        "usbhost": [
            "rtos/proj/sc/driver/sysdriver/usbhost",
            "rtos/proj/sc_priv/driver/sysdriver/usbhost"
        ],
        "voltage": [
            "rtos/proj/sc/driver/sysdriver/voltage",
            "rtos/proj/sc/driver/sysdriver_common/voltage"
        ],
        "watchdog": [
            "rtos/proj/sc/driver/sysdriver/watchdog",
            "rtos/proj/sc/driver/sysdriver_common/watchdog"
        ],
        "wifi_ssw6x5x": [
            "rtos/proj/sc/driver/thirdparty/wifi/ssw6x5x"
        ],
        "algo": [
            "rtos/proj/sc/middleware/algo"
        ],
        "decompress": [
            "rtos/proj/sc/middleware/decompress"
        ],
        "firmwarefs": [
            "rtos/proj/sc/middleware/fs/firmwarefs",
            "rtos/proj/sc_priv/middleware/fs/firmwarefs"
        ],
        "freertos_plus_fat": [
            "rtos/proj/sc/middleware/fs/Lab-Project-FreeRTOS-FAT"
        ],
        "littlefs": [
            "rtos/proj/sc/middleware/fs/littlefs",
            "rtos/proj/sc_priv/middleware/fs/littlefs"
        ],
        "lwfs": [
            "rtos/proj/sc/middleware/fs/lwfs"
        ],
        "nfs": [
            "rtos/proj/sc/middleware/fs/nfs",
            "rtos/proj/sc_priv/middleware/fs/nfs"
        ],
        "proxyfs": [
            "rtos/proj/sc/middleware/fs/proxyfs"
        ],
        "tcpip": [
            "rtos/proj/sc/middleware/tcpip"
        ],
        "arm": [
            "rtos/proj/sc/system/arch"
        ],
        "riscv": [
            "rtos/proj/sc/system/riscv"
        ],
        "cam_dev_wrapper": [
            "rtos/proj/sc/system/cam_dev_wrapper",
            "rtos/proj/sc/driver/sysdriver_common/cam_dev_wrapper"
        ],
        "cam_drv_poll": [
            "rtos/proj/sc/system/cam_drv_poll",
            "rtos/proj/sc/driver/sysdriver_common/cam_drv_poll"
        ],
        "cam_fs_wrapper": [
            "rtos/proj/sc/system/cam_fs_wrapper",
            "rtos/proj/sc/driver/sysdriver_common/cam_fs_wrapper"
        ],
        "cam_os_wrapper": [
            "rtos/proj/sc/system/cam_os_wrapper",
            "rtos/proj/sc/driver/sysdriver_common/cam_os_wrapper"
        ],
        "cam_proc_wrapper": [
            "rtos/proj/sc/system/cam_proc_wrapper",
            "rtos/proj/sc/driver/sysdriver_common/cam_proc_wrapper"
        ],
        "env_util": [
            "rtos/proj/sc/system/env_util"
        ],
        "initcall": [
            "rtos/proj/sc/system/initcall"
        ],
        "libc": [
            "rtos/proj/sc/system/libc"
        ],
        "libstdcpp_plugin": [
            "rtos/proj/sc/system/libstdcpp_plugin",
            "rtos/proj/sc_priv/system/libstdcpp_plugin"
        ],
        "newlib_stub": [
            "rtos/proj/sc/system/newlib_stub"
        ],
        "loadable_module": [
            "rtos/proj/sc/system/loadable_module"
        ],
        "memmang": [
            "rtos/proj/sc/system/memmang"
        ],
        "memmap": [
            "rtos/proj/sc/system/memmap"
        ],
        "mempool": [
            "rtos/proj/sc/system/mempool"
        ],
        "MsWrapper": [
            "rtos/proj/sc/system/MsWrapper"
        ],
        "newlib_stub": [
            "rtos/proj/sc/system/newlib_stub"
        ],
        "freertos": [
            "rtos/proj/sc/system/rtos/freertos",
            "rtos/proj/sc_priv/system/rtos/freertos"
        ],
        "freertos_main": [
            "rtos/proj/sc/system/rtos/freertos_main"
        ],
        "freertos_posix": [
            "rtos/proj/sc/system/rtos/freertos_posix"
        ],
        "sys_I_SW": [
            "rtos/proj/sc/system/sys"
        ],
        "context_switch": [
            "rtos/proj/sc_priv/arch/arm/cortex-a/v7_aarch32/context_switch"
        ],
        "lh_monitor": [
            "rtos/proj/sc_priv/arch/arm/cortex-a/v7_aarch32/lh_monitor"
        ],
        "pm_bench": [
            "pm_rtos/proj/sc/bench"
        ],
        "pm_bootloader": [
            "pm_rtos/proj/sc/application/bootloader"
        ],
        "pm_coremark": [
            "pm_rtos/proj/sc/application/coremark"
        ],
        "pm_common": [
            "pm_rtos/proj/sc/application/common"
        ],
        "pm_dhrystone": [
            "pm_rtos/proj/sc/application/dhrystone"
        ],
        "pm_dualos_pipeline": [
            "pm_rtos/proj/sc/application/dualos_pipeline"
        ],
        "pm_dualos_camera": [
            "pm_rtos/proj/sc/application/dualos_camera"
        ],
        "pm_usb_gadget_app": [
            "pm_rtos/proj/sc/application/usb_gadget_app"
        ],
        "pm_algo_test_app": [
            "pm_rtos/proj/sc/application/algo_test_app"
        ],
        "pm_slnn_raw_hpd": [
            "pm_rtos/proj/sc/application/slnn_raw_hpd"
        ],
        "pm_slnn_sypd": [
            "pm_rtos/proj/sc/application/slnn_sypd"
        ],
        "pm_slnn_syfd": [
            "pm_rtos/proj/sc/application/slnn_syfd"
        ],
        "pm_cm4_pipeline": [
            "pm_rtos/proj/sc/application/cm4_pipeline"
        ],
        "pm_audio_aed": [
            "pm_rtos/proj/sc/application/audio_aed"
        ],
        "pm_audio_wos": [
            "pm_rtos/proj/sc/application/audio_wos"
        ],
        "pm_cust_isp": [
            "pm_rtos/proj/sc/customer/cust_isp"
        ],
        "pm_cust_usb_gadget": [
            "pm_rtos/proj/sc/customer/usb_gadget"
        ],
        "pm_aesdma": [
            "pm_rtos/proj/sc/driver/sysdriver/aesdma"
        ],
        "pm_bdma": [
            "pm_rtos/proj/sc/driver/sysdriver/bdma"
        ],
        "pm_camclk": [
            "pm_rtos/proj/sc/driver/sysdriver/camclk"
        ],
        "pm_cpufreq": [
            "pm_rtos/proj/sc/driver/sysdriver/cpufreq"
        ],
        "pm_drvutil": [
            "pm_rtos/proj/sc/driver/sysdriver/drvutil"
        ],
        "pm_dualos": [
            "pm_rtos/proj/sc/driver/sysdriver/dualos"
        ],
        "pm_loadns": [
            "pm_rtos/proj/sc/driver/sysdriver/loadns"
        ],
        "pm_emac": [
            "pm_rtos/proj/sc/driver/sysdriver/emac"
        ],
        "pm_flash": [
            "pm_rtos/proj/sc/driver/sysdriver/flash"
        ],
        "pm_fsp_qspi": [
            "pm_rtos/proj/sc/driver/sysdriver/fsp_qspi"
        ],
        "pm_gpio": [
            "pm_rtos/proj/sc/driver/sysdriver/gpio"
        ],
        "pm_i2c": [
            "pm_rtos/proj/sc/driver/sysdriver/i2c"
        ],
        "pm_int": [
            "pm_rtos/proj/sc/driver/sysdriver/int"
        ],
        "pm_ir": [
            "pm_rtos/proj/sc/driver/sysdriver/ir"
        ],
        "pm_ive": [
            "pm_rtos/proj/sc/driver/sysdriver/ive"
        ],
        "pm_kernel": [
            "pm_rtos/proj/sc/driver/sysdriver/kernel"
        ],
        "pm_miu": [
            "pm_rtos/proj/sc/driver/sysdriver/miu"
        ],
        "pm_mmupte": [
            "pm_rtos/proj/sc/driver/sysdriver/mmupte"
        ],
        "pm_mspi": [
            "pm_rtos/proj/sc/driver/sysdriver/mspi"
        ],
        "pm_msys": [
            "pm_rtos/proj/sc/driver/sysdriver/msys"
        ],
        "pm_padmux": [
            "pm_rtos/proj/sc/driver/sysdriver/padmux"
        ],
        "pm_pcie": [
            "pm_rtos/proj/sc/driver/sysdriver/pcie"
        ],
        "pm_pl011": [
            "pm_rtos/proj/sc/driver/sysdriver/pl011"
        ],
        "pm_mhal_pm_clk": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_clk"
        ],
        "pm_pm_idle": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_idle"
        ],
        "pm_mhal_pm_mbx": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_mbx"
        ],
        "pm_pm_power": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_power"
        ],
        "pm_pm_rtcpwc": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_rtcpwc"
        ],
        "pm_mhal_pm_sys": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_sys"
        ],
        "pm_mhal_pm_wdt": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_wdt"
        ],
        "pm_power_manag": [
            "pm_rtos/proj/sc/driver/sysdriver/power_manag"
        ],
        "pm_pspi": [
            "pm_rtos/proj/sc/driver/sysdriver/pspi"
        ],
        "pm_pwm": [
            "pm_rtos/proj/sc/driver/sysdriver/pwm"
        ],
        "pm_rpmsg_lite": [
            "pm_rtos/proj/sc/driver/sysdriver/rpmsg-lite"
        ],
        "pm_rtc": [
            "pm_rtos/proj/sc/driver/sysdriver/rtc"
        ],
        "pm_rtcpwc": [
            "pm_rtos/proj/sc/driver/sysdriver/rtcpwc"
        ],
        "pm_saradc": [
            "pm_rtos/proj/sc/driver/sysdriver/saradc"
        ],
        "pm_sdmmc": [
            "pm_rtos/proj/sc/driver/sysdriver/sdmmc"
        ],
        "pm_sysdesc": [
            "pm_rtos/proj/sc/driver/sysdriver/sysdesc"
        ],
        "pm_timer": [
            "pm_rtos/proj/sc/driver/sysdriver/timer"
        ],
        "pm_tsensor": [
            "pm_rtos/proj/sc/driver/sysdriver/tsensor"
        ],
        "pm_uart": [
            "pm_rtos/proj/sc/driver/sysdriver/uart"
        ],
        "pm_usb_gadget_udc_usb20": [
            "pm_rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usb20"
        ],
        "pm_usb_gadget_udc_usb30": [
            "pm_rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usb30"
        ],
        "pm_usbphy_drv": [
            "pm_rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usbphy"
        ],
        "pm_usbhost": [
            "pm_rtos/proj/sc/driver/sysdriver/usbhost"
        ],
        "pm_voltage": [
            "pm_rtos/proj/sc/driver/sysdriver/voltage"
        ],
        "pm_watchdog": [
            "pm_rtos/proj/sc/driver/sysdriver/watchdog"
        ],
        "pm_decompress": [
            "pm_rtos/proj/sc/middleware/decompress"
        ],
        "pm_firmwarefs": [
            "pm_rtos/proj/sc/middleware/fs/firmwarefs"
        ],
        "pm_freertos_plus_fat": [
            "pm_rtos/proj/sc/middleware/fs/Lab-Project-FreeRTOS-FAT"
        ],
        "pm_littlefs": [
            "pm_rtos/proj/sc/middleware/fs/littlefs"
        ],
        "pm_lwfs": [
            "pm_rtos/proj/sc/middleware/fs/lwfs"
        ],
        "pm_proxyfs": [
            "pm_rtos/proj/sc/middleware/fs/proxyfs"
        ],
        "pm_tcpip": [
            "pm_rtos/proj/sc/middleware/tcpip"
        ],
        "pm_arm": [
            "pm_rtos/proj/sc/system/arch"
        ],
        "pm_riscv": [
            "pm_rtos/proj/sc/system/riscv"
        ],
        "pm_cam_dev_wrapper": [
            "pm_rtos/proj/sc/system/cam_dev_wrapper"
        ],
        "pm_cam_drv_poll": [
            "pm_rtos/proj/sc/system/cam_drv_poll"
        ],
        "pm_cam_fs_wrapper": [
            "pm_rtos/proj/sc/system/cam_fs_wrapper"
        ],
        "pm_cam_os_wrapper": [
            "pm_rtos/proj/sc/system/cam_os_wrapper"
        ],
        "pm_cam_proc_wrapper": [
            "pm_rtos/proj/sc/system/cam_proc_wrapper"
        ],
        "pm_env_util": [
            "pm_rtos/proj/sc/system/env_util"
        ],
        "pm_initcall": [
            "pm_rtos/proj/sc/system/initcall"
        ],
        "pm_libc": [
            "pm_rtos/proj/sc/system/libc"
        ],
        "pm_memmang": [
            "pm_rtos/proj/sc/system/memmang"
        ],
        "pm_memmap": [
            "pm_rtos/proj/sc/system/memmap"
        ],
        "pm_mempool": [
            "pm_rtos/proj/sc/system/mempool"
        ],
        "pm_MsWrapper": [
            "pm_rtos/proj/sc/system/MsWrapper"
        ],
        "pm_freertos": [
            "pm_rtos/proj/sc/system/rtos/freertos"
        ],
        "pm_freertos_posix": [
            "pm_rtos/proj/sc/system/rtos/freertos_posix"
        ],
        "pm_sys_I_SW": [
            "pm_rtos/proj/sc/system/sys"
        ],
        "pm_mhal_pm_default": [
            "pm_rtos/proj/sc/driver/camdriver/common"
        ],
        "pm_mhal_imi_heap": [
            "pm_rtos/proj/sc/driver/sysdriver/imi_heap"
        ],
        "pm_mhal_pm_aio": [
            "pm_rtos/proj/sc/driver/camdriver/pm_aio"
        ],
        "pm_mhal_pm_idle": [
            "pm_rtos/proj/sc/driver/camdriver/pm_idle"
        ],
        "pm_mhal_pm_isp": [
            "pm_rtos/proj/sc/driver/camdriver/pm_isp"
        ],
        "pm_mhal_pm_ispalgo": [
            "pm_rtos/proj/sc/driver/camdriver/pm_ispalgo"
        ],
        "pm_mhal_pm_jpe": [
            "pm_rtos/proj/sc/driver/camdriver/pm_jpe"
        ],
        "pm_mhal_pm_md": [
            "pm_rtos/proj/sc/driver/camdriver/pm_md"
        ],
        "pm_mhal_pm_pir": [
            "pm_rtos/proj/sc/driver/sysdriver/pm_pir"
        ],
        "pm_mhal_pm_radar": [
            "pm_rtos/proj/sc/driver/camdriver/pm_radar"
        ],
        "pm_mhal_pm_radar_algo": [
            "pm_rtos/proj/sc/driver/camdriver/pm_radar_algo"
        ],
        "pm_mhal_pm_usb_gadget_udc_usb30": [
            "pm_rtos/proj/sc/driver/sysdriver/usb_gadget/udc/usb30"
        ],
        "pm_mhal_pm_usbpoc": [
            "pm_rtos/proj/sc/driver/camdriver/pm_usbpoc"
        ],
        "pm_mhal_pm_vif": [
            "pm_rtos/proj/sc/driver/camdriver/pm_vif"
        ]
    }

    def check(self) -> bool:
        for key, value in self.items():
            if not isinstance(value, list):
                raise ValueError(f"Invalid value type for {key}: {type(value)}")
            for item in value:
                if not isinstance(item, str):
                    raise ValueError(f"Invalid item type for {key}: {type(item)}")
                # 格式化路径 将一些动态路径在运行时确定下来
                file = self._path_format(item)
                if not check_file_exists(file):
                    log.warning(f"{self.__class__.__name__} config [{file}] not exists")
                self[key] = file # 将格式化后的路径更新到_dict中
        return True
    
    def _path_format(self, item: str) -> str:
        return str_format(Path(ReleaseOptions.AlkaidRootPath) / item)


def str_format(item: Any) -> str:
    """格式化字符串，将字符串中的{key}替换为ReleaseOptions._dict[key]
    我们目的是将一些会跟随实际chip分支会变化的文件路径在运行时才确定下来
    ## 例如：
    ```python
    item = "sdk/verify/sample_code/source/{SWBoardAlias}/preload/rtos"
    item = str_format(item)
    print(item)
    ```
    ## 输出：
    sdk/verify/sample_code/source/iford/preload/rtos

    Args:
        item (str): 需要格式化的字符串

    Returns:
        str: 格式化后的字符串
    """
    item = str(item)
    if '{' in item:
        # log.info(f"format item: {item}")
        item = item.format(**ReleaseOptions._dict)  # 使用keyargs的方式格式化字符串
        # log.info(f"formated item: {item} use {ReleaseOptions._dict}")
    return item

def CheckDirAliasDecorator(cls):
    """配置检查装饰器：检查配置类中的所有项是否在 DirAlias 中存在, 如果是一个路径则检查其是否存在
       例如：
       ```python
       @CheckDirAliasDecorator
       class Test(BaseConfig):
           _config = ["mi_sys", "mi_isp", "sdk/verify/sample_code/source/{SWBoardAlias}/preload/rtos"]
       ```
       那么会检查mi_sys和mi_isp是否在DirAlias中存在，如果存在则返回True，否则返回False
       同时会检查sdk/verify/sample_code/source/{SWBoardAlias}/preload/rtos是否存在
    Args:
        cls: 被装饰的类
    Returns:
        cls: 装饰后的类
    """
    original_check = cls.check
    @wraps(original_check)
    def wrapped_check(self) -> bool:
        for item in self:
            # 如果不是一个路径那么判断其是否在DirAlias中存在
            if '/' not in item and not DirAlias[item]:
                raise ValueError(f"{item} not found in DirAlias")
            # 如果是路径那么判断其是否存在
            if '/' in item:
                if not check_file_exists(item):
                    log.warning(f"{self.__class__.__name__} config [{item}] not exists")
        return True
    cls.check = wrapped_check
    return cls