Просмотр исходного кода

Merge branch 'bugfix/env_var_SDKCONFIG_DEFAULTS_fail_with_bootloader_subproject' into 'master'

build_system: stop looking for env var `SDKCONFIG_DEFAULTS` in bootloader subproject

See merge request espressif/esp-idf!21091
Fu Hanxi 3 лет назад
Родитель
Сommit
fbef416c36
2 измененных файлов с 26 добавлено и 3 удалено
  1. 8 1
      tools/cmake/project.cmake
  2. 18 2
      tools/test_build_system/test_common.py

+ 8 - 1
tools/cmake/project.cmake

@@ -396,7 +396,14 @@ macro(project project_name)
     # PROJECT_NAME is taken from the passed name from project() call
     # PROJECT_DIR is set to the current directory
     # PROJECT_VER is from the version text or git revision of the current repo
-    set(_sdkconfig_defaults "$ENV{SDKCONFIG_DEFAULTS}")
+
+    # SDKCONFIG_DEFAULTS environment variable may specify a file name relative to the root of the project.
+    # When building the bootloader, ignore this variable, since:
+    # 1. The bootloader project uses an existing SDKCONFIG file from the top-level project
+    # 2. File specified by SDKCONFIG_DEFAULTS will not be found relative to the root of the bootloader project
+    if(NOT BOOTLOADER_BUILD)
+        set(_sdkconfig_defaults "$ENV{SDKCONFIG_DEFAULTS}")
+    endif()
 
     if(NOT _sdkconfig_defaults)
         if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")

+ 18 - 2
tools/test_build_system/test_common.py

@@ -5,7 +5,8 @@ import subprocess
 from pathlib import Path
 
 import pytest
-from test_build_system_helpers import EnvDict, IdfPyFunc, get_snapshot, replace_in_file
+from _pytest.monkeypatch import MonkeyPatch
+from test_build_system_helpers import IdfPyFunc, get_snapshot, replace_in_file
 
 
 @pytest.mark.usefixtures('test_app_copy')
@@ -34,7 +35,7 @@ def test_of_test_app_copy(idf_py: IdfPyFunc) -> None:
 
 
 @pytest.mark.usefixtures('test_app_copy')
-def test_hints_no_color_output_when_noninteractive(idf_py: EnvDict) -> None:
+def test_hints_no_color_output_when_noninteractive(idf_py: IdfPyFunc) -> None:
     """Check that idf.py hints don't include color escape codes in non-interactive builds"""
 
     # make the build fail in such a way that idf.py shows a hint
@@ -55,3 +56,18 @@ def test_idf_copy(idf_copy: Path, idf_py: IdfPyFunc) -> None:
     # For example, we can check if idf.py build can work without the .git directory:
     shutil.rmtree(idf_copy / '.git', ignore_errors=True)
     idf_py('build')
+
+
+def test_idf_build_with_env_var_sdkconfig_defaults(
+    test_app_copy: Path,
+    idf_py: IdfPyFunc,
+    monkeypatch: MonkeyPatch,
+) -> None:
+    with open(test_app_copy / 'sdkconfig.test', 'w') as fw:
+        fw.write('CONFIG_BT_ENABLED=y')
+
+    monkeypatch.setenv('SDKCONFIG_DEFAULTS', 'sdkconfig.test')
+    idf_py('build')
+
+    with open(test_app_copy / 'sdkconfig') as fr:
+        assert 'CONFIG_BT_ENABLED=y' in fr.read()