Auto detect alternate core path from sketchbook folder

Fix #86
This commit is contained in:
Sudar 2013-06-23 13:08:06 +05:30
parent 2b75a0ddb4
commit 7e66672a6c
4 changed files with 81 additions and 38 deletions

View file

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

View file

@ -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

View file

@ -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

View file

@ -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