document GREP_CMD

This commit is contained in:
John Whittington 2020-08-06 12:38:03 +02:00
parent 264f8f604a
commit 185a1e9e35
3 changed files with 23 additions and 7 deletions

View file

@ -8,8 +8,8 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter') # result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \
then \ then \
$(GREP) -Ev '^\#' $(BOARDS_TXT) | \ $(GREP_CMD) -Ev '^\#' $(BOARDS_TXT) | \
$(GREP) -E "^[ \t]*$(1).$(2)=" | \ $(GREP_CMD) -E "^[ \t]*$(1).$(2)=" | \
cut -d = -f 2- | \ cut -d = -f 2- | \
cut -d : -f 2; \ cut -d : -f 2; \
fi) fi)
@ -48,20 +48,20 @@ $(call arduino_output,$(call ardmk_include) Configuration:)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
CURRENT_OS = WINDOWS CURRENT_OS = WINDOWS
GREP := grep GREP_CMD := grep
else else
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux) ifeq ($(UNAME_S),Linux)
CURRENT_OS = LINUX CURRENT_OS = LINUX
GREP := grep GREP_CMD := grep
endif endif
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
CURRENT_OS = MAC CURRENT_OS = MAC
ifeq (, $(shell which ggrep)) ifeq (, $(shell which ggrep))
echo $(info Using macOS BSD grep, please install GNU grep to avoid warnings) echo $(info Using macOS BSD grep, please install GNU grep to avoid warnings)
GREP := grep GREP_CMD := grep
else else
GREP := ggrep GREP_CMD := ggrep
endif endif
endif endif
endif endif

2
Sam.mk
View file

@ -414,7 +414,7 @@ CFLAGS_STD += -std=gnu11
CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)' CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)'
# Get extra define flags from boards.txt # Get extra define flags from boards.txt
EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP) -oE '(-D)\w+') EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP_CMD) -oE '(-D)\w+')
# Strip only defines from extra flags as boards file appends user {build.usb} # Strip only defines from extra flags as boards file appends user {build.usb}
CPPFLAGS += $(EXFLAGS) CPPFLAGS += $(EXFLAGS)

View file

@ -150,6 +150,22 @@ PYTHON_CMD = /usr/bin/python3
---- ----
### GREP_CMD
**Description:**
Path to GNU grep binary. Only added for macOS, which has BSD grep by default but results in some parsing warnings. macOS users should install GNU grep using Homebrew.
**Example:**
```Makefile
GREP_CMD = /bin/grep
```
**Requirement:** *Optional*
----
## Arduino IDE variables ## Arduino IDE variables
### ARDUINO_DIR ### ARDUINO_DIR