<commit_before>#!/bin/sh

ESP32_GCC_RELEASE="esp-2021r2-patch3"
ESP32_GCC_VERSION_DIR="8.4.0"

ESP32_OPENOCD_VERSION="v0.11.0-esp32-20211220"

TOOLS_PATH=${IDF_TOOLS_PATH}/tools

export_arch()
{
    case $1 in
        esp32)
            TARGET_ARCH="xtensa-esp32-elf"
            ;;
        esp32c3)
            TARGET_ARCH="riscv32-esp-elf"
            ;;
        *)
            echo "Unknown architecture $1"
            exit 1
    esac

    TOOLS_DIR=${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}-${ESP32_GCC_VERSION_DIR}/${TARGET_ARCH}
    TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`

    if [ -e ${TOOLS_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
        echo "Extending PATH by ${TOOLS_DIR}/bin"
        export PATH=${TOOLS_DIR}/bin:${PATH}
    fi

    unset TOOLS_DIR
}

export_openocd()
{
    TOOLS_DIR=${TOOLS_PATH}/openocd-esp32/${ESP32_OPENOCD_VERSION}
    TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`
    OPENOCD_DIR=${TOOLS_DIR}/openocd-esp32

    if [ -e ${OPENOCD_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
        echo "Extending PATH by ${TOOLS_DIR}/bin"
        export PATH=${OPENOCD_DIR}/bin:${PATH}
        export OPENOCD="${OPENOCD_DIR}/bin/openocd -s ${OPENOCD_DIR}/share/openocd/scripts"
    fi

    unset TOOLS_DIR
    unset OPENOCD_DIR
}

export_qemu()
{
    # qemu version depends on the version of ncurses lib
    if [ "$(ldconfig -p | grep libncursesw.so.6)" != "" ]; then
        ESP32_QEMU_VERSION="esp-develop-20220203"
    else
        ESP32_QEMU_VERSION="esp-develop-20210220"
    fi

    if [ -z ${IDF_TOOLS_PATH} ]; then
        IDF_TOOLS_PATH=${HOME}/.espressif
    fi

    TOOLS_DIR=${TOOLS_PATH}/qemu-esp32/${ESP32_QEMU_VERSION}/qemu
    TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`

    if [ -e ${TOOLS_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
        echo "Extending PATH by ${TOOLS_DIR}/bin"
        export PATH=${TOOLS_DIR}/bin:${PATH}
    fi

    unset TOOLS_DIR
}
<commit_msg>dist/tools/esptools: qemu-esp32 is only supported on linux-amd64<commit_after>#!/bin/sh

ESP32_GCC_RELEASE="esp-2021r2-patch3"
ESP32_GCC_VERSION_DIR="8.4.0"

ESP32_OPENOCD_VERSION="v0.11.0-esp32-20211220"

TOOLS_PATH=${IDF_TOOLS_PATH}/tools

export_arch()
{
    case $1 in
        esp32)
            TARGET_ARCH="xtensa-esp32-elf"
            ;;
        esp32c3)
            TARGET_ARCH="riscv32-esp-elf"
            ;;
        *)
            echo "Unknown architecture $1"
            exit 1
    esac

    TOOLS_DIR=${TOOLS_PATH}/${TARGET_ARCH}/${ESP32_GCC_RELEASE}-${ESP32_GCC_VERSION_DIR}/${TARGET_ARCH}
    TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`

    if [ -e ${TOOLS_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
        echo "Extending PATH by ${TOOLS_DIR}/bin"
        export PATH=${TOOLS_DIR}/bin:${PATH}
    fi

    unset TOOLS_DIR
}

export_openocd()
{
    TOOLS_DIR=${TOOLS_PATH}/openocd-esp32/${ESP32_OPENOCD_VERSION}
    TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`
    OPENOCD_DIR=${TOOLS_DIR}/openocd-esp32

    if [ -e ${OPENOCD_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
        echo "Extending PATH by ${TOOLS_DIR}/bin"
        export PATH=${OPENOCD_DIR}/bin:${PATH}
        export OPENOCD="${OPENOCD_DIR}/bin/openocd -s ${OPENOCD_DIR}/share/openocd/scripts"
    fi

    unset TOOLS_DIR
    unset OPENOCD_DIR
}

export_qemu()
{
    # determine the platform using python
    PLATFORM_SYSTEM=$(python3 -c "import platform; print(platform.system())")
    PLATFORM_MACHINE=$(python3 -c "import platform; print(platform.machine())")
    PLATFORM=${PLATFORM_SYSTEM}-${PLATFORM_MACHINE}

    # map different platform names to a unique OS name
    case ${PLATFORM} in
        linux-amd64|linux64|Linux-x86_64|FreeBSD-amd64)
            OS=linux-amd64
            ;;
        *)
            echo "error: OS architecture ${PLATFORM} not supported"
            exit 1
            ;;
    esac

    # qemu version depends on the version of ncurses lib
    if [ "$(ldconfig -p | grep libncursesw.so.6)" != "" ]; then
        ESP32_QEMU_VERSION="esp-develop-20220203"
    else
        ESP32_QEMU_VERSION="esp-develop-20210220"
    fi

    if [ -z ${IDF_TOOLS_PATH} ]; then
        IDF_TOOLS_PATH=${HOME}/.espressif
    fi

    TOOLS_DIR=${TOOLS_PATH}/qemu-esp32/${ESP32_QEMU_VERSION}/qemu
    TOOLS_DIR_IN_PATH=`echo $PATH | grep ${TOOLS_DIR}`

    if [ -e ${TOOLS_DIR} ] && [ -z ${TOOLS_DIR_IN_PATH} ]; then
        echo "Extending PATH by ${TOOLS_DIR}/bin"
        export PATH=${TOOLS_DIR}/bin:${PATH}
    fi

    unset TOOLS_DIR
}

{'fraction_non_alphanumeric': 0.13844444444444445, 'fraction_numerical': 0.038, 'mean_word_length': 2.8502994011976046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6513283', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1714, 'n_words': 280}