]> granicus.if.org Git - esp-idf/commitdiff
examples: Move sdkconfig.defaults support into build system
authorAngus Gratton <angus@espressif.com>
Wed, 21 Dec 2016 01:46:24 +0000 (12:46 +1100)
committerWu Jian Gang <wujiangang@espressif.com>
Thu, 29 Dec 2016 09:37:30 +0000 (17:37 +0800)
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).

docs/build_system.rst
examples/05_ble_adv/Makefile
examples/12_blufi/Makefile
examples/14_gatt_server/Makefile
examples/15_gatt_client/Makefile
examples/18_ota/sdkconfig [deleted file]
examples/18_ota/sdkconfig.defaults [new file with mode: 0644]
make/project_config.mk

index 6687fa69ed2f8d70fa4ccb2a583052dc1bcb107e..2e388bd4956ec97a739fbb7a5858670b89467ff7 100644 (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.
+
index 3a913b817bce8ed60f585918209fbcdd0caed9cb..2319786d4a9dc05c6a18230cf7085ce6fe6bd356 100644 (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
index 7e7548444f487a1b43c6d62966f1311ef0d8abc5..9c80f26c1a55d2b8d2bc087c676a6c4fe8b87950 100644 (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
index d7732bd280737f083626714f3e1bc17143a6c07f..2f76e60b607134e1afc4859882601e67b08a401b 100644 (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
index 93f793308f733a22986bff427b80ed65ae0dc70b..700ffd7add7ba8aa25ecff434a180ea1f08ee691 100644 (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
diff --git a/examples/18_ota/sdkconfig b/examples/18_ota/sdkconfig
deleted file mode 100644 (file)
index 070b529..0000000
+++ /dev/null
@@ -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
diff --git a/examples/18_ota/sdkconfig.defaults b/examples/18_ota/sdkconfig.defaults
new file mode 100644 (file)
index 0000000..2289a82
--- /dev/null
@@ -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
index 187d1ac28257ad43577b1929e6296bf013c94ff8..b8e40f435761da7ae3614372ddaf60c0f576e438 100644 (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