tmp/arduino-cli-pre-rebase
Jesse Vincent 4 years ago
parent 09b5c613ee
commit 928f02fdbd
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -47,8 +47,6 @@ else
: "${ARDUINO_CLI:=${SYSTEM_ARDUINO_CLI}}" : "${ARDUINO_CLI:=${SYSTEM_ARDUINO_CLI}}"
fi fi
: "${ARDUINO_CONTENT:=${KALEIDOSCOPE_DIR}/.arduino}" : "${ARDUINO_CONTENT:=${KALEIDOSCOPE_DIR}/.arduino}"
: "${ARDUINO_DIRECTORIES_DATA:=${ARDUINO_CONTENT}/data}" : "${ARDUINO_DIRECTORIES_DATA:=${ARDUINO_CONTENT}/data}"
: "${ARDUINO_DIRECTORIES_DOWNLOADS:=${ARDUINO_CONTENT}/downloads}" : "${ARDUINO_DIRECTORIES_DOWNLOADS:=${ARDUINO_CONTENT}/downloads}"
@ -57,7 +55,6 @@ fi
: "${ARDUINO_BOARDS_MANAGER_KALEIDOSCOPE:=https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json}" : "${ARDUINO_BOARDS_MANAGER_KALEIDOSCOPE:=https://raw.githubusercontent.com/keyboardio/boardsmanager/master/package_keyboardio_index.json}"
} }
install_arduino_cli() { install_arduino_cli() {
# todo cd to kaleidoscope dir # todo cd to kaleidoscope dir
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
@ -90,7 +87,6 @@ install_arduino_core() {
run_arduino_cli core install "$1" run_arduino_cli core install "$1"
} }
run_arduino_cli() { run_arduino_cli() {
ARDUINO_DIRECTORIES_USER=${ARDUINO_DIRECTORIES_USER} \ ARDUINO_DIRECTORIES_USER=${ARDUINO_DIRECTORIES_USER} \
ARDUINO_DIRECTORIES_DATA=${ARDUINO_DIRECTORIES_DATA} \ ARDUINO_DIRECTORIES_DATA=${ARDUINO_DIRECTORIES_DATA} \
@ -101,8 +97,14 @@ run_arduino_cli() {
build_version() { build_version() {
: "${LIB_PROPERTIES_PATH:="../.."}" : "${LIB_PROPERTIES_PATH:="../.."}"
GIT_VERSION="$(cd "${SKETCH_DIR}"; if [ -d .git ]; then echo -n '-g' && git describe --abbrev=4 --dirty --always; fi)" GIT_VERSION="$(
LIB_VERSION="$(cd "${SKETCH_DIR}"; (grep version= "${LIB_PROPERTIES_PATH}/library.properties" 2>/dev/null || echo version=0.0.0) | cut -d= -f2)${GIT_VERSION}" cd "${SKETCH_DIR}"
if [ -d .git ]; then echo -n '-g' && git describe --abbrev=4 --dirty --always; fi
)"
LIB_VERSION="$(
cd "${SKETCH_DIR}"
(grep version= "${LIB_PROPERTIES_PATH}/library.properties" 2>/dev/null || echo version=0.0.0) | cut -d= -f2
)${GIT_VERSION}"
} }
build_paths() { build_paths() {
@ -135,7 +137,6 @@ build_filenames () {
: "${LIB_FILE_PATH:=${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.a}" : "${LIB_FILE_PATH:=${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.a}"
} }
enable_ccache() { enable_ccache() {
if [ -z "${CCACHE_NOT_SUPPORTED}" ] && [ "$(command -v ccache)" ]; then if [ -z "${CCACHE_NOT_SUPPORTED}" ] && [ "$(command -v ccache)" ]; then
if ! [ -d "$CCACHE_WRAPPER_PATH" ]; then if ! [ -d "$CCACHE_WRAPPER_PATH" ]; then
@ -172,7 +173,6 @@ enable_ccache () {
fi fi
} }
firmware_size() { firmware_size() {
if [ "${ARCH}" = "virtual" ]; then if [ "${ARCH}" = "virtual" ]; then
echo "[Size not computed for virtual build]" echo "[Size not computed for virtual build]"
@ -203,7 +203,6 @@ firmware_size () {
fi fi
} }
find_sketch() { find_sketch() {
SKETCH_DIR="${SKETCH:-$(absolute_filename "$(pwd)")}" SKETCH_DIR="${SKETCH:-$(absolute_filename "$(pwd)")}"
SKETCH_BASE_NAME=$(basename "${SKETCH_DIR}") SKETCH_BASE_NAME=$(basename "${SKETCH_DIR}")
@ -224,7 +223,6 @@ find_sketch () {
exit 1 exit 1
} }
find_device_vid_pid() { find_device_vid_pid() {
: "${VID:=$(get_arduino_pref 'build.vid')}" : "${VID:=$(get_arduino_pref 'build.vid')}"
: "${SKETCH_PID:=$(get_arduino_pref 'build.pid')}" : "${SKETCH_PID:=$(get_arduino_pref 'build.pid')}"
@ -232,7 +230,6 @@ find_device_vid_pid() {
: "${BOOTLOADER_VID:=$(get_arduino_pref 'bootloader.vid')}" : "${BOOTLOADER_VID:=$(get_arduino_pref 'bootloader.vid')}"
} }
prompt_before_flashing() { prompt_before_flashing() {
flashing_instructions=$(get_arduino_pref 'build.flashing_instructions') flashing_instructions=$(get_arduino_pref 'build.flashing_instructions')
@ -335,7 +332,6 @@ check_bootloader_port_and_flash () {
return 0 return 0
} }
flash_from_bootloader() { flash_from_bootloader() {
compile "$@" compile "$@"
prompt_before_flashing prompt_before_flashing
@ -395,7 +391,6 @@ build () {
size "$@" size "$@"
} }
prepare_ccache() { prepare_ccache() {
find_sketch find_sketch
build_paths build_paths
@ -419,8 +414,6 @@ compile () {
} }
set_executable_paths() { set_executable_paths() {
###### ######
###### Executable paths ###### Executable paths
@ -451,7 +444,6 @@ AVRDUDE_CMD="${AVRDUDE} -v-C \"${AVRDUDE_CONF}\" -D -p\"$(get_arduino_pref 'buil
} }
do_compile() { do_compile() {
prepare_ccache prepare_ccache
@ -463,7 +455,6 @@ do_compile () {
# shellcheck disable=SC2154 # shellcheck disable=SC2154
${compile_HOOKS} ${compile_HOOKS}
SAVED_BOARD="${BOARD}" SAVED_BOARD="${BOARD}"
SAVED_FQBN="${FQBN}" SAVED_FQBN="${FQBN}"
if [ -e "${SKETCH_DIR}/.kaleidoscope-builder.conf" ]; then if [ -e "${SKETCH_DIR}/.kaleidoscope-builder.conf" ]; then
@ -477,7 +468,6 @@ do_compile () {
fi fi
fi fi
do_compile_with_cli do_compile_with_cli
if [ -z "${LIBONLY}" ]; then if [ -z "${LIBONLY}" ]; then
@ -491,7 +481,7 @@ do_compile () {
fi fi
if [ "${ARDUINO_VERBOSE}" == "--verbose" ]; then if [ "${ARDUINO_VERBOSE}" == "--verbose" ]; then
echo "Build artifacts can be found in ${BUILD_PATH}"; echo "Build artifacts can be found in ${BUILD_PATH}"
fi fi
BOARD="${SAVED_BOARD}" BOARD="${SAVED_BOARD}"
@ -505,7 +495,6 @@ get_arduino_pref() {
echo "$MESSAGE" echo "$MESSAGE"
} }
dump_arduino_prefs() { dump_arduino_prefs() {
if [ "x${_ARDUINO_PREFS}x" == "xx" ]; then if [ "x${_ARDUINO_PREFS}x" == "xx" ]; then
_ARDUINO_PREFS=$(run_arduino_cli --fqbn "${FQBN}" compile --show-properties "${SKETCH_FILE_PATH}") _ARDUINO_PREFS=$(run_arduino_cli --fqbn "${FQBN}" compile --show-properties "${SKETCH_FILE_PATH}")
@ -513,7 +502,6 @@ dump_arduino_prefs() {
echo "$_ARDUINO_PREFS" echo "$_ARDUINO_PREFS"
} }
do_compile_with_cli() { do_compile_with_cli() {
#-build-cache "${CORE_CACHE_PATH}" \ #-build-cache "${CORE_CACHE_PATH}" \
@ -541,7 +529,6 @@ do_compile_with_cli() {
"${SKETCH_FILE_PATH}" "${SKETCH_FILE_PATH}"
} }
find_all_sketches() { find_all_sketches() {
for sketch_name in ./*.ino \ for sketch_name in ./*.ino \
$([ -d examples ] && find examples -name '*.ino') \ $([ -d examples ] && find examples -name '*.ino') \
@ -571,7 +558,6 @@ build_all () {
done done
} }
size() { size() {
compile compile
@ -667,7 +653,6 @@ EOF
fi fi
} }
usage() { usage() {
cat <<-EOF cat <<-EOF
Usage: $0 SKETCH commands... Usage: $0 SKETCH commands...
@ -715,15 +700,16 @@ if [ $# -lt 1 ]; then
exit 1 exit 1
fi fi
# Temporary migration for old makefiles # Temporary migration for old makefiles
# I'm not thrilled about how we default to system Arduino dirs. # I'm not thrilled about how we default to system Arduino dirs.
if [ -n "${BOARD_HARDWARE_PATH}" ]; then 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/}"
@ -738,7 +724,6 @@ else
ARDUINO_VERBOSE="--quiet" ARDUINO_VERBOSE="--quiet"
fi fi
## Parse the command-line ## Parse the command-line
## - anything that has a =, is an env var ## - anything that has a =, is an env var
## - from the remaining stuff, the first one is the Library/Sketch ## - from the remaining stuff, the first one is the Library/Sketch
@ -746,7 +731,6 @@ fi
## ##
## - if there is only one argument, that's a command ## - if there is only one argument, that's a command
cmds="" cmds=""
## Export vars ## Export vars

@ -30,8 +30,6 @@ fi
uname_S=$(uname -s 2>/dev/null || echo not) uname_S=$(uname -s 2>/dev/null || echo not)
uname_O=$(uname -o 2>/dev/null || echo not) uname_O=$(uname -o 2>/dev/null || echo not)
find_device_port() { find_device_port() {
find_device_vid_pid find_device_vid_pid
DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-linux-udev" DEVICE_PORT_PROBER="${KALEIDOSCOPE_BIN_DIR}/find-device-port-linux-udev"
@ -59,8 +57,6 @@ find_bootloader_ports() {
fi fi
} }
if [ "${uname_S}" = "Darwin" ]; then if [ "${uname_S}" = "Darwin" ]; then
find_device_port() { find_device_port() {
@ -72,7 +68,6 @@ if [ "${uname_S}" = "Darwin" ]; then
/bin/stty -f ${DEVICE_PORT} 1200 /bin/stty -f ${DEVICE_PORT} 1200
} }
find_bootloader_ports() { find_bootloader_ports() {
find_device_vid_pid find_device_vid_pid
: "${BOOTLOADER_VID:=${VID}}" : "${BOOTLOADER_VID:=${VID}}"
@ -149,4 +144,3 @@ elif [ "${uname_O}" = "Cygwin" ]; then
} }
fi fi

Loading…
Cancel
Save