From e482e6fbc71a78fbb1acffd6279df5d4138a70c5 Mon Sep 17 00:00:00 2001 From: Tokita Hiroshi Date: Mon, 14 Sep 2020 15:59:42 -0700 Subject: [PATCH 1/3] Add -DARDUINO_{build.board} for compile options --- Arduino.mk | 12 +++++++++++- HISTORY.md | 1 + arduino-mk-vars.md | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Arduino.mk b/Arduino.mk index 30bf36b..729f80a 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -674,6 +674,16 @@ ifeq ($(strip $(NO_CORE)),) $(call show_config_variable,VARIANT,[USER]) endif + ifndef BOARD + BOARD := $(call PARSE_BOARD,$(BOARD_TAG),build.board) + ifndef BOARD + BOARD := $(shell echo $(ARCHITECTURE)_$(BOARD_TAG) | tr '[:lower:]' '[:upper:]') + endif + $(call show_config_variable,BOARD,[COMPUTED],(from build.board)) + else + $(call show_config_variable,BOARD,[USER]) + endif + # see if we are a caterina device like leonardo or micro CATERINA := $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).bootloader.file)) ifndef CATERINA @@ -1162,7 +1172,7 @@ else endif # Using += instead of =, so that CPPFLAGS can be set per sketch level -CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) $(ARDUINO_ARCH_FLAG) \ +CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_$(BOARD) $(ARDUINO_ARCH_FLAG) \ -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_CORE_PATH)/api -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \ -fdata-sections diff --git a/HISTORY.md b/HISTORY.md index 0641531..9d892e5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -35,6 +35,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it - New: Add support for Robotis OpenCR 1.0 boards. - New: Build the ArduinoCore API - New: Support for Python 3 and multi-os Python installation using new PYTHON_CMD variable. +- New: Add "ARDUINO_{build.board}" to be able to detect board type. ### 1.6.0 (2017-07-11) - Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278) diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md index 7c42416..0907eb2 100644 --- a/arduino-mk-vars.md +++ b/arduino-mk-vars.md @@ -583,6 +583,26 @@ CORE = tiny ---- +### BOARD + +**Description:** + +Board identifier that passes to a compile option as -DARDUINO_$(BOARD). + +Usually can be auto-detected as `build.board` from `boards.txt`. + +If not found build.board entry, use upper-case converted "$(ARCHITECTURE)_$(BOARD_TAG)". + +**Example:** + +```Makefile +BOARD = AVR_LEONARD +``` + +**Requirement:** *Optional* + +---- + ### VARIANT **Description:** From d21e7ebe996f5c69159d1e5429521ea3a4848dcf Mon Sep 17 00:00:00 2001 From: Tokita Hiroshi Date: Wed, 16 Sep 2020 08:00:59 +0900 Subject: [PATCH 2/3] Add -DARDUINO_BOARD definition --- Arduino.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Arduino.mk b/Arduino.mk index 729f80a..e4694af 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -1173,6 +1173,7 @@ endif # Using += instead of =, so that CPPFLAGS can be set per sketch level CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_$(BOARD) $(ARDUINO_ARCH_FLAG) \ + "-DARDUINO_BOARD=\"$(BOARD)\"" \ -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_CORE_PATH)/api -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \ -fdata-sections From 01493f4e23a55e3117ee3e71b12cad35ecfa681d Mon Sep 17 00:00:00 2001 From: "Tokita, Hiroshi" Date: Tue, 20 Oct 2020 09:57:36 +0900 Subject: [PATCH 3/3] Add -DARDUINO_VARIANT definition --- Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino.mk b/Arduino.mk index e4694af..08af529 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -1173,7 +1173,7 @@ endif # Using += instead of =, so that CPPFLAGS can be set per sketch level CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_$(BOARD) $(ARDUINO_ARCH_FLAG) \ - "-DARDUINO_BOARD=\"$(BOARD)\"" \ + "-DARDUINO_BOARD=\"$(BOARD)\"" "-DARDUINO_VARIANT=\"$(VARIANT)\"" \ -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_CORE_PATH)/api -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \ -fdata-sections