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
This commit is contained in:
Fu Hanxi
2022-11-16 19:14:11 +08:00
2 changed files with 26 additions and 3 deletions

View File

@@ -396,7 +396,14 @@ macro(project project_name)
# PROJECT_NAME is taken from the passed name from project() call # PROJECT_NAME is taken from the passed name from project() call
# PROJECT_DIR is set to the current directory # PROJECT_DIR is set to the current directory
# PROJECT_VER is from the version text or git revision of the current repo # PROJECT_VER is from the version text or git revision of the current repo
# 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}") set(_sdkconfig_defaults "$ENV{SDKCONFIG_DEFAULTS}")
endif()
if(NOT _sdkconfig_defaults) if(NOT _sdkconfig_defaults)
if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults") if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")

View File

@@ -5,7 +5,8 @@ import subprocess
from pathlib import Path from pathlib import Path
import pytest 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') @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') @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""" """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 # 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: # For example, we can check if idf.py build can work without the .git directory:
shutil.rmtree(idf_copy / '.git', ignore_errors=True) shutil.rmtree(idf_copy / '.git', ignore_errors=True)
idf_py('build') 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()