Build system: Add new BATCH_BUILD flag to disable interactive parts of the build

Mostly useful for Eclipse (where accidentally running interactive
config hangs the build), but also good for CI and other automated
build systems.
This commit is contained in:
Angus Gratton 2017-02-10 17:38:24 +11:00
parent c0f155f6ff
commit f29768c404
8 changed files with 37 additions and 7 deletions

View File

@ -31,6 +31,7 @@ build_template_app:
SDK_PATH: "$CI_PROJECT_DIR"
IDF_PATH: "$CI_PROJECT_DIR"
GIT_STRATEGY: clone
BATCH_BUILD: "1"
script:
- git clone https://github.com/espressif/esp-idf-template.git
@ -39,13 +40,11 @@ build_template_app:
# using on esp-idf. If it doesn't exist then just stick to the default
# branch
- git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-idf-template default branch..."
- make defconfig
# Test debug build (default)
- make all V=1
# Now test release build
- make clean
- sed -i.bak -e's/CONFIG_OPTIMIZATION_LEVEL_DEBUG\=y/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/' sdkconfig
- make defconfig
- make all V=1
# Check if there are any stray printf/ets_printf references in WiFi libs
- cd ../components/esp32/lib
@ -63,6 +62,8 @@ build_template_app:
SDK_PATH: "$CI_PROJECT_DIR"
IDF_PATH: "$CI_PROJECT_DIR"
GIT_STRATEGY: clone
BATCH_BUILD: "1"
build_ssc:
<<: *build_template
@ -103,7 +104,6 @@ build_esp_idf_tests:
script:
- cd tools/unit-test-app
- git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..."
- make defconfig
- make TESTS_ALL=1
- python UnitTestParser.py

View File

@ -305,6 +305,17 @@ Second Level: Component Makefiles
To better understand the component make process, have a read through the ``component_wrapper.mk`` file and some of the ``component.mk`` files included with esp-idf.
Running Make Non-Interactively
------------------------------
When running ``make`` in a situation where you don't want interactive prompts (for example: inside an IDE or an automated build system) append ``BATCH_BUILD=1`` to the make arguments (or set it as an environment variable).
Setting ``BATCH_BUILD`` implies the following:
- Verbose output (same as ``V=1``, see below). If you don't want verbose output, also set ``V=0``.
- If the project configuration is missing new configuration items (from new components or esp-idf updates) then the project use the default values, instead of prompting the user for each item.
- If the build system needs to invoke ``menuconfig``, an error is printed and the build fails.
Debugging The Make Process
--------------------------

View File

@ -45,7 +45,7 @@ Project Properties
* Click on the "Environment" properties page under "C/C++ Build":
* Click "Add..." and enter name ``V`` and value ``1``.
* Click "Add..." and enter name ``BATCH_BUILD`` and value ``1``.
* Click "Add..." again, and enter name ``IDF_PATH``. The value should be the full path where ESP-IDF is installed. The IDF_PATH directory should be specified using forwards slashes not backslashes, ie *C:/Users/MyUser/Development/esp-idf*.

View File

@ -45,7 +45,7 @@ Project Properties
* The new project will appear under Project Explorer. Right-click the project and choose Properties from the context menu.
* Click on the "Environment" properties page under "C/C++ Build". Click "Add..." and enter name ``V`` and value ``1``.
* Click on the "Environment" properties page under "C/C++ Build". Click "Add..." and enter name ``BATCH_BUILD`` and value ``1``.
* Click "Add..." again, and enter name ``IDF_PATH``. The value should be the full path where ESP-IDF is installed.

View File

@ -9,6 +9,9 @@
#
[ -z ${IDF_PATH} ] && echo "IDF_PATH is not set" && exit 1
export BATCH_BUILD=1
export V=0 # only build verbose if there's an error
EXAMPLE_NUM=1
RESULT=0
FAILED_EXAMPLES=""
@ -36,7 +39,7 @@ for category in ${IDF_PATH}/examples/*; do
set -e
make clean defconfig
make $* all 2>&1 | tee $BUILDLOG
) || { RESULT=$?; FAILED_EXAMPLES+=" ${example}"; make V=1; } # only build verbose if there's an error
) || { RESULT=$?; FAILED_EXAMPLES+=" ${example}"; make V=1; } # verbose output for errors
popd
EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 ))

View File

@ -10,6 +10,11 @@ SDKCONFIG_MAKEFILE ?= $(abspath $(BUILD_DIR_BASE)/include/config/auto.conf)
include $(SDKCONFIG_MAKEFILE)
export SDKCONFIG_MAKEFILE # sub-makes (like bootloader) will reuse this path
# BATCH_BUILD flag disables interactive terminal features, defaults to verbose build
ifdef BATCH_BUILD
V ?= 1
endif
#Handling of V=1/VERBOSE=1 flag
#
# if V=1, $(summary) does nothing and $(details) will echo extra details

View File

@ -56,7 +56,15 @@ ifeq ("$(MAKE_RESTARTS)","")
menuconfig: $(KCONFIG_TOOL_DIR)/mconf
$(summary) MENUCONFIG
ifdef BATCH_BUILD
@echo "Can't run interactive configuration inside non-interactive build process."
@echo ""
@echo "Open a command line terminal and run 'make menuconfig' from there."
@echo "See esp-idf documentation for more details."
@exit 1
else
$(call RunConf,mconf)
endif
# defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present
defconfig: $(KCONFIG_TOOL_DIR)/conf
@ -70,6 +78,9 @@ endif
# ensure generated config files are up to date
$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(KCONFIG_TOOL_DIR)/conf $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig)
$(summary) GENCONFIG
ifdef BATCH_BUILD # can't prompt for new config values like on terminal
$(call RunConf,conf --olddefconfig)
endif
$(call RunConf,conf --silentoldconfig)
touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h # ensure newer than sdkconfig

View File

@ -26,7 +26,7 @@ def check_path(path):
def main():
print("Running make in '%s'" % check_path(os.getcwd()))
make = subprocess.Popen(["make"] + sys.argv[1:] + ["V=1"], stdout=subprocess.PIPE)
make = subprocess.Popen(["make"] + sys.argv[1:] + ["BATCH_BUILD=1"], stdout=subprocess.PIPE)
for line in iter(make.stdout.readline, ''):
line = re.sub(UNIX_PATH_RE, lambda m: check_path(m.group(0)), line)
print(line.rstrip())