From cca69ce86d807116c36143e00445b6048f96583b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 23 Oct 2020 23:07:04 -0700 Subject: [PATCH] move find_bootloader_port and find_device_port to the kaleidoscope-builder --- bin/kaleidoscope-builder | 51 +++++++++++++++++++++++++++++++++++ etc/kaleidoscope-builder.conf | 48 --------------------------------- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index 987c2122..e3fc4e3b 100644 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -623,6 +623,57 @@ reset_device() { reset_device_cmd } + +find_bootloader_ports() { + if [ -n "${DEVICE_PORT_BOOTLOADER}" ]; then + echo "DEVICE_PORT_BOOTLOADER=\"${DEVICE_PORT_BOOTLOADER}\" predefined." + return + fi + + find_device_vid_pid + : "${BOOTLOADER_VID:=${VID}}" + if [ "${uname_S}" = "Darwin" ]; then + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-macos" + DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${BOOTLOADER_VID} ${BOOTLOADER_PID})" + elif [ "${uname_O}" = "Cygwin" ]; then + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-windows.ps1" + DEVICE_PORT_BOOTLOADER="$(powershell -noprofile -executionpolicy bypass ${DEVICE_PORT_PROBER} ${BOOTLOADER_VID} ${BOOTLOADER_PID} -Format COM)" + elif [ "${uname_S}" = "FreeBSD" ]; then + DEVICE_PORT_PROBER="${KALEIDOSCPE_BIN_DIR}/find-device-port-freebsd" + DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER})" + + else + + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-linux-udev" + DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${BOOTLOADER_VID} ${BOOTLOADER_PID})" + fi +} + + +find_device_port() { + if [ -n "${DEVICE_PORT}" ]; then + echo "DEVICE_PORT=\"${DEVICE_PORT}\" predefined." + return + fi + + find_device_vid_pid + if [ "${uname_S}" = "Darwin" ]; then + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-macos" + DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})" + elif [ "${uname_O}" = "Cygwin" ]; then + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-windows.ps1" + DEVICE_PORT="$(powershell -noprofile -executionpolicy bypass ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID} -Format Cygwin)" + DEVICE_COM_PORT="$(powershell -noprofile -executionpolicy bypass ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID} -Format COM)" + elif [ "${uname_S}" = "FreeBSD" ]; then + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-freebsd" + DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER})" + else + DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-linux-udev" + DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})" + fi +} + + check_device_port() { if [ -z "$DEVICE_PORT" ]; then cat <&2 diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf index da4cd1f3..97046b23 100644 --- a/etc/kaleidoscope-builder.conf +++ b/etc/kaleidoscope-builder.conf @@ -21,54 +21,6 @@ fi : "${FQBN:=keyboardio:${ARCH}:${BOARD}}" -find_device_port() { - if [ -n "${DEVICE_PORT}" ]; then - echo "DEVICE_PORT=\"${DEVICE_PORT}\" predefined." - return - fi - - find_device_vid_pid - if [ "${uname_S}" = "Darwin" ]; then - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-macos" - DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})" - elif [ "${uname_O}" = "Cygwin" ]; then - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-windows.ps1" - DEVICE_PORT="$(powershell -noprofile -executionpolicy bypass ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID} -Format Cygwin)" - DEVICE_COM_PORT="$(powershell -noprofile -executionpolicy bypass ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID} -Format COM)" - elif [ "${uname_S}" = "FreeBSD" ]; then - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-freebsd" - DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER})" - else - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-linux-udev" - DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})" - fi -} - -find_bootloader_ports() { - if [ -n "${DEVICE_PORT_BOOTLOADER}" ]; then - echo "DEVICE_PORT_BOOTLOADER=\"${DEVICE_PORT_BOOTLOADER}\" predefined." - return - fi - - find_device_vid_pid - : "${BOOTLOADER_VID:=${VID}}" - if [ "${uname_S}" = "Darwin" ]; then - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-macos" - DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${BOOTLOADER_VID} ${BOOTLOADER_PID})" - elif [ "${uname_O}" = "Cygwin" ]; then - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-windows.ps1" - DEVICE_PORT_BOOTLOADER="$(powershell -noprofile -executionpolicy bypass ${DEVICE_PORT_PROBER} ${BOOTLOADER_VID} ${BOOTLOADER_PID} -Format COM)" - elif [ "${uname_S}" = "FreeBSD" ]; then - DEVICE_PORT_PROBER="${KALEIDOSCPE_BIN_DIR}/find-device-port-freebsd" - DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER})" - - else - - DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-linux-udev" - DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${BOOTLOADER_VID} ${BOOTLOADER_PID})" - fi -} - if [ "${uname_S}" = "FreeBSD" ]; then : "${AVR_SIZE:=/usr/local/bin/avr-size}" : "${AVR_NM:=/usr/local/bin/avr-nm}"