diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index f5f29b2f..9fe58c27 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -30,10 +30,6 @@ install_arduino_cli() { curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh } -compile_arduino_cli() { - run_arduino_cli compile --fqbn keyboardio:avr:keyboardio_atreus --libraries "${KALEIDOSCOPE_DIR}/.." examples/Devices/Keyboardio/Atreus --verbose --show-properties -} - configure_arduino_cli() { if [ -z "${ARDUINO_CLI}" ]; then install_arduino_cli @@ -393,6 +389,9 @@ compile () { # TODO(anyone): Make this suck less if [ "${HEX_FILE_PATH}" -ot "${SKETCH_FILE_PATH}" ]; then do_compile "$@" + else + echo "${HEX_FILE_PATH} did not need to be rebuilt" + do_compile "$@" fi } @@ -442,6 +441,29 @@ do_compile () { _CMD_CC="${CC:-${COMPILER_PREFIX}${C_COMPILER_BASENAME}${COMPILER_SUFFIX}}" _CMD_AR="${AR:-${COMPILER_PREFIX}${AR_BASENAME}${COMPILER_SUFFIX}}" + #do_compile_with_builder + do_compile_with_cli + + if [ -z "${LIBONLY}" ]; then + cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.hex" "${HEX_FILE_PATH}" + cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.elf" "${ELF_FILE_PATH}" + ln -sf "${OUTPUT_FILE_PREFIX}.hex" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.hex" + ln -sf "${OUTPUT_FILE_PREFIX}.elf" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.elf" + else + cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.a" "${LIB_FILE_PATH}" + ln -sf "${OUTPUT_FILE_PREFIX}.a" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.a" + fi + + if [ "${ARDUINO_VERBOSE}" = "-verbose" ]; then + echo "Build artifacts can be found in ${BUILD_PATH}"; + fi + + BOARD="${SAVED_BOARD}" + FQBN="${SAVED_FQBN}" +} + +do_compile_with_builder() { + # SC2091: We do not care if quotes or backslashes are not respected. # SC2086: We want word splitting. # shellcheck disable=SC2086,SC2090 @@ -473,25 +495,21 @@ do_compile () { ${ARDUINO_VERBOSE} \ ${ARDUINO_AVR_GCC_PREFIX_PARAM} \ "${SKETCH_FILE_PATH}" +} - if [ -z "${LIBONLY}" ]; then - cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.hex" "${HEX_FILE_PATH}" - cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.elf" "${ELF_FILE_PATH}" - ln -sf "${OUTPUT_FILE_PREFIX}.hex" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.hex" - ln -sf "${OUTPUT_FILE_PREFIX}.elf" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.elf" - else - cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.a" "${LIB_FILE_PATH}" - ln -sf "${OUTPUT_FILE_PREFIX}.a" "${OUTPUT_PATH}/${SKETCH_BASE_NAME}-latest.a" - fi - if [ "${ARDUINO_VERBOSE}" = "-verbose" ]; then - echo "Build artifacts can be found in ${BUILD_PATH}"; - fi - BOARD="${SAVED_BOARD}" - FQBN="${SAVED_FQBN}" +do_compile_with_cli() { + run_arduino_cli compile \ + --fqbn "${FQBN}" \ + --libraries "${KALEIDOSCOPE_DIR}/.." \ + --build-path=${BUILD_PATH} \ + --output-dir=${OUTPUT_PATH} \ + --verbose \ + "${SKETCH_FILE_PATH}" } + find_all_sketches () { for plugin in ./*.ino \ $([ -d examples ] && find examples -name '*.ino') \ @@ -687,10 +705,10 @@ fi SYSTEM_ARDUINO_CLI="$(command -v arduino-cli || true )" if [ "x${SYSTEM_ARDUINO_CLI}" == "x" ]; then - $VERBOSE && echo "Using our own arduino-cli" + echo "Using our own arduino-cli" : "${ARDUINO_CLI:=${KALEIDOSCOPE_BIN_DIR}/arduino-cli}" else - $VERBOSE && echo "Using system arduino-cli from ${SYSTEM_ARDUINO_CLI}" + echo "Using system arduino-cli from ${SYSTEM_ARDUINO_CLI}" : "${ARDUINO_CLI:=${SYSTEM_ARDUINO_CLI}}" fi