diff --git a/platformio/project/config.py b/platformio/project/config.py index 8e4ec096..7f2efb03 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -276,6 +276,8 @@ class ProjectConfigBase(object): if value == MISSING: value = default if default != MISSING else option_meta.default + if callable(value): + value = value() if value == MISSING: return None diff --git a/platformio/project/options.py b/platformio/project/options.py index c12679b9..ee5fd603 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -60,7 +60,7 @@ class ConfigOption(object): # pylint: disable=too-many-instance-attributes type="string", multiple=self.multiple, sysenvvar=self.sysenvvar, - default=self.default, + default=self.default() if callable(self.default) else self.default, ) if isinstance(self.type, click.ParamType): result["type"] = self.type.name @@ -168,7 +168,7 @@ ProjectOptions = OrderedDict( ), oldnames=["home_dir"], sysenvvar="PLATFORMIO_CORE_DIR", - default=get_default_core_dir(), + default=get_default_core_dir, validate=validate_dir, ), ConfigPlatformioOption( diff --git a/tests/test_projectconf.py b/tests/test_projectconf.py index b3e85863..0fada8c3 100644 --- a/tests/test_projectconf.py +++ b/tests/test_projectconf.py @@ -254,9 +254,15 @@ def test_sysenv_options(config): 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) + assert os.path.realpath(config.get("platformio", "core_dir")) == os.path.realpath( + custom_core_dir + ) + assert os.path.realpath(config.get("platformio", "src_dir")) == os.path.realpath( + custom_src_dir + ) + assert os.path.realpath(config.get("platformio", "build_dir")) == os.path.realpath( + custom_build_dir + ) # cleanup system environment variables del os.environ["PLATFORMIO_BUILD_FLAGS"]