forked from platformio/platformio-core
Fixed an issue when referencing "*_dir" option from a custom project configuration environment // Resolve #4110
This commit is contained in:
@ -16,7 +16,8 @@ PlatformIO Core 5
|
||||
- Upgraded build engine to the SCons 4.3 (`release notes <https://github.com/SCons/scons/blob/rel_4.3.0/CHANGES.txt>`__)
|
||||
- Fixed an issue with the CLion project generator when a macro contains a space (`issue #4102 <https://github.com/platformio/platformio-core/issues/4102>`_)
|
||||
- Fixed an issue with the NetBeans project generator when the path to PlatformIO contains a space (`issue #4096 <https://github.com/platformio/platformio-core/issues/4096>`_)
|
||||
- Fixed a bug when the system environment variable does not override a project configuration option (`issue #4125 <https://github.com/platformio/platformio-core/issues/4125>`_)
|
||||
- Fixed an issue when the system environment variable does not override a project configuration option (`issue #4125 <https://github.com/platformio/platformio-core/issues/4125>`_)
|
||||
- Fixed an issue when referencing "*_dir" option from a custom project configuration environment (`issue #4110 <https://github.com/platformio/platformio-core/issues/4110>`_)
|
||||
|
||||
5.2.3 (2021-11-05)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -279,9 +279,6 @@ class ProjectConfigBase(object):
|
||||
if value == MISSING:
|
||||
return None
|
||||
|
||||
if option_meta.validate:
|
||||
value = option_meta.validate(value)
|
||||
|
||||
return self._expand_interpolations(value)
|
||||
|
||||
def _expand_interpolations(self, value):
|
||||
@ -318,6 +315,8 @@ class ProjectConfigBase(object):
|
||||
if not option_meta:
|
||||
return value
|
||||
|
||||
if option_meta.validate:
|
||||
value = option_meta.validate(value)
|
||||
if option_meta.multiple:
|
||||
value = self.parse_multi_values(value or [])
|
||||
try:
|
||||
|
@ -117,14 +117,13 @@ def validate_dir(path):
|
||||
return fs.normalize_path(path)
|
||||
|
||||
|
||||
def validate_core_dir(path):
|
||||
default_dir = ProjectOptions["platformio.core_dir"].default
|
||||
win_core_dir = None
|
||||
if IS_WINDOWS and path == default_dir:
|
||||
def get_default_core_dir():
|
||||
path = os.path.join(fs.expanduser("~"), ".platformio")
|
||||
if IS_WINDOWS:
|
||||
win_core_dir = os.path.splitdrive(path)[0] + "\\.platformio"
|
||||
if os.path.isdir(win_core_dir):
|
||||
path = win_core_dir
|
||||
return validate_dir(path)
|
||||
return win_core_dir
|
||||
return path
|
||||
|
||||
|
||||
ProjectOptions = OrderedDict(
|
||||
@ -169,8 +168,8 @@ ProjectOptions = OrderedDict(
|
||||
),
|
||||
oldnames=["home_dir"],
|
||||
sysenvvar="PLATFORMIO_CORE_DIR",
|
||||
default=os.path.join(fs.expanduser("~"), ".platformio"),
|
||||
validate=validate_core_dir,
|
||||
default=get_default_core_dir(),
|
||||
validate=validate_dir,
|
||||
),
|
||||
ConfigPlatformioOption(
|
||||
group="directory",
|
||||
|
@ -26,7 +26,8 @@ from platformio.project.exception import InvalidProjectConfError, UnknownEnvName
|
||||
BASE_CONFIG = """
|
||||
[platformio]
|
||||
env_default = base, extra_2
|
||||
build_dir = ~/tmp/pio-$PROJECT_HASH
|
||||
src_dir = ${custom.src_dir}
|
||||
build_dir = ${custom.build_dir}
|
||||
extra_configs =
|
||||
extra_envs.ini
|
||||
extra_debug.ini
|
||||
@ -53,6 +54,8 @@ extends = strict_ldf, monitor_custom
|
||||
build_flags = -D RELEASE
|
||||
|
||||
[custom]
|
||||
src_dir = source
|
||||
build_dir = ~/tmp/pio-$PROJECT_HASH
|
||||
debug_flags = -D RELEASE
|
||||
lib_flags = -lc -lm
|
||||
extra_flags = ${sysenv.__PIO_TEST_CNF_EXTRA_FLAGS}
|
||||
@ -297,6 +300,7 @@ def test_getraw_value(config):
|
||||
config.getraw("custom", "debug_server")
|
||||
== f"\n{packages_dir}/tool-openocd/openocd\n--help"
|
||||
)
|
||||
assert config.getraw("platformio", "build_dir") == "~/tmp/pio-$PROJECT_HASH"
|
||||
|
||||
|
||||
def test_get_value(config):
|
||||
@ -327,10 +331,16 @@ def test_get_value(config):
|
||||
os.path.join(DEFAULT_CORE_DIR, "packages/tool-openocd/openocd"),
|
||||
"--help",
|
||||
]
|
||||
# test relative dir
|
||||
assert config.get("platformio", "src_dir") == os.path.abspath(
|
||||
os.path.join(os.getcwd(), "source")
|
||||
)
|
||||
|
||||
|
||||
def test_items(config):
|
||||
assert config.items("custom") == [
|
||||
("src_dir", "source"),
|
||||
("build_dir", "~/tmp/pio-$PROJECT_HASH"),
|
||||
("debug_flags", "-D DEBUG=1"),
|
||||
("lib_flags", "-lc -lm"),
|
||||
("extra_flags", ""),
|
||||
@ -473,7 +483,8 @@ def test_dump(tmpdir_factory):
|
||||
(
|
||||
"platformio",
|
||||
[
|
||||
("build_dir", "~/tmp/pio-$PROJECT_HASH"),
|
||||
("src_dir", "${custom.src_dir}"),
|
||||
("build_dir", "${custom.build_dir}"),
|
||||
("extra_configs", ["extra_envs.ini", "extra_debug.ini"]),
|
||||
("default_envs", ["base", "extra_2"]),
|
||||
],
|
||||
@ -497,6 +508,8 @@ def test_dump(tmpdir_factory):
|
||||
(
|
||||
"custom",
|
||||
[
|
||||
("src_dir", "source"),
|
||||
("build_dir", "~/tmp/pio-$PROJECT_HASH"),
|
||||
("debug_flags", "-D RELEASE"),
|
||||
("lib_flags", "-lc -lm"),
|
||||
("extra_flags", "${sysenv.__PIO_TEST_CNF_EXTRA_FLAGS}"),
|
||||
|
Reference in New Issue
Block a user