diff --git a/.keyboardio-builder.conf b/.keyboardio-builder.conf index 2959a79f..90bc5472 100644 --- a/.keyboardio-builder.conf +++ b/.keyboardio-builder.conf @@ -1,11 +1,11 @@ # -*- mode: sh -*- generate_keymaps () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh - rm -f generated/keymaps.h - (cd layouts && ( find . -type f | sort | xargs -n 1 -I % sh -c 'perl ../../../tools/generate_keymaps.pl < % >> ../generated/keymaps.h' )) + rm -f examples/KeyboardioFirmware/generated/keymaps.h + (cd examples/KeyboardioFirmware/layouts && \ + ( find . -type f | sort | xargs -n 1 -I % sh -c 'perl ../../../tools/generate_keymaps.pl < % >> ../generated/keymaps.h' )) } EXTRA_BUILDER_ARGS="-libraries ${SOURCEDIR}/libraries" diff --git a/tools/keyboardio-builder b/tools/keyboardio-builder index 0641b739..07fe2b12 100755 --- a/tools/keyboardio-builder +++ b/tools/keyboardio-builder @@ -59,7 +59,6 @@ find_sketch () { } flash () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh echo "Press ENTER when ready..." @@ -68,12 +67,9 @@ flash () { reset_device sleep 3s avrdude -q -q -p${MCU} -cavr109 -D -P ${DEVICE_PORT_BOOTLOADER} -b57600 "-Uflash:w:${HEX_FILE_PATH}:i" - - cd "${SOURCEDIR}" } program () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh echo "Press ENTER when ready..." @@ -85,12 +81,9 @@ program () { -D \ -B 1 \ "-Uflash:w:${HEX_FILE_PATH}:i" - - cd "${SOURCEDIR}" } hex_with_bootloader () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh cat ${HEX_FILE_PATH} | awk '/^:00000001FF/ == 0' > ${HEX_FILE_WITH_BOOTLOADER_PATH} @@ -105,8 +98,6 @@ Make sure you have the bootloader version you expect. And TEST THIS ON REAL HARDWARE BEFORE YOU GIVE IT TO ANYONE EOF - - cd "${SOURCEDIR}" } build () { @@ -115,7 +106,6 @@ build () { } compile () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh install -d "${OUTPUT_PATH}" @@ -141,15 +131,13 @@ compile () { ${ARDUINO_VERBOSE} \ -prefs "compiler.cpp.extra_flags=-std=c++11 -Woverloaded-virtual -Wno-unused-parameter -Wno-unused-variable -Wno-ignored-qualifiers" \ ${ARDUINO_AVR_GCC_PREFIX_PARAM} \ - "${SKETCH}.ino" + "$(find_sketch)/${SKETCH}.ino" cp "${BUILD_PATH}/${SKETCH}.ino.hex" "${HEX_FILE_PATH}" cp "${BUILD_PATH}/${SKETCH}.ino.elf" "${ELF_FILE_PATH}" ln -sf "${OUTPUT_FILE_PREFIX}.hex" "${OUTPUT_PATH}/${SKETCH}-latest.hex" ln -sf "${OUTPUT_FILE_PREFIX}.elf" "${OUTPUT_PATH}/${SKETCH}-latest.elf" rm -rf "${BUILD_PATH}" - - cd "${SOURCEDIR}" } _find_all () { @@ -176,50 +164,35 @@ build_all () { } report_size () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh echo "- Size: firmware/${LIBRARY}/${OUTPUT_FILE_PREFIX}.elf" firmware_size "${AVR_SIZE}" -C --mcu="${MCU}" "${ELF_FILE_PATH}" echo - - cd "${SOURCEDIR}" } size_map () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh "${AVR_NM}" --size-sort -C -r -l "${ELF_FILE_PATH}" - - cd "${SOURCEDIR}" } decompile () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh "${AVR_OBJDUMP}" -d "${ELF_FILE_PATH}" - - cd "${SOURCEDIR}" } clean () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh rm -rf "${OUTPUT_PATH}" - - cd "${SOURCEDIR}" } reset_device () { - cd "$(find_sketch)" . ${ROOT}/tools/settings.sh ${RESET_DEVICE} - - cd "${SOURCEDIR}" } usage () { diff --git a/tools/settings.sh b/tools/settings.sh index d07a8f39..660df139 100644 --- a/tools/settings.sh +++ b/tools/settings.sh @@ -44,8 +44,8 @@ BUILD_PATH="${BUILD_PATH:-$(mktemp -d 2>/dev/null || mktemp -d -t 'build')}" OUTPUT_DIR="${OUTPUT_DIR:-output/${LIBRARY}}" OUTPUT_PATH="${OUTPUT_PATH:-${SOURCEDIR}/${OUTPUT_DIR}}" -GIT_VERSION="$(git describe --abbrev=4 --dirty --always)" -LIB_VERSION="$( (grep version= ../../library.properties 2>/dev/null || echo version=0.0.0) | cut -d= -f2)-g${GIT_VERSION}" +GIT_VERSION="$(cd $(find_sketch); git describe --abbrev=4 --dirty --always)" +LIB_VERSION="$(cd $(find_sketch); (grep version= ../../library.properties 2>/dev/null || echo version=0.0.0) | cut -d= -f2)-g${GIT_VERSION}" OUTPUT_FILE_PREFIX="${SKETCH}-${LIB_VERSION}"