From 34b428c4a94d9a98ea53decc92d3d88fc229735e Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 17 Oct 2020 00:00:16 -0700 Subject: [PATCH] Simplify conditional building --- bin/kaleidoscope-builder | 52 ++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index 427bf27d..26fbd174 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -171,7 +171,7 @@ prompt_before_flashing () { } flash () { - maybe_build "$@" + compile "$@" # Check to see if we can see a keyboard bootloader port. # If we -can-, then we should skip over the "reset to bootloader" thing @@ -277,14 +277,14 @@ flash_over_usb () { } flash_from_bootloader() { - maybe_build "$@" + compile "$@" prompt_before_flashing find_bootloader_ports check_bootloader_port_and_flash } program() { - maybe_build "$@" + compile "$@" prompt_before_flashing flash_with_programmer } @@ -307,9 +307,7 @@ find_bootloader_path() { hex_with_bootloader () { - if [ ! -e "${HEX_FILE_PATH}" ]; then - compile - fi + compile find_bootloader_path @@ -328,7 +326,17 @@ hex_with_bootloader () { EOF } -maybe_build () { +build () { + compile "$@" + size "$@" +} + + +prepare_ccache () { + build_paths + enable_ccache +} +compile () { find_sketch build_version build_paths @@ -338,27 +346,14 @@ maybe_build () { # But it's less broken for most user use cases # TODO(anyone): Make this suck less if [ "${HEX_FILE_PATH}" -ot "${SKETCH_FILE_PATH}" ]; then - build "$@" + do_compile "$@" fi } -build () { - compile "$@" - size "$@" -} - - -prepare_ccache () { - build_paths - enable_ccache -} -compile () { - find_sketch - build_version +do_compile () { prepare_ccache - build_filenames install -d "${OUTPUT_PATH}" @@ -492,9 +487,7 @@ compile_all () { size () { - if [ ! -e "${HEX_FILE_PATH}" ]; then - compile - fi + compile echo "- Size: ${ELF_FILE_PATH}" # shellcheck disable=SC2086 @@ -503,18 +496,13 @@ size () { } size_map () { - if [ ! -e "${HEX_FILE_PATH}" ]; then - compile - fi + compile "${AVR_NM}" --size-sort -C -r -l -t decimal "${ELF_FILE_PATH}" } disassemble () { - - if [ ! -e "${HEX_FILE_PATH}" ]; then - compile - fi + compile "${AVR_OBJDUMP}" -C -d "${ELF_FILE_PATH}" }