examples: Move sdkconfig.defaults support into build system

Is used fairly widely, and a little bit buggy in the form
where it was in each Makefile (didn't always get copied in place).
This commit is contained in:
Angus Gratton 2016-12-21 12:46:24 +11:00 committed by Wu Jian Gang
parent d0fccbce15
commit 2350288a33
8 changed files with 28 additions and 40 deletions

View file

@ -477,3 +477,12 @@ is set then the component can instruct the linker to link other binaries instead
.. _esp-idf-template: https://github.com/espressif/esp-idf-template
.. _GNU Make Manual: https://www.gnu.org/software/make/manual/make.html
.. _[_f1]: Actually, some components in esp-idf are "pure configuration" components that don't have a component.mk file, only a Makefile.projbuild and/or Kconfig.projbuild file. However, these components are unusual and most components have a component.mk file.
Custom sdkconfig defaults
-------------------------
For example projects or other projects where you don't want to specify a full sdkconfig configuration, but you do want to override some key values from the esp-idf defaults, it is possible to create a file ``sdkconfig.defaults`` in the project directory. This file will be used when running ``make defconfig``, or creating a new config from scratch.
To override the name of this file, set the ``SDKCONFIG_DEFAULTS`` environment variable.

View file

@ -6,11 +6,3 @@
PROJECT_NAME := ble_adv
include $(IDF_PATH)/make/project.mk
# Copy some defaults into the sdkconfig by default
# so BT stack is enabled
sdkconfig: sdkconfig.defaults
$(Q) cp $< $@
menuconfig: sdkconfig
defconfig: sdkconfig

View file

@ -8,11 +8,3 @@ PROJECT_NAME := blufi_demo
COMPONENT_ADD_INCLUDEDIRS := components/include
include $(IDF_PATH)/make/project.mk
# Copy some defaults into the sdkconfig by default
# so BT stack is enabled
sdkconfig: sdkconfig.defaults
$(Q) cp $< $@
menuconfig: sdkconfig
defconfig: sdkconfig

View file

@ -8,11 +8,3 @@ PROJECT_NAME := gatt_server_demos
COMPONENT_ADD_INCLUDEDIRS := components/include
include $(IDF_PATH)/make/project.mk
# Copy some defaults into the sdkconfig by default
# so BT stack is enabled
sdkconfig: sdkconfig.defaults
$(Q) cp $< $@
menuconfig: sdkconfig
defconfig: sdkconfig

View file

@ -8,11 +8,3 @@ PROJECT_NAME := gatt_client_demo
COMPONENT_ADD_INCLUDEDIRS := components/include
include $(IDF_PATH)/make/project.mk
# Copy some defaults into the sdkconfig by default
# so BT stack is enabled
sdkconfig: sdkconfig.defaults
$(Q) cp $< $@
menuconfig: sdkconfig
defconfig: sdkconfig

View file

@ -1,5 +0,0 @@
# Some sdkconfig parameters overriden from the defaults for this example,
# This file is in git but will be overwritten with the autogenerated file
# the first time "menuconfig" is run (changes ignored by git).
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_TWO_OTA=y

View file

@ -0,0 +1,4 @@
# Default sdkconfig parameters to use the OTA
# partition table layout, with a 4MB flash size
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_TWO_OTA=y

View file

@ -11,6 +11,10 @@ KCONFIG_TOOL_DIR=$(IDF_PATH)/tools/kconfig
# unless it's overriden (happens for bootloader)
SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig
# SDKCONFIG_DEFAULTS is an optional file containing default
# overrides (usually used for esp-idf examples)
SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults
# reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules
$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
MAKEFLAGS=$(ORIGINAL_MAKEFLAGS) CC=$(HOSTCC) LD=$(HOSTLD) \
@ -21,21 +25,29 @@ KCONFIG_TOOL_ENV=KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfi
COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \
COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)"
menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig | defconfig
$(summary) MENUCONFIG
$(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
ifeq ("$(wildcard $(SDKCONFIG))","")
ifeq ("$(call prereq_if_explicit,defconfig)","")
# if not configuration is present and defconfig is not a target, run makeconfig
$(SDKCONFIG): menuconfig
# if not configuration is present and defconfig is not a target, run defconfig then menuconfig
$(SDKCONFIG): defconfig menuconfig
else
# otherwise, just defconfig
$(SDKCONFIG): defconfig
endif
endif
$(wildcard $(PROJECT_PATH)/sdkconfig.defaults): | menuconfig defconfig
cp $< $@
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
$(summary) DEFCONFIG
ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","")
cp $(SDKCONFIG_DEFAULTS) $(SDKCONFIG)
endif
mkdir -p $(BUILD_DIR_BASE)/include/config
$(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig