From 2442dafb4fa8a7f0c5212a0d0f6e3fbafb986b29 Mon Sep 17 00:00:00 2001 From: Pieter du Preez Date: Thu, 13 Sep 2018 23:44:12 +0200 Subject: 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. --- Common.mk | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Common.mk') diff --git a/Common.mk b/Common.mk index 5f30fba..6209b03 100644 --- a/Common.mk +++ b/Common.mk @@ -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)), \ -- cgit v1.2.3 From 62d23d66a2f9326235022bfd8711c62e015c0bc8 Mon Sep 17 00:00:00 2001 From: Pieter du Preez Date: Sat, 15 Sep 2018 14:31:39 +0200 Subject: Moved the BOARDS_TXT section and stop if BOARDS_TXT is not a file. The section of Arduino.mk that calculates BOARDS_TXT was moved to just before the point where it gets used for the first time (a call to PARSE_BOARD). An error gets generated if BOARDS_TXT is not pointing to a valid file, directly after the BOARDS_TXT calculation. In addition, the PARSE_BOARD macro will now be bypassed if the BOARDS_TXT variable points to a non-existing file. If a user makefile uses PARSE_BOARD before including Arduino.mk, and the BOARDS_TXT is wrong, the error will only be caught in the Arduino.mk file, which is probably acceptable. --- Common.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Common.mk') diff --git a/Common.mk b/Common.mk index 6209b03..c5f2bc2 100644 --- a/Common.mk +++ b/Common.mk @@ -7,7 +7,13 @@ 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) +PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ +then \ + grep -Ev '^\#' $(BOARDS_TXT) | \ + grep -E "^[ \t]*$(1).$(2)=" | \ + cut -d = -f 2 | \ + cut -d : -f 2; \ +fi) endif # Run a shell script if it exists. Stops make on error. -- cgit v1.2.3