rework the single sketch search path to use the current directory name as a hint to the sketch name if it's not specified

tmp/arduino-cli-pre-rebase
Jesse Vincent 4 years ago
parent 91753fe259
commit 1ae46ddc69
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -205,21 +205,18 @@ firmware_size () {
find_sketch () { find_sketch () {
if [ -z "${SKETCH}" ]; then SKETCH_DIR="${SKETCH:-$(absolute_filename $(pwd))}"
echo "SKETCH needs to be set before including this file!" >&2 SKETCH_BASE_NAME=$(basename "${SKETCH_DIR}")
exit 1
fi
SKETCH_DIR="${SKETCH}"
SKETCH_BASE_NAME=$(basename "$SKETCH")
SKETCH_FILE_NAME="${SKETCH_BASE_NAME}.ino" SKETCH_FILE_NAME="${SKETCH_BASE_NAME}.ino"
for path in "${SKETCH_DIR}" \ # Arduino sketches are usually a file inside directory Foo named Foo.ino, so try that as a fallback
"src" \ for dir in \
"."; do "${SKETCH_DIR}" \
if [ -f "${path}/${SKETCH_FILE_NAME}" ]; then "src/" \
SKETCH_DIR="${path}" "."; do
SKETCH_FILE_PATH=$(absolute_filename "${SKETCH_DIR}/${SKETCH_FILE_NAME}") if [ -f "${dir}/${SKETCH_FILE_NAME}" ]; then
SKETCH_DIR="${dir}"
SKETCH_FILE_PATH=$(absolute_filename "${dir}/${SKETCH_FILE_NAME}")
return return
fi fi
done done

Loading…
Cancel
Save