From 7e66672a6c8d1e60c492bfaf992288d2c9b6a692 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sun, 23 Jun 2013 13:08:06 +0530 Subject: [PATCH] Auto detect alternate core path from sketchbook folder Fix #86 --- HISTORY.md | 1 + arduino-mk/Arduino.mk | 104 ++++++++++++++++++--------- examples/ATtinyBlink/Makefile | 7 +- examples/TinySoftWareSerial/Makefile | 7 +- 4 files changed, 81 insertions(+), 38 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index a3690b7..df20a2e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,7 @@ The following is the rough list of changes that went into different versions. I - Add support for specifying optimization level. Fix issue #81 - Add support for reseting "Micro" Arduino. Fix issue #80 (https://github.com/sej7278) - Remove "utility" from example makefiles. Fix issue #84 +- Auto detect alternate core path from sketchbook folder. Fix issue #86 ### 0.12.0 (2013-06-20) - Fix "generated_assembly" target, which got broken earlier. Fix issue #76 (https://github.com/matthijskooijman) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8ade57b..f95ff7a 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -252,6 +252,7 @@ ifndef TARGET endif ######################################################################## +# # Arduino version number ifndef ARDUINO_VERSION # Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes. @@ -269,6 +270,33 @@ else $(call show_config_variable,ARDUINO_VERSION,[USER]) endif +######################################################################## +# Arduino Sketchbook folder +# +ifndef ARDUINO_SKETCHBOOK + ifneq ($(wildcard $(HOME)/.arduino/preferences.txt),) + ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \ + $(HOME)/.arduino/preferences.txt | \ + sed -e 's/sketchbook.path=//' ) + endif + + # on mac + ifneq ($(wildcard $(HOME)/Library/Arduino/preferences.txt),) + ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \ + $(HOME)/Library/Arduino/preferences.txt | \ + sed -e 's/sketchbook.path=//' ) + endif + + ifneq ($(ARDUINO_SKETCHBOOK),) + $(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(from arduino preferences file)) + else + ARDUINO_SKETCHBOOK = $(HOME)/sketchbook + $(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT]) + endif +else + $(call show_config_variable,ARDUINO_SKETCHBOOK) +endif + ######################################################################## # Arduino and system paths # @@ -301,17 +329,53 @@ ifdef ARDUINO_DIR $(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino - ifndef ARDUINO_VAR_PATH - ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants - $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR)) + # Third party hardware and core like ATtiny or ATmega 16 + ifdef ALTERNATE_CORE + $(call show_config_variable,ALTERNATE_CORE,[USER]) + + ifndef ALTERNATE_CORE_PATH + ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE) + endif + endif + + ifdef ALTERNATE_CORE_PATH + + ifdef ALTERNATE_CORE + $(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE)) + else + $(call show_config_variable,ALTERNATE_CORE_PATH,[USER]) + endif + + ifndef ARDUINO_VAR_PATH + ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants + $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH)) + endif + + ifndef BOARDS_TXT + BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt + $(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH)) + endif + else - $(call show_config_variable,ARDUINO_VAR_PATH,[USER]) + + ifndef ARDUINO_VAR_PATH + ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants + $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR)) + else + $(call show_config_variable,ARDUINO_VAR_PATH,[USER]) + endif + + ifndef BOARDS_TXT + BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt + $(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR)) + else + $(call show_config_variable,BOARDS_TXT,[USER]) + endif + endif else - echo $(error "ARDUINO_DIR is not defined") - endif ifdef AVR_TOOLS_DIR @@ -346,30 +410,6 @@ endif ######################################################################## # Miscellaneous # -ifndef ARDUINO_SKETCHBOOK - ifneq ($(wildcard $(HOME)/.arduino/preferences.txt),) - ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \ - $(HOME)/.arduino/preferences.txt | \ - sed -e 's/sketchbook.path=//' ) - endif - - # on mac - ifneq ($(wildcard $(HOME)/Library/Arduino/preferences.txt),) - ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \ - $(HOME)/Library/Arduino/preferences.txt | \ - sed -e 's/sketchbook.path=//' ) - endif - - ifneq ($(ARDUINO_SKETCHBOOK),) - $(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(in arduino preferences file)) - else - ARDUINO_SKETCHBOOK = $(HOME)/sketchbook - $(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT]) - endif -else - $(call show_config_variable,ARDUINO_SKETCHBOOK) -endif - ifndef USER_LIB_PATH USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries $(call show_config_variable,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) @@ -427,10 +467,6 @@ else $(call show_config_variable,BOARD_TAG,[USER]) endif -ifndef BOARDS_TXT - BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt -endif - ifndef PARSE_BOARD PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards endif diff --git a/examples/ATtinyBlink/Makefile b/examples/ATtinyBlink/Makefile index a851ad8..12d4a1f 100644 --- a/examples/ATtinyBlink/Makefile +++ b/examples/ATtinyBlink/Makefile @@ -1,8 +1,11 @@ # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile +# if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. +ALTERNATE_CORE = attiny +# If not, you might have to include the full path. +#ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/ + BOARD_TAG = attiny85-8 -ARDUINO_VAR_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/variants -BOARDS_TXT = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/boards.txt ISP_PORT = /dev/ttyACM* include $(ARDMK_DIR)/arduino-mk/Arduino.mk diff --git a/examples/TinySoftWareSerial/Makefile b/examples/TinySoftWareSerial/Makefile index b68f08d..0f9c6e2 100644 --- a/examples/TinySoftWareSerial/Makefile +++ b/examples/TinySoftWareSerial/Makefile @@ -1,8 +1,11 @@ # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile +# if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. +ALTERNATE_CORE = attiny +# If not, you might have to include the full path. +#ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/ + BOARD_TAG = attiny85-8 -ARDUINO_VAR_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/variants -BOARDS_TXT = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/boards.txt ISP_PORT = /dev/ttyACM* ARDUINO_LIBS = SoftwareSerial