]> granicus.if.org Git - esp-idf/commitdiff
build system: Don't build an sdkconfig for bootloader, share the top-level one
authorAngus Gratton <angus@espressif.com>
Wed, 9 Nov 2016 03:26:50 +0000 (14:26 +1100)
committerAngus Gratton <angus@espressif.com>
Wed, 9 Nov 2016 05:51:52 +0000 (16:51 +1100)
This works because all CONFIG variables are exported into child make processes.

components/bootloader/Makefile.projbuild
components/bootloader/src/Makefile
make/component_common.mk
make/project.mk

index 0b460059e8787a69245e8391f608fc6051630491..5bcd77b36fc728906286ca87db2670fa3a0df8ab 100644 (file)
@@ -13,21 +13,18 @@ ifndef IS_BOOTLOADER_BUILD
 BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
 BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader)
 BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
-BOOTLOADER_SDKCONFIG=$(BOOTLOADER_BUILD_DIR)/sdkconfig
 
 # Custom recursive make for bootloader sub-project
 BOOTLOADER_MAKE=+$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
-       V=$(V) SDKCONFIG=$(BOOTLOADER_SDKCONFIG) \
-       BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
+       V=$(V) BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
 
 .PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
 
-$(BOOTLOADER_BIN): | $(BOOTLOADER_BUILD_DIR)/sdkconfig
+$(BOOTLOADER_BIN):
        $(Q) $(BOOTLOADER_MAKE) $@
 
 bootloader-clean:
-       $(Q) $(BOOTLOADER_MAKE) app-clean config-clean
-       $(Q) rm -f $(BOOTLOADER_SDKCONFIG) $(BOOTLOADER_SDKCONFIG).old
+       $(Q) $(BOOTLOADER_MAKE) app-clean
 
 clean: bootloader-clean
 
@@ -43,15 +40,10 @@ ESPTOOL_ALL_FLASH_ARGS += 0x1000 $(BOOTLOADER_BIN)
 bootloader-flash: $(BOOTLOADER_BIN)
        $(ESPTOOLPY_WRITE_FLASH) 0x1000 $^
 
-# synchronise the project level config to the bootloader's
-# config
-$(BOOTLOADER_SDKCONFIG): $(PROJECT_PATH)/sdkconfig | $(BOOTLOADER_BUILD_DIR)
-       $(Q) cp $< $@
-
 $(BOOTLOADER_BUILD_DIR):
        $(Q) mkdir -p $@
 
 else
-CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include 
+CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
 
 endif
index add9c15d6134a6d13d1bdacf4924ed52821b2dff..3a939a8857fa1a18d65a1689b3d0aa7a5832a4dc 100644 (file)
@@ -4,6 +4,9 @@
 #
 
 PROJECT_NAME := bootloader
+
+#We cannot include the esp32 component directly but we need its includes.
+#This is fixed by adding CFLAGS from Makefile.projbuild
 COMPONENTS := esptool_py bootloader log spi_flash
 
 # The bootloader pseudo-component is also included in this build, for its Kconfig.projbuild to be included.
@@ -12,7 +15,7 @@ COMPONENTS := esptool_py bootloader log spi_flash
 IS_BOOTLOADER_BUILD := 1
 export IS_BOOTLOADER_BUILD
 
-#We cannot include the esp32 component directly but we need its includes. 
-#This is fixed by adding CFLAGS from Makefile.projbuild
+# include the top-level "project" include directory, for sdkconfig.h
+CFLAGS += -I$(BUILD_DIR_BASE)/../include
 
 include $(IDF_PATH)/make/project.mk
index 3177ca6e3015a761965f44d38fcc9a01d87e43ba..9db57bf948abaed1f25049bda390a2198fd5ae72 100644 (file)
@@ -66,7 +66,7 @@ COMPONENT_INCLUDES := $(OWN_INCLUDES) $(filter-out $(OWN_INCLUDES),$(COMPONENT_I
 # project.mk evaluates dependencies before calling down to here. See
 # GenerateProjectVarsTarget in project.mk.
 component_project_vars.mk::
-       $(details) "Rebuilding component project variables list $(abspath $@)"
+       $(details) "Building component project variables list $(abspath $@)"
        @echo "# Automatically generated build file. Do not edit." > $@
        @echo "COMPONENT_INCLUDES += $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS))" >> $@
        @echo "COMPONENT_LDFLAGS += $(COMPONENT_ADD_LDFLAGS)" >> $@
index ac02261869fa19931c3887fd183883b998a79950..deaf987709c93408911def05c95c77255ee8d523 100644 (file)
@@ -56,13 +56,17 @@ export COMMON_MAKEFILES
 BUILD_DIR_BASE ?= $(PROJECT_PATH)/build
 export BUILD_DIR_BASE
 
+ifndef IS_BOOTLOADER_BUILD
 # Include project config file, if it exists.
+# (bootloader build doesn't need this, config is exported from top-level)
 #
 # (Note that we only rebuild auto.conf automatically for some targets,
 # see project_config.mk for details.)
+#
 SDKCONFIG_MAKEFILE := $(BUILD_DIR_BASE)/include/config/auto.conf
 -include $(SDKCONFIG_MAKEFILE)
 export $(filter CONFIG_%,$(.VARIABLES))
+endif
 
 #Component directories. These directories are searched for components.
 #The project Makefile can override these component dirs, or define extra component directories.
@@ -114,7 +118,7 @@ include $(COMPONENT_PROJECT_VARS)
 #
 # Rebuilds if component.mk, makefiles or sdkconfig changes.
 define GenerateProjectVarsTarget
-$(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(if $(MAKE_RESTARTS),,$(SDKCONFIG_MAKEFILE)) $(BUILD_DIR_BASE)/$(2)
+$(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG) | $(BUILD_DIR_BASE)/$(2)
        $(Q) +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(1)/component.mk component_project_vars.mk COMPONENT_PATH=$(1)
 endef
 $(foreach comp,$(COMPONENT_PATHS_BUILDABLE), $(eval $(call GenerateProjectVarsTarget,$(comp),$(notdir $(comp)))))
@@ -238,8 +242,12 @@ COMPONENT_PATH := $(1)
 endef
 $(foreach componentpath,$(COMPONENT_PATHS),$(eval $(call includeProjBuildMakefile,$(componentpath))))
 
+ifndef IS_BOOTLOADER_BUILD
 # once we know component paths, we can include the config generation targets
+#
+# (bootloader build doesn't need this, config is exported from top-level)
 include $(IDF_PATH)/make/project_config.mk
+endif
 
 # A "component" library is any library in the LDFLAGS where
 # the name of the library is also a name of the component