From 3658cc1340674bcdf9a7f5d009e77554cbb61991 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 15 Nov 2020 21:49:21 -0800 Subject: [PATCH] Lift more of the builder into the makefile --- bin/kaleidoscope-builder | 25 ------------------------- etc/sketch-arduino-cli.mk | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index 5643497e..ea96b97f 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -62,30 +62,6 @@ _set_executable_paths() { : "${AVR_SIZE:=${COMPILER_PATH}/${COMPILER_PREFIX}size}" } -_set_build_paths() { - GIT_VERSION="$( - cd "${SKETCH_DIR}" - if [ -d .git ]; then echo -n '-g' && git describe --abbrev=4 --dirty --always; fi - )" - 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}" - - - : "${BOOTLOADER_PATH:=$(_arduino_prop 'runtime.platform.path')/bootloaders/$(_arduino_prop 'bootloader.file')}" - : "${OUTPUT_FILE_PREFIX:=${SKETCH_BASE_NAME}-${LIB_VERSION}}" - : "${HEX_FILE_PATH:=${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.hex}" - : "${HEX_FILE_WITH_BOOTLOADER_PATH:=${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}-with-bootloader.hex}" - : "${ELF_FILE_PATH:=${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.elf}" - : "${LIB_FILE_PATH:=${OUTPUT_PATH}/${OUTPUT_FILE_PREFIX}.a}" - - mkdir -p "$BUILD_PATH" - -} - - - _find_sketch() { if [ -z "${SKETCH_FILE_PATH}" ] || [ ! -f "${SKETCH_FILE_PATH}" ]; then @@ -183,7 +159,6 @@ cmd_disassemble() { _set_up_environment() { _find_sketch - _set_build_paths _set_executable_paths } diff --git a/etc/sketch-arduino-cli.mk b/etc/sketch-arduino-cli.mk index acd86279..8cae8fc3 100644 --- a/etc/sketch-arduino-cli.mk +++ b/etc/sketch-arduino-cli.mk @@ -86,12 +86,15 @@ export SKETCH_FILE_NAME := $(addsuffix .ino, $(SKETCH_BASE_NAME)) sketch_dir_candidates = $(sketch_dir) src/ . sketch_exists_p = $(realpath $(wildcard $(dir)/$(SKETCH_FILE_NAME))) -# FIND the path of the sketch file -export SKETCH_FILE_PATH := $(firstword $(foreach dir,$(sketch_dir_candidates),$(sketch_exists_p))) - +export BOOTLOADER_PATH := $(call _arduino_prop,runtime.platform.path)/bootloaders/$(call _arduino_prop,bootloader.file) +# Find the path of the sketch file +export SKETCH_FILE_PATH := $(firstword $(foreach dir,$(sketch_dir_candidates),$(sketch_exists_p))) +# We -could- check to see if sketch-dir is in git before running this command +# but since we'd just return an empty value in that case, why bother? +export GIT_VERSION := $(shell git -C "$(sketch_dir)" describe --abbrev=6 --dirty --alway 2>/dev/null || echo 'unknown') export SKETCH_IDENTIFIER := $(shell echo "$${SKETCH_FILE_PATH}" | cksum | cut -d ' ' -f 1)-$(SKETCH_FILE_NAME) @@ -102,6 +105,15 @@ export SKETCH_OUTPUT_DIR ?= $(SKETCH_IDENTIFIER)/output export BUILD_PATH ?= $(KALEIDOSCOPE_BUILD_PATH)/$(SKETCH_BUILD_DIR) export OUTPUT_PATH ?= $(KALEIDOSCOPE_OUTPUT_PATH)/$(SKETCH_OUTPUT_DIR) + +export OUTPUT_FILE_PREFIX := $(SKETCH_BASE_NAME)-$(GIT_VERSION) +export HEX_FILE_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).hex +export HEX_FILE_WITH_BOOTLOADER_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX)-with-bootloader.hex +export ELF_FILE_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).elf +export LIB_FILE_PATH := $(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).a + + + export LIB_PROPERTIES_PATH := "../.."