Switch find_sketch to set an env variable, rather than return a value, to reduce the number of times we need to call it. Also, begin to add better support for:

kaleidoscope-builder examples/Foo/Bar compile
pull/914/head
Jesse Vincent 4 years ago
parent beb963d341
commit e378f9cd17
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -26,15 +26,15 @@ absolute_filename() {
build_version () { build_version () {
GIT_VERSION="$(cd "$(find_sketch)"; if [ -d .git ]; then echo -n '-g' && git describe --abbrev=4 --dirty --always; fi)" GIT_VERSION="$(cd "${SKETCH_DIR}"; if [ -d .git ]; then echo -n '-g' && git describe --abbrev=4 --dirty --always; fi)"
LIB_PROPERTIES_PATH="${LIB_PROPERTIES_PATH:-"../.."}" LIB_PROPERTIES_PATH="${LIB_PROPERTIES_PATH:-"../.."}"
LIB_VERSION="$(cd "$(find_sketch)"; (grep version= "${LIB_PROPERTIES_PATH}/library.properties" 2>/dev/null || echo version=0.0.0) | cut -d= -f2)${GIT_VERSION}" LIB_VERSION="$(cd "${SKETCH_DIR}"; (grep version= "${LIB_PROPERTIES_PATH}/library.properties" 2>/dev/null || echo version=0.0.0) | cut -d= -f2)${GIT_VERSION}"
} }
build_paths() { build_paths() {
# We need that echo because we\re piping to cksum # We need that echo because we\re piping to cksum
# shellcheck disable=SC2005 # shellcheck disable=SC2005
SKETCH_IDENTIFIER="$(echo "$(absolute_filename "$(find_sketch)/${SKETCH}.ino")" | cksum | cut -d ' ' -f 1)-${SKETCH}.ino" SKETCH_IDENTIFIER="$(echo "$(absolute_filename "${SKETCH_DIR}/${SKETCH}.ino")" | cksum | cut -d ' ' -f 1)-${SKETCH}.ino"
KALEIDOSCOPE_TEMP_PATH="${KALEIDOSCOPE_TEMP_PATH:-${TMPDIR:-/tmp}/kaleidoscope-${USER}}" KALEIDOSCOPE_TEMP_PATH="${KALEIDOSCOPE_TEMP_PATH:-${TMPDIR:-/tmp}/kaleidoscope-${USER}}"
@ -137,11 +137,16 @@ find_sketch () {
exit 1 exit 1
fi fi
for path in "examples/${LIBRARY}" \ SKETCH_DIR="$SKETCH"
SKETCH_FILE=$(basename "$SKETCH")
for path in "${SKETCH_DIR}" \
"examples/${LIBRARY}" \
"src" \ "src" \
"."; do "."; do
if [ -f "${path}/${SKETCH}.ino" ]; then if [ -f "${path}/${SKETCH_FILE}.ino" ]; then
echo "${path}" SKETCH_DIR="${path}"
SKETCH="${SKETCH_FILE}"
return return
fi fi
done done
@ -324,6 +329,7 @@ hex_with_bootloader () {
} }
maybe_build () { maybe_build () {
find_sketch
build_version build_version
build_paths build_paths
build_filenames build_filenames
@ -342,6 +348,7 @@ build () {
} }
compile () { compile () {
find_sketch
build_version build_version
build_paths build_paths
build_filenames build_filenames
@ -349,8 +356,6 @@ compile () {
install -d "${OUTPUT_PATH}" install -d "${OUTPUT_PATH}"
SKETCH_DIR="$(find_sketch)"
echo "Building ${SKETCH_DIR}/${SKETCH}" echo "Building ${SKETCH_DIR}/${SKETCH}"
# This is defined in the (optional) user config. # This is defined in the (optional) user config.

Loading…
Cancel
Save