From 7d9cc69645c48e67fd404c494cebad1b90c5757d Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Fri, 29 Apr 2022 05:49:20 +1000 Subject: [PATCH] rp2/Makefile: Use cmake for "make submodules" task when needed. Because the submodule list can be updated by cmake files. Signed-off-by: Andrew Leech --- ports/rp2/Makefile | 10 +++++++++- py/mkrules.cmake | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ports/rp2/Makefile b/ports/rp2/Makefile index 461a27acad89..a41bda760307 100644 --- a/ports/rp2/Makefile +++ b/ports/rp2/Makefile @@ -19,7 +19,7 @@ CMAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST} endif all: - [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0 ${CMAKE_ARGS} + [ -e $(BUILD)/CMakeCache.txt ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0 ${CMAKE_ARGS} $(MAKE) $(MAKESILENT) -C $(BUILD) clean: @@ -28,4 +28,12 @@ clean: GIT_SUBMODULES += lib/mbedtls lib/pico-sdk lib/tinyusb submodules: +ifeq ($(BOARD),PICO) + # Run the standard submodules target with minimum required submodules above $(MAKE) -f ../../py/mkrules.mk GIT_SUBMODULES="$(GIT_SUBMODULES)" submodules +else + # Run submodules task through cmake interface to pick up any board specific dependencies. + GIT_SUBMODULES=$$(cmake -B $(BUILD)/submodules -DECHO_SUBMODULES=1 -DGIT_SUBMODULES="$(GIT_SUBMODULES)" ${CMAKE_ARGS} -S . 2>&1 | \ + grep 'GIT_SUBMODULES=' | cut -d= -f2); \ + $(MAKE) -f ../../py/mkrules.mk GIT_SUBMODULES="$${GIT_SUBMODULES}" submodules +endif diff --git a/py/mkrules.cmake b/py/mkrules.cmake index 261e153690d9..d0dc0196253a 100644 --- a/py/mkrules.cmake +++ b/py/mkrules.cmake @@ -178,3 +178,10 @@ if(MICROPY_FROZEN_MANIFEST) VERBATIM ) endif() + +# Update submodules +if(ECHO_SUBMODULES) + # If cmake is run with GIT_SUBMODULES defined on command line, process the port / board + # settings then print the final GIT_SUBMODULES variable as a fatal error and exit. + message(FATAL_ERROR "GIT_SUBMODULES=${GIT_SUBMODULES}") +endif()