From 856d7a91a80dcf7cbd73fe7cbb35112c59b99ece Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 12 Nov 2020 11:14:47 -0800 Subject: [PATCH] extract out commonalities between various things that do stuff with sketches --- bin/kaleidoscope-builder | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index f234117e..f7251d92 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -225,10 +225,7 @@ _prompt_before_flashing() { flash() { - _find_sketch - _ensure_sketch_found - _set_build_paths - _set_executable_paths + _set_up_environment # Check to see if we can see a keyboard bootloader port. @@ -254,10 +251,7 @@ flash() { hex_with_bootloader() { - _find_sketch - _ensure_sketch_found - _set_build_paths - _set_executable_paths + _set_up_environment : "${BOOTLOADER_PATH:=$(_arduino_prop 'runtime.platform.path')/bootloaders/$(_arduino_prop 'bootloader.file')}" @@ -276,10 +270,7 @@ hex_with_bootloader() { } compile() { - _find_sketch - _ensure_sketch_found - _set_build_paths - _set_executable_paths + _set_up_environment install -d "${OUTPUT_PATH}" @@ -340,29 +331,27 @@ compile() { } size_map() { - _find_sketch - _ensure_sketch_found - _set_build_paths - _set_executable_paths + _set_up_environment "${AVR_NM}" --size-sort -C -r -l -t decimal "${ELF_FILE_PATH}" } disassemble() { - _find_sketch - _ensure_sketch_found - _set_build_paths - _set_executable_paths + _set_up_environment "${AVR_OBJDUMP}" -C -d "${ELF_FILE_PATH}" } clean() { + _set_up_environment + if [ -d "$OUTPUT_PATH" ]; then + rm -rf -- "${OUTPUT_PATH}" + fi +} + +_set_up_environment() { _find_sketch _ensure_sketch_found _set_build_paths _set_executable_paths - if [ -d "$OUTPUT_PATH" ]; then - rm -rf -- "${OUTPUT_PATH}" - fi } _find_bootloader_port() {