From 722d67ea3662763a28131f5ac758de7b742b79f6 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 25 Aug 2020 17:04:18 +1000 Subject: [PATCH 1/2] idf.py: Disable CMake --warn-uninitialized option by default Can still be enabled by passing --cmake-warn-uninitialized on the command line Prevents CMake warnings printed by default if IDF_PATH is underneath the CMake project directory. The reason for this is that CMake --warn-uninitialized only enables checks inside the project directory (ie top-level CMakeLists.txt directory and subdirectories), it doesn't enable for files included from other directories. (The only way to enable warnings in other directories is to pass --check-system-dirs and this looks like it's only useful for CMake's own developers as it prints a lot of warnings from inside CMake otherwise - see https://gitlab.kitware.com/cmake/cmake/-/issues/19645 ) Plan to follow up with a later commit to clean up most of the warnings (which aren't problems for CMake execution), but we'll also disable this option by default to avoid this unexpected triggering of IDF warnings. --- docs/en/api-guides/build-system.rst | 1 + tools/idf_py_actions/core_ext.py | 6 ++++-- tools/idf_py_actions/tools.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index f5d7a6f8b5..72fc77184a 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -115,6 +115,7 @@ Here is a list of some useful options: Note that some older versions of CCache may exhibit bugs on some platforms, so if files are not rebuilt as expected then try disabling ccache and build again. CCache can be enabled by default by setting the ``IDF_ENABLE_CCACHE`` environment variable to a non-zero value. - ``-v`` flag causes both ``idf.py`` and the build system to produce verbose build output. This can be useful for debugging build problems. +- ``--cmake-warn-uninitialized`` (or ``-w``) will cause CMake to print uninitialized variable warnings inside the project directory (not for directories not found inside the project directory). This only controls CMake variable warnings inside CMake itself, not other types of build warnings. This option can also be set permanently by setting the ``IDF_CMAKE_WARN_UNINITIALIZED`` environment variable to a non-zero value. Using CMake Directly -------------------- diff --git a/tools/idf_py_actions/core_ext.py b/tools/idf_py_actions/core_ext.py index 182194785b..7ff2e522b2 100644 --- a/tools/idf_py_actions/core_ext.py +++ b/tools/idf_py_actions/core_ext.py @@ -210,8 +210,10 @@ def action_extensions(base_actions, project_path): "default": None, }, { - "names": ["-n", "--no-warnings"], - "help": "Disable Cmake warnings.", + "names": ["-w/-n", "--cmake-warn-uninitialized/--no-warnings"], + "help": ("Enable CMake uninitialized variable warnings for CMake files inside the project directory. " + "(--no-warnings is now the default, and doesn't need to be specified.)"), + "envvar": "IDF_CMAKE_WARN_UNINITIALIZED", "is_flag": True, "default": False, }, diff --git a/tools/idf_py_actions/tools.py b/tools/idf_py_actions/tools.py index 788bcca5e3..356c5bc374 100644 --- a/tools/idf_py_actions/tools.py +++ b/tools/idf_py_actions/tools.py @@ -199,7 +199,7 @@ def ensure_build_directory(args, prog_name, always_run_cmake=False): "-DPYTHON_DEPS_CHECKED=1", "-DESP_PLATFORM=1", ] - if not args.no_warnings: + if args.cmake_warn_uninitialized: cmake_args += ["--warn-uninitialized"] if args.define_cache_entry: From 0831d06dee9fad6f10f23dd21efda09417164c85 Mon Sep 17 00:00:00 2001 From: Victor Lamoine Date: Tue, 18 Aug 2020 22:59:36 +0200 Subject: [PATCH 2/2] Fix ccache documentation: environment variable is IDF_CCACHE_ENABLE Merges https://github.com/espressif/esp-idf/pull/5753 --- docs/en/api-guides/build-system.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 72fc77184a..d4fee5066f 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -113,7 +113,7 @@ Here is a list of some useful options: - ``-B `` allows overriding the build directory from the default ``build`` subdirectory of the project directory. - ``--ccache`` flag can be used to enable CCache_ when compiling source files, if the CCache_ tool is installed. This can dramatically reduce some build times. -Note that some older versions of CCache may exhibit bugs on some platforms, so if files are not rebuilt as expected then try disabling ccache and build again. CCache can be enabled by default by setting the ``IDF_ENABLE_CCACHE`` environment variable to a non-zero value. +Note that some older versions of CCache may exhibit bugs on some platforms, so if files are not rebuilt as expected then try disabling ccache and build again. CCache can be enabled by default by setting the ``IDF_CCACHE_ENABLE`` environment variable to a non-zero value. - ``-v`` flag causes both ``idf.py`` and the build system to produce verbose build output. This can be useful for debugging build problems. - ``--cmake-warn-uninitialized`` (or ``-w``) will cause CMake to print uninitialized variable warnings inside the project directory (not for directories not found inside the project directory). This only controls CMake variable warnings inside CMake itself, not other types of build warnings. This option can also be set permanently by setting the ``IDF_CMAKE_WARN_UNINITIALIZED`` environment variable to a non-zero value.