From ea2ec888b8ad671e68fd74f26cf93e9d86a7f676 Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Mon, 31 Jul 2023 16:28:13 -0300 Subject: [PATCH] Build system: Add PREBUILD definition Add PREBUILD definition and `prebuild` recipe to call it before the `mkconfig` tool, at the beginning of the build process. This `prebuild` step enables running CPU/board-specific operations before building the firmware, like tweaking or overriding configs that need to be set after the board configuration. --- tools/Config.mk | 9 +++++++++ tools/Unix.mk | 12 +++++++++++- tools/Win.mk | 12 +++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/Config.mk b/tools/Config.mk index ef78ee2b7e..464d23b298 100644 --- a/tools/Config.mk +++ b/tools/Config.mk @@ -458,6 +458,15 @@ define PRELINK endef endif +# PREBUILD -- Perform pre build operations +# Some architectures require the use of special tools and special handling +# BEFORE building NuttX. The `Make.defs` files for those architectures +# should override the following define with the correct operations for +# that platform. + +define PREBUILD +endef + # POSTBUILD -- Perform post build operations # Some architectures require the use of special tools and special handling # AFTER building the NuttX binary. Make.defs files for those architectures diff --git a/tools/Unix.mk b/tools/Unix.mk index 439066b2ff..90d90263d9 100644 --- a/tools/Unix.mk +++ b/tools/Unix.mk @@ -244,7 +244,7 @@ include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT) # part of the overall NuttX configuration sequence. Notice that the # tools/mkconfig tool is built and used to create include/nuttx/config.h -tools/mkconfig$(HOSTEXEEXT): +tools/mkconfig$(HOSTEXEEXT): prebuild $(Q) $(MAKE) -C tools -f Makefile.host mkconfig$(HOSTEXEEXT) include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT) @@ -486,6 +486,16 @@ clean_context: clean_dirlinks include tools/LibTargets.mk +# prebuild +# +# Some architectures require the use of special tools and special handling +# BEFORE building NuttX. The `Make.defs` files for those architectures +# should override the following define with the correct operations for +# that platform. + +prebuild: + $(call PREBUILD, $(TOPDIR)) + # pass1 and pass2 # # If the 2 pass build option is selected, then this pass1 target is diff --git a/tools/Win.mk b/tools/Win.mk index 483910339c..af8b21c7ad 100644 --- a/tools/Win.mk +++ b/tools/Win.mk @@ -231,7 +231,7 @@ include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion$(HOSTEXEEXT) # part of the overall NuttX configuration sequence. Notice that the # tools\mkconfig tool is built and used to create include\nuttx\config.h -tools\mkconfig$(HOSTEXEEXT): +tools\mkconfig$(HOSTEXEEXT): prebuild $(Q) $(MAKE) -C tools -f Makefile.host mkconfig$(HOSTEXEEXT) include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT) @@ -473,6 +473,16 @@ clean_context: include tools/LibTargets.mk +# prebuild +# +# Some architectures require the use of special tools and special handling +# BEFORE building NuttX. The `Make.defs` files for those architectures +# should override the following define with the correct operations for +# that platform. + +prebuild: + $(call PREBUILD, $(TOPDIR)) + # pass1 and pass2 # # If the 2 pass build option is selected, then this pass1 target is