Moved the PARSE_BOARD macro from Arduino.mk to Common.mk.
There seems to be 3 different macros to parse the boards.txt file. This patch moves the PARSE_BOARD macro from Arduino.mk to Common.mk. The PARSE_OPENCM and PARSE_TEENSY macros in Teensy.mk and OpenCM.mk were removed and the common PARSE_BOARD is now being called from everywhere. Advantages of this fix are: 1. Less code, i.e. no redundant parse macros. 2. A single standardized algorithm to parse the boards.txt file.
This commit is contained in:
parent
22ca63614d
commit
2442dafb4f
5 changed files with 55 additions and 65 deletions
|
@ -585,11 +585,6 @@ else
|
|||
$(call show_config_variable,BOARD_TAG,[USER])
|
||||
endif
|
||||
|
||||
ifndef PARSE_BOARD
|
||||
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
|
||||
PARSE_BOARD = $(shell grep -Ev '^\#' $(BOARDS_TXT) | grep -E "^[ \t]*$(1).$(2)=" | cut -d = -f 2 | cut -d : -f 2)
|
||||
endif
|
||||
|
||||
# If NO_CORE is set, then we don't have to parse boards.txt file
|
||||
# But the user might have to define MCU, F_CPU etc
|
||||
ifeq ($(strip $(NO_CORE)),)
|
||||
|
|
|
@ -5,6 +5,11 @@ COMMON_INCLUDED = TRUE
|
|||
# (directory and optional filename) exists
|
||||
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
|
||||
|
||||
ifndef PARSE_BOARD
|
||||
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
|
||||
PARSE_BOARD = $(shell grep -Ev '^\#' $(BOARDS_TXT) | grep -E "^[ \t]*$(1).$(2)=" | cut -d = -f 2 | cut -d : -f 2)
|
||||
endif
|
||||
|
||||
# Run a shell script if it exists. Stops make on error.
|
||||
runscript_if_exists = \
|
||||
$(if $(wildcard $(1)), \
|
||||
|
|
|
@ -22,6 +22,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
|
|||
- New: Compatibility with deprecated pgmspace.h API can now be disabled since it sometimes causes bogus compiler warnings (issue #546)
|
||||
- New: Support Arduino ARM SAMD devices (Zero, M0 Pro, Feather M0). (https://github.com/tuna-f1sh)
|
||||
- New: Support Arduino ARM SAM devices (Due). (https://github.com/tuna-f1sh)
|
||||
- New: Moved the PARSE_BOARD macro to Common.mk and use only this to parse the boards.txt file. (https://github.com/wingunder)
|
||||
|
||||
### 1.6.0 (2017-07-11)
|
||||
- Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278)
|
||||
|
|
41
OpenCM.mk
41
OpenCM.mk
|
@ -44,17 +44,12 @@ ifndef BOARDS_TXT
|
|||
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt
|
||||
endif
|
||||
|
||||
ifndef PARSE_OPENCM
|
||||
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
|
||||
PARSE_OPENCM = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
|
||||
endif
|
||||
|
||||
ifndef F_CPU
|
||||
F_CPU := $(call PARSE_OPENCM,$(BOARD_TAG),build.f_cpu)
|
||||
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
|
||||
endif
|
||||
|
||||
# if boards.txt gets modified, look there, else hard code it
|
||||
ARCHITECTURE = $(call PARSE_OPENCM,$(BOARD_TAG),build.architecture)
|
||||
ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
|
||||
ifeq ($(strip $(ARCHITECTURE)),)
|
||||
ARCHITECTURE = arm
|
||||
endif
|
||||
|
@ -75,7 +70,7 @@ endif
|
|||
# command names
|
||||
|
||||
ifndef CC_NAME
|
||||
CC_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.gcc)
|
||||
CC_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gcc)
|
||||
ifndef CC_NAME
|
||||
CC_NAME := arm-none-eabi-gcc
|
||||
else
|
||||
|
@ -84,7 +79,7 @@ ifndef CC_NAME
|
|||
endif
|
||||
|
||||
ifndef CXX_NAME
|
||||
CXX_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.g++)
|
||||
CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.g++)
|
||||
ifndef CXX_NAME
|
||||
CXX_NAME := arm-none-eabi-g++
|
||||
else
|
||||
|
@ -93,7 +88,7 @@ ifndef CXX_NAME
|
|||
endif
|
||||
|
||||
ifndef AS_NAME
|
||||
AS_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.as)
|
||||
AS_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.as)
|
||||
ifndef AS_NAME
|
||||
AS_NAME := arm-none-eabi-as
|
||||
else
|
||||
|
@ -102,7 +97,7 @@ ifndef AS_NAME
|
|||
endif
|
||||
|
||||
ifndef OBJDUMP_NAME
|
||||
OBJDUMP_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.objdump)
|
||||
OBJDUMP_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objdump)
|
||||
ifndef OBJDUMP_NAME
|
||||
OBJDUMP_NAME := arm-none-eabi-objdump
|
||||
else
|
||||
|
@ -111,7 +106,7 @@ ifndef OBJDUMP_NAME
|
|||
endif
|
||||
|
||||
ifndef AR_NAME
|
||||
AR_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.ar)
|
||||
AR_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.ar)
|
||||
ifndef AR_NAME
|
||||
AR_NAME := arm-none-eabi-ar
|
||||
else
|
||||
|
@ -120,7 +115,7 @@ ifndef AR_NAME
|
|||
endif
|
||||
|
||||
ifndef SIZE_NAME
|
||||
SIZE_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.size)
|
||||
SIZE_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.size)
|
||||
ifndef SIZE_NAME
|
||||
SIZE_NAME := arm-none-eabi-size
|
||||
else
|
||||
|
@ -129,7 +124,7 @@ ifndef SIZE_NAME
|
|||
endif
|
||||
|
||||
ifndef NM_NAME
|
||||
NM_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.nm)
|
||||
NM_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.nm)
|
||||
ifndef NM_NAME
|
||||
NM_NAME := arm-none-eabi-nm
|
||||
else
|
||||
|
@ -138,7 +133,7 @@ ifndef NM_NAME
|
|||
endif
|
||||
|
||||
ifndef OBJCOPY_NAME
|
||||
OBJCOPY_NAME := $(call PARSE_OPENCM,$(BOARD_TAG),build.command.objcopy)
|
||||
OBJCOPY_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objcopy)
|
||||
ifndef OBJCOPY_NAME
|
||||
OBJCOPY_NAME := arm-none-eabi-objcopy
|
||||
else
|
||||
|
@ -148,7 +143,7 @@ endif
|
|||
|
||||
# processor stuff
|
||||
ifndef MCU
|
||||
MCU := $(call PARSE_OPENCM,$(BOARD_TAG),build.family)
|
||||
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.family)
|
||||
endif
|
||||
|
||||
ifndef MCU_FLAG_NAME
|
||||
|
@ -161,20 +156,20 @@ ifndef USB_TYPE
|
|||
USB_TYPE = USB_SERIAL
|
||||
endif
|
||||
|
||||
CPPFLAGS += -DBOARD_$(call PARSE_OPENCM,$(BOARD_TAG),build.board)
|
||||
CPPFLAGS += -DMCU_$(call PARSE_OPENCM,$(BOARD_TAG),build.mcu)
|
||||
CPPFLAGS += -DBOARD_$(call PARSE_BOARD,$(BOARD_TAG),build.board)
|
||||
CPPFLAGS += -DMCU_$(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
|
||||
CPPFLAGS += -DSTM32_MEDIUM_DENSITY -DVECT_TAB_FLASH
|
||||
|
||||
CPPFLAGS += $(call PARSE_OPENCM,$(BOARD_TAG),build.option)
|
||||
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
|
||||
|
||||
CXXFLAGS += -fno-rtti
|
||||
|
||||
CXXFLAGS += $(call PARSE_OPENCM,$(BOARD_TAG),build.cppoption)
|
||||
ifeq ("$(call PARSE_OPENCM,$(BOARD_TAG),build.gnu0x)","true")
|
||||
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
|
||||
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
|
||||
CXXFLAGS_STD += -std=gnu++0x
|
||||
endif
|
||||
|
||||
ifeq ("$(call PARSE_OPENCM,$(BOARD_TAG),build.elide_constructors)", "true")
|
||||
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
|
||||
CXXFLAGS += -felide-constructors
|
||||
endif
|
||||
|
||||
|
@ -209,7 +204,7 @@ ifeq ($(CURRENT_OS), WINDOWS)
|
|||
else
|
||||
override AVRDUDE_ARD_OPTS = $(call get_monitor_port)
|
||||
endif
|
||||
|
||||
|
||||
override AVRDUDE_UPLOAD_HEX = $(TARGET_HEX)
|
||||
|
||||
########################################################################
|
||||
|
|
68
Teensy.mk
68
Teensy.mk
|
@ -38,25 +38,19 @@ ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/teensy/avr/cores/teensy3
|
|||
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/avr/boards.txt
|
||||
|
||||
|
||||
ifndef PARSE_TEENSY
|
||||
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
|
||||
PARSE_TEENSY = $(shell grep -v "^\#" "$(BOARDS_TXT)" | grep $(1).$(2) | cut -d = -f 2- )
|
||||
endif
|
||||
|
||||
|
||||
ifndef F_CPU
|
||||
ifndef BOARD_SUB
|
||||
SPEEDS := $(call PARSE_TEENSY,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
|
||||
SPEEDS := $(call PARSE_BOARD,"$(BOARD_TAG),menu.speed.*.build.fcpu") # Obtain sequence of supported frequencies.
|
||||
SPEEDS := $(shell printf "%d\n" $(SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works.
|
||||
F_CPU := $(lastword $(SPEEDS)) # List is sorted in ascending order. Take the fastest speed.
|
||||
#$(info "speeds is " $(SPEEDS)) # Good for debugging
|
||||
else
|
||||
F_CPU := $(call PARSE_TEENSY,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
|
||||
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),menu.speed.$(BOARD_SUB).build.fcpu)
|
||||
endif
|
||||
endif
|
||||
|
||||
# if boards.txt gets modified, look there, else hard code it
|
||||
ARCHITECTURE = $(call PARSE_TEENSY,$(BOARD_TAG),build.architecture)
|
||||
ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
|
||||
ifeq ($(strip $(ARCHITECTURE)),)
|
||||
ARCHITECTURE = arm
|
||||
endif
|
||||
|
@ -73,7 +67,7 @@ endif
|
|||
# command names
|
||||
|
||||
ifndef CC_NAME
|
||||
CC_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.gcc)
|
||||
CC_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.gcc)
|
||||
ifndef CC_NAME
|
||||
CC_NAME := arm-none-eabi-gcc
|
||||
else
|
||||
|
@ -82,7 +76,7 @@ ifndef CC_NAME
|
|||
endif
|
||||
|
||||
ifndef CXX_NAME
|
||||
CXX_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.g++)
|
||||
CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.g++)
|
||||
ifndef CXX_NAME
|
||||
CXX_NAME := arm-none-eabi-g++
|
||||
else
|
||||
|
@ -91,7 +85,7 @@ ifndef CXX_NAME
|
|||
endif
|
||||
|
||||
ifndef AS_NAME
|
||||
AS_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.as)
|
||||
AS_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.as)
|
||||
ifndef AS_NAME
|
||||
AS_NAME := arm-none-eabi-gcc-as
|
||||
else
|
||||
|
@ -100,7 +94,7 @@ ifndef AS_NAME
|
|||
endif
|
||||
|
||||
ifndef OBJCOPY_NAME
|
||||
OBJCOPY_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.objcopy)
|
||||
OBJCOPY_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objcopy)
|
||||
ifndef OBJCOPY_NAME
|
||||
OBJCOPY_NAME := arm-none-eabi-objcopy
|
||||
else
|
||||
|
@ -109,7 +103,7 @@ ifndef OBJCOPY_NAME
|
|||
endif
|
||||
|
||||
ifndef OBJDUMP_NAME
|
||||
OBJDUMP_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.objdump)
|
||||
OBJDUMP_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.objdump)
|
||||
ifndef OBJDUMP_NAME
|
||||
OBJDUMP_NAME := arm-none-eabi-objdump
|
||||
else
|
||||
|
@ -118,7 +112,7 @@ ifndef OBJDUMP_NAME
|
|||
endif
|
||||
|
||||
ifndef AR_NAME
|
||||
AR_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.ar)
|
||||
AR_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.ar)
|
||||
ifndef AR_NAME
|
||||
AR_NAME := arm-none-eabi-ar
|
||||
else
|
||||
|
@ -127,7 +121,7 @@ ifndef AR_NAME
|
|||
endif
|
||||
|
||||
ifndef SIZE_NAME
|
||||
SIZE_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.size)
|
||||
SIZE_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.size)
|
||||
ifndef SIZE_NAME
|
||||
SIZE_NAME := arm-none-eabi-size
|
||||
else
|
||||
|
@ -136,7 +130,7 @@ ifndef SIZE_NAME
|
|||
endif
|
||||
|
||||
ifndef NM_NAME
|
||||
NM_NAME := $(call PARSE_TEENSY,$(BOARD_TAG),build.command.nm)
|
||||
NM_NAME := $(call PARSE_BOARD,$(BOARD_TAG),build.command.nm)
|
||||
ifndef NM_NAME
|
||||
NM_NAME := arm-none-eabi-gcc-nm
|
||||
else
|
||||
|
@ -146,7 +140,7 @@ endif
|
|||
|
||||
# processor stuff
|
||||
ifndef MCU
|
||||
MCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.mcu)
|
||||
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
|
||||
endif
|
||||
|
||||
ifndef MCU_FLAG_NAME
|
||||
|
@ -161,39 +155,39 @@ endif
|
|||
|
||||
CPPFLAGS += -DLAYOUT_US_ENGLISH -D$(USB_TYPE)
|
||||
|
||||
CPPFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.option)
|
||||
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
|
||||
|
||||
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.cppoption)
|
||||
ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.gnu0x)","true")
|
||||
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
|
||||
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
|
||||
CXXFLAGS_STD += -std=gnu++0x
|
||||
endif
|
||||
|
||||
ifeq ("$(call PARSE_TEENSY,$(BOARD_TAG),build.elide_constructors)", "true")
|
||||
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
|
||||
CXXFLAGS += -felide-constructors
|
||||
endif
|
||||
|
||||
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common)
|
||||
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
|
||||
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs)
|
||||
CXXFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpp)
|
||||
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
|
||||
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
|
||||
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
|
||||
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpp)
|
||||
|
||||
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common)
|
||||
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
|
||||
CFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs)
|
||||
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
|
||||
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
|
||||
CFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
|
||||
|
||||
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.common)
|
||||
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
|
||||
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.defs)
|
||||
ASFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.S)
|
||||
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.common)
|
||||
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
|
||||
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.defs)
|
||||
ASFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.S)
|
||||
|
||||
LDFLAGS += $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
|
||||
LDFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
|
||||
|
||||
AMCU := $(call PARSE_TEENSY,$(BOARD_TAG),build.mcu)
|
||||
AMCU := $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
|
||||
LDFLAGS += -Wl,--gc-sections,--relax
|
||||
LINKER_SCRIPTS = -T${ARDUINO_CORE_PATH}/${AMCU}.ld
|
||||
OTHER_LIBS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.libs)
|
||||
OTHER_LIBS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.libs)
|
||||
|
||||
CPUFLAGS = $(call PARSE_TEENSY,$(BOARD_TAG),build.flags.cpu)
|
||||
CPUFLAGS = $(call PARSE_BOARD,$(BOARD_TAG),build.flags.cpu)
|
||||
# usually defined as per teensy31.build.mcu=mk20dx256 but that isn't valid switch
|
||||
MCU := $(shell echo ${CPUFLAGS} | sed -n -e 's/.*-mcpu=\([a-zA-Z0-9_-]*\).*/\1/p')
|
||||
|
||||
|
|
Loading…
Reference in a new issue