summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-02-21 16:23:17 +1100
committerDamien George <damien@micropython.org>2023-02-23 09:49:54 +1100
commit742037ec3836c56baf51289288ba954d901e728a (patch)
tree1ac39ec9e5a1b8212d6dbf8c66755330c8ce5293
parent69b93527d555c45185e7bd933ed0725f4b7230c9 (diff)
esp32/Makefile: Allow specifying BOARD_DIR on make command line.
This matches the behavior of the makefile ports but implemented for CMake, making it easy to specify custom board definitions. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r--ports/esp32/Makefile16
1 files changed, 14 insertions, 2 deletions
diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile
index e43cad751..0b33fa6e5 100644
--- a/ports/esp32/Makefile
+++ b/ports/esp32/Makefile
@@ -2,8 +2,20 @@
#
# This is a simple, convenience wrapper around idf.py (which uses cmake).
-# Select the board to build for, defaulting to GENERIC.
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to GENERIC.
BOARD ?= GENERIC
+BOARD_DIR ?= boards/$(BOARD)
+endif
+
+ifeq ($(wildcard $(BOARD_DIR)/.),)
+$(error Invalid BOARD specified: $(BOARD_DIR))
+endif
# If the build directory is not given, make it reflect the board name.
BUILD ?= build-$(BOARD)
@@ -28,7 +40,7 @@ ifdef USER_C_MODULES
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
endif
-IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -B $(BUILD) $(CMAKE_ARGS)
+IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -D MICROPY_BOARD_DIR=$(abspath $(BOARD_DIR)) -B $(BUILD) $(CMAKE_ARGS)
ifdef FROZEN_MANIFEST
IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST)