minor refactoring

tmp/arduino-cli-pre-rebase
Jesse Vincent 4 years ago
parent 2fc6b92947
commit 77a40d48de
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -26,15 +26,6 @@ _identify_os() {
uname_O=$(uname -o 2>/dev/null || echo not) uname_O=$(uname -o 2>/dev/null || echo not)
} }
adjust_for_virtual_build() {
if [ "${uname_S}" = "FreeBSD" ]; then
: "${COMPILER_PATH:=/usr/local/bin/}"
else
: "${COMPILER_PATH:=/usr/bin/}"
fi
COMPILER_PREFIX=""
}
@ -108,6 +99,20 @@ run_arduino_cli() {
"${ARDUINO_CLI}" "$@" "${ARDUINO_CLI}" "$@"
} }
_arduino_prop() {
pref=$1
# Strip the preference name. And then strip leading and trailing quotations
_arduino_props | grep --max-count=1 "${pref}=" | sed -e s/^.*"${pref}"=// -e 's/^"//' -e 's/"$//'
}
_arduino_props() {
if [ "x${_ARDUINO_PREFS}x" == "xx" ]; then
_ARDUINO_PREFS=$(run_arduino_cli --fqbn "${FQBN}" compile --show-properties "${SKETCH_FILE_PATH}")
fi
echo "$_ARDUINO_PREFS"
}
_set_executable_paths() { _set_executable_paths() {
###### ######
###### Executable paths ###### Executable paths
@ -227,7 +232,7 @@ flash() {
# Check to see if we can see a keyboard bootloader port. # Check to see if we can see a keyboard bootloader port.
# If we -can-, then we should skip over the "reset to bootloader" thing # If we -can-, then we should skip over the "reset to bootloader" thing
port="${DEVICE_PORT_BOOTLOADER:$(_find_bootloader_port)}" port="${DEVICE_PORT_BOOTLOADER:=$(_find_bootloader_port)}"
if [ -z "${port}" ]; then if [ -z "${port}" ]; then
prompt_before_flashing prompt_before_flashing
@ -235,7 +240,7 @@ flash() {
# shellcheck disable=SC2154 # shellcheck disable=SC2154
${preFlash_HOOKS} ${preFlash_HOOKS}
port="${DEVICE_PORT:$(_find_device_port)}" port="${DEVICE_PORT:=$(_find_device_port)}"
fi fi
run_arduino_cli upload \ run_arduino_cli upload \
--fqbn "${FQBN}" \ --fqbn "${FQBN}" \
@ -332,19 +337,6 @@ compile() {
FQBN="${SAVED_FQBN}" FQBN="${SAVED_FQBN}"
} }
_arduino_prop() {
pref=$1
# Strip the preference name. And then strip leading and trailing quotations
_arduino_props | grep --max-count=1 "${pref}=" | sed -e s/^.*"${pref}"=// -e 's/^"//' -e 's/"$//'
}
_arduino_props() {
if [ "x${_ARDUINO_PREFS}x" == "xx" ]; then
_ARDUINO_PREFS=$(run_arduino_cli --fqbn "${FQBN}" compile --show-properties "${SKETCH_FILE_PATH}")
fi
echo "$_ARDUINO_PREFS"
}
size_map() { size_map() {
find_sketch find_sketch
ensure_sketch_found ensure_sketch_found
@ -371,19 +363,10 @@ clean() {
} }
_find_bootloader_port() { _find_bootloader_port() {
if [ -n "${DEVICE_PORT_BOOTLOADER}" ]; then
echo "DEVICE_PORT_BOOTLOADER=\"${DEVICE_PORT_BOOTLOADER}\" predefined."
return
fi
_probe_port "$(_arduino_prop 'build.vid')" "$( _arduino_prop 'bootloader.pid' || _arduino_prop 'build.pid')" _probe_port "$(_arduino_prop 'build.vid')" "$( _arduino_prop 'bootloader.pid' || _arduino_prop 'build.pid')"
} }
_find_device_port() { _find_device_port() {
if [ -n "${DEVICE_PORT}" ]; then
echo "DEVICE_PORT=\"${DEVICE_PORT}\" predefined."
return
fi
_probe_port "$(_arduino_prop 'build.vid')" "$( _arduino_prop 'build.pid')" _probe_port "$(_arduino_prop 'build.vid')" "$( _arduino_prop 'build.pid')"
} }
@ -451,10 +434,7 @@ if [ -n "${BOARD_HARDWARE_PATH}" ]; then
ARDUINO_DIRECTORIES_USER="${BOARD_HARDWARE_PATH}/../" ARDUINO_DIRECTORIES_USER="${BOARD_HARDWARE_PATH}/../"
fi fi
: "${KALEIDOSCOPE_DIR:=$( : "${KALEIDOSCOPE_DIR:=$( cd "$(dirname "$0")"/.. pwd)}"
cd "$(dirname "$0")"/..
pwd
)}"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
: "${KALEIDOSCOPE_BIN_DIR:=${KALEIDOSCOPE_DIR}/bin/}" : "${KALEIDOSCOPE_BIN_DIR:=${KALEIDOSCOPE_DIR}/bin/}"
@ -470,17 +450,23 @@ else
ARDUINO_VERBOSE="--quiet" ARDUINO_VERBOSE="--quiet"
fi fi
: "${BOARD:=model01}"
if [[ -z "${ARCH}" && -n "${FQBN}" ]]; then if [[ -z "${ARCH}" && -n "${FQBN}" ]]; then
ARCH=$(echo "${FQBN}" | sed -n -e 's/^[^:]\+:\([^:]\+\).*/\1/p') ARCH=$(echo "${FQBN}" | sed -n -e 's/^[^:]\+:\([^:]\+\).*/\1/p')
fi fi
: "${BOARD:=model01}"
: "${ARCH:=avr}" : "${ARCH:=avr}"
: "${FQBN:=keyboardio:${ARCH}:${BOARD}}" : "${FQBN:=keyboardio:${ARCH}:${BOARD}}"
if [ "${ARCH}" = "virtual" ]; then if [ "${ARCH}" = "virtual" ]; then
adjust_for_virtual_build if [ "${uname_S}" = "FreeBSD" ]; then
: "${COMPILER_PATH:=/usr/local/bin/}"
else
: "${COMPILER_PATH:=/usr/bin/}"
fi
COMPILER_PREFIX=""
fi fi
## Parse the command-line ## Parse the command-line

Loading…
Cancel
Save