Simplify conditional building

pull/934/head
Jesse Vincent 4 years ago
parent c98b513636
commit 34b428c4a9
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -171,7 +171,7 @@ prompt_before_flashing () {
} }
flash () { flash () {
maybe_build "$@" compile "$@"
# Check to see if we can see a keyboard bootloader port. # Check to see if we can see a keyboard bootloader port.
# If we -can-, then we should skip over the "reset to bootloader" thing # If we -can-, then we should skip over the "reset to bootloader" thing
@ -277,14 +277,14 @@ flash_over_usb () {
} }
flash_from_bootloader() { flash_from_bootloader() {
maybe_build "$@" compile "$@"
prompt_before_flashing prompt_before_flashing
find_bootloader_ports find_bootloader_ports
check_bootloader_port_and_flash check_bootloader_port_and_flash
} }
program() { program() {
maybe_build "$@" compile "$@"
prompt_before_flashing prompt_before_flashing
flash_with_programmer flash_with_programmer
} }
@ -307,9 +307,7 @@ find_bootloader_path() {
hex_with_bootloader () { hex_with_bootloader () {
if [ ! -e "${HEX_FILE_PATH}" ]; then
compile compile
fi
find_bootloader_path find_bootloader_path
@ -328,7 +326,17 @@ hex_with_bootloader () {
EOF EOF
} }
maybe_build () { build () {
compile "$@"
size "$@"
}
prepare_ccache () {
build_paths
enable_ccache
}
compile () {
find_sketch find_sketch
build_version build_version
build_paths build_paths
@ -338,27 +346,14 @@ maybe_build () {
# But it's less broken for most user use cases # But it's less broken for most user use cases
# TODO(anyone): Make this suck less # TODO(anyone): Make this suck less
if [ "${HEX_FILE_PATH}" -ot "${SKETCH_FILE_PATH}" ]; then if [ "${HEX_FILE_PATH}" -ot "${SKETCH_FILE_PATH}" ]; then
build "$@" do_compile "$@"
fi fi
} }
build () {
compile "$@"
size "$@"
}
prepare_ccache () {
build_paths
enable_ccache
}
compile () { do_compile () {
find_sketch
build_version
prepare_ccache prepare_ccache
build_filenames
install -d "${OUTPUT_PATH}" install -d "${OUTPUT_PATH}"
@ -492,9 +487,7 @@ compile_all () {
size () { size () {
if [ ! -e "${HEX_FILE_PATH}" ]; then
compile compile
fi
echo "- Size: ${ELF_FILE_PATH}" echo "- Size: ${ELF_FILE_PATH}"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -503,18 +496,13 @@ size () {
} }
size_map () { size_map () {
if [ ! -e "${HEX_FILE_PATH}" ]; then
compile compile
fi
"${AVR_NM}" --size-sort -C -r -l -t decimal "${ELF_FILE_PATH}" "${AVR_NM}" --size-sort -C -r -l -t decimal "${ELF_FILE_PATH}"
} }
disassemble () { disassemble () {
if [ ! -e "${HEX_FILE_PATH}" ]; then
compile compile
fi
"${AVR_OBJDUMP}" -C -d "${ELF_FILE_PATH}" "${AVR_OBJDUMP}" -C -d "${ELF_FILE_PATH}"
} }

Loading…
Cancel
Save