From f29768c404cf7d6eab618002b42d5cb9e67f4e52 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 10 Feb 2017 17:38:24 +1100 Subject: [PATCH] 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. --- .gitlab-ci.yml | 6 +++--- docs/build-system.rst | 11 +++++++++++ docs/eclipse-setup-windows.rst | 2 +- docs/eclipse-setup.rst | 2 +- make/build_examples.sh | 5 ++++- make/common.mk | 5 +++++ make/project_config.mk | 11 +++++++++++ tools/windows/eclipse_make.py | 2 +- 8 files changed, 37 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ea64e142b..96bc56e3e6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/docs/build-system.rst b/docs/build-system.rst index 0973eeb31f..b3abbd28f5 100644 --- a/docs/build-system.rst +++ b/docs/build-system.rst @@ -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 -------------------------- diff --git a/docs/eclipse-setup-windows.rst b/docs/eclipse-setup-windows.rst index 4cf8fe5fb5..aeb011c0c1 100644 --- a/docs/eclipse-setup-windows.rst +++ b/docs/eclipse-setup-windows.rst @@ -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*. diff --git a/docs/eclipse-setup.rst b/docs/eclipse-setup.rst index 1716dbf167..140e81e173 100644 --- a/docs/eclipse-setup.rst +++ b/docs/eclipse-setup.rst @@ -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. diff --git a/make/build_examples.sh b/make/build_examples.sh index e85ec26a70..ee429309e1 100755 --- a/make/build_examples.sh +++ b/make/build_examples.sh @@ -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 )) diff --git a/make/common.mk b/make/common.mk index 4281bad94b..41a87b3a64 100644 --- a/make/common.mk +++ b/make/common.mk @@ -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 diff --git a/make/project_config.mk b/make/project_config.mk index 3537f786ba..c0369f95f8 100644 --- a/make/project_config.mk +++ b/make/project_config.mk @@ -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 diff --git a/tools/windows/eclipse_make.py b/tools/windows/eclipse_make.py index 572e171e26..e65cfc9cc3 100644 --- a/tools/windows/eclipse_make.py +++ b/tools/windows/eclipse_make.py @@ -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())