diff --git a/HISTORY.rst b/HISTORY.rst index 68e1f024..86f150a8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ PlatformIO Core 5 - Upgraded build engine to the SCons 4.3 (`release notes `__) - Fixed an issue with the CLion project generator when a macro contains a space (`issue #4102 `_) - Fixed an issue with the NetBeans project generator when the path to PlatformIO contains a space (`issue #4096 `_) +- Fixed a bug when the system environment variable does not override a project configuration option (`issue #4125 `_) 5.2.3 (2021-11-05) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/config.py b/platformio/project/config.py index d930dfa7..492bacf2 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -271,7 +271,7 @@ class ProjectConfigBase(object): if value == MISSING: value = "" value += ("\n" if value else "") + envvar_value - elif envvar_value and value == MISSING: + elif envvar_value: value = envvar_value if value == MISSING: diff --git a/tests/test_projectconf.py b/tests/test_projectconf.py index da9b7732..350bdeaa 100644 --- a/tests/test_projectconf.py +++ b/tests/test_projectconf.py @@ -226,7 +226,7 @@ def test_sysenv_options(config): "-DSYSENVDEPS1 -DSYSENVDEPS2", ] assert config.get("env:base", "upload_port") == "/dev/sysenv/port" - assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port" + assert config.get("env:extra_2", "upload_port") == "/dev/sysenv/port" assert config.get("env:base", "build_unflags") == ["-DREMOVE_MACRO"] # env var as option @@ -244,10 +244,16 @@ def test_sysenv_options(config): "upload_port", ] - # sysenv - custom_core_dir = os.path.join(os.getcwd(), "custom") + # sysenv dirs + custom_core_dir = os.path.join(os.getcwd(), "custom-core") + custom_src_dir = os.path.join(os.getcwd(), "custom-src") + custom_build_dir = os.path.join(os.getcwd(), "custom-build") os.environ["PLATFORMIO_HOME_DIR"] = custom_core_dir + os.environ["PLATFORMIO_SRC_DIR"] = custom_src_dir + os.environ["PLATFORMIO_BUILD_DIR"] = custom_build_dir assert config.get("platformio", "core_dir") == os.path.realpath(custom_core_dir) + assert config.get("platformio", "src_dir") == os.path.realpath(custom_src_dir) + assert config.get("platformio", "build_dir") == os.path.realpath(custom_build_dir) # cleanup system environment variables del os.environ["PLATFORMIO_BUILD_FLAGS"] @@ -255,6 +261,8 @@ def test_sysenv_options(config): del os.environ["PLATFORMIO_UPLOAD_PORT"] del os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"] del os.environ["PLATFORMIO_HOME_DIR"] + del os.environ["PLATFORMIO_SRC_DIR"] + del os.environ["PLATFORMIO_BUILD_DIR"] def test_getraw_value(config):