refactoring a bit to simplify

tmp/arduino-cli-pre-rebase
Jesse Vincent 4 years ago
parent 2b0a12fdad
commit 0f5b630f6c
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -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') \

Loading…
Cancel
Save