Skip to content

Commit

Permalink
Moved the BOARDS_TXT section and stop if BOARDS_TXT is not a file.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wingunder committed Sep 15, 2018
1 parent e445400 commit 62d23d6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 46 deletions.
94 changes: 49 additions & 45 deletions Arduino.mk
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,55 @@ endif
########################################################################
# Arduino and system paths

# 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)/$(ARCHITECTURE)
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

ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/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/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif

endif

ifeq (,$(wildcard $(BOARDS_TXT)))
$(error Currently BOARDS_TXT='$(BOARDS_TXT)', which is not an existing file or an invalid filename.)
endif

ifndef TOOL_PREFIX
TOOL_PREFIX = avr
endif
Expand Down Expand Up @@ -557,51 +606,6 @@ else
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER])
endif

# 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)/$(ARCHITECTURE)
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

ifndef ARDUINO_VAR_PATH
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/$(ARCHITECTURE)/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/$(ARDMK_VENDOR)/$(ARCHITECTURE)/boards.txt
$(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR))
else
$(call show_config_variable,BOARDS_TXT,[USER])
endif

endif

########################################################################
# Miscellaneous

Expand Down
8 changes: 7 additions & 1 deletion Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 62d23d6

Please sign in to comment.