From 0f5b630f6ca4a3139e488b0c59d576e84592bdc8 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 24 Oct 2020 01:12:37 -0700 Subject: [PATCH] refactoring a bit to simplify --- bin/kaleidoscope-builder | 61 +++++++++++++++------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index fd509fec..6499b70b 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -210,6 +210,12 @@ enable_ccache() { CCACHE_ENABLED=1 fi + if [ $CCACHE_ENABLED ]; then + COMPILER_PATH_PROP="${CCACHE_WRAPPER_PATH}/" + else + COMPILER_PATH_PROP="${COMPILER_PATH}" + fi + } @@ -307,21 +313,13 @@ hex_with_bootloader() { EOF } -build() { - compile "$@" -} - -prepare_ccache() { - find_sketch - build_paths - enable_ccache -} compile() { find_sketch set_executable_paths build_version build_paths build_filenames + enable_ccache # If the hex file is older than the sketch file, or the hex file does not exist # then rebuild. This is not as correct as letting make check our dependencies # But it's less broken for most user use cases @@ -358,7 +356,6 @@ set_executable_paths() { } do_compile() { - prepare_ccache install -d "${OUTPUT_PATH}" @@ -381,7 +378,22 @@ do_compile() { fi fi - do_compile_with_cli + _CMD_CXX="${CXX:-${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}${COMPILER_SUFFIX}}" + _CMD_CC="${CC:-${COMPILER_PREFIX}${C_COMPILER_BASENAME}${COMPILER_SUFFIX}}" + _CMD_AR="${AR:-${COMPILER_PREFIX}${AR_BASENAME}${COMPILER_SUFFIX}}" + run_arduino_cli compile \ + --fqbn "${FQBN}" \ + --libraries "${KALEIDOSCOPE_DIR}/.." \ + --build-path "${BUILD_PATH}" \ + --output-dir "${OUTPUT_PATH}" \ + --build-properties "compiler.path=${COMPILER_PATH_PROP}" \ + --build-properties "compiler.c.cmd=${_CMD_CC}" \ + --build-properties "compiler.cpp.cmd=${_CMD_CXX}" \ + --build-properties "compiler.ar.cmd=${_CMD_AR}" \ + --build-properties "compiler.c.elf.cmd=${_CMD_CXX}" \ + --build-properties "compiler.cpp.extra_flags=${LOCAL_CFLAGS}" \ + --warnings all \ + "${SKETCH_FILE_PATH}" if [ -z "${LIBONLY}" ]; then cp "${BUILD_PATH}/${SKETCH_FILE_NAME}.hex" "${HEX_FILE_PATH}" @@ -415,33 +427,6 @@ dump_arduino_prefs() { echo "$_ARDUINO_PREFS" } -do_compile_with_cli() { - #-build-cache "${CORE_CACHE_PATH}" \ - - if [ $CCACHE_ENABLED ]; then - COMPILER_PATH_PROP="${CCACHE_WRAPPER_PATH}/" - else - COMPILER_PATH_PROP="${COMPILER_PATH}" - fi - - _CMD_CXX="${CXX:-${COMPILER_PREFIX}${CXX_COMPILER_BASENAME}${COMPILER_SUFFIX}}" - _CMD_CC="${CC:-${COMPILER_PREFIX}${C_COMPILER_BASENAME}${COMPILER_SUFFIX}}" - _CMD_AR="${AR:-${COMPILER_PREFIX}${AR_BASENAME}${COMPILER_SUFFIX}}" - run_arduino_cli compile \ - --fqbn "${FQBN}" \ - --libraries "${KALEIDOSCOPE_DIR}/.." \ - --build-path "${BUILD_PATH}" \ - --output-dir "${OUTPUT_PATH}" \ - --build-properties "compiler.path=${COMPILER_PATH_PROP}" \ - --build-properties "compiler.c.cmd=${_CMD_CC}" \ - --build-properties "compiler.cpp.cmd=${_CMD_CXX}" \ - --build-properties "compiler.ar.cmd=${_CMD_AR}" \ - --build-properties "compiler.c.elf.cmd=${_CMD_CXX}" \ - --build-properties "compiler.cpp.extra_flags=${LOCAL_CFLAGS}" \ - --warnings all \ - "${SKETCH_FILE_PATH}" -} - find_all_sketches() { for sketch_name in ./*.ino \ $([ -d examples ] && find examples -name '*.ino') \