Fixed an issue when `"libArchive": false` in "library.json" does not work // Resolve #3403

This commit is contained in:
Ivan Kravets
2020-03-06 00:37:48 +02:00
parent 3a27fbc883
commit 59e1c88726
5 changed files with 12 additions and 7 deletions

View File

@ -12,7 +12,8 @@ PlatformIO Core 4
* Added support for Arm Mbed "module.json" ``dependencies`` field (`issue #3400 <https://github.com/platformio/platformio-core/issues/3400>`_)
* Fixed an issue when quitting from PlatformIO IDE does not shutdown PIO Home server
* Fixed an issue "the JSON object must be str, not 'bytes'" when PIO Home is used with Python 3.5 (`issue #3396 <https://github.com/platformio/platformio-core/issues/3396>`_)
* Fixed an issue when Python 2 does not keep encoding when converting .INO file (`issue #3393 <https://github.com/platformio/platformio-core/issues/3393>`_)
* Fixed an issue when Python 2 does not keep encoding when converting ".ino" (`issue #3393 <https://github.com/platformio/platformio-core/issues/3393>`_)
* Fixed an issue when ``"libArchive": false`` in "library.json" does not work (`issue #3403 <https://github.com/platformio/platformio-core/issues/3403>`_)
4.2.1 (2020-02-17)
~~~~~~~~~~~~~~~~~~

View File

@ -717,9 +717,11 @@ class PlatformIOLibBuilder(LibBuilderBase):
@property
def lib_archive(self):
unique_value = "_not_declared_%s" % id(self)
global_value = self.env.GetProjectOption("lib_archive", unique_value)
if global_value != unique_value:
missing = object()
global_value = self.env.GetProjectConfig().getraw(
"env:" + self.env["PIOENV"], "lib_archive", missing
)
if global_value != missing:
return global_value
return self._manifest.get("build", {}).get(
"libArchive", LibBuilderBase.lib_archive.fget(self)

View File

@ -14,7 +14,7 @@
from __future__ import absolute_import
from platformio.project.config import ProjectConfig, ProjectOptions
from platformio.project.config import MISSING, ProjectConfig, ProjectOptions
def GetProjectConfig(env):
@ -25,7 +25,7 @@ def GetProjectOptions(env, as_dict=False):
return env.GetProjectConfig().items(env=env["PIOENV"], as_dict=as_dict)
def GetProjectOption(env, option, default=None):
def GetProjectOption(env, option, default=MISSING):
return env.GetProjectConfig().get("env:" + env["PIOENV"], option, default)

View File

@ -280,7 +280,7 @@ class ProjectConfigBase(object):
value = envvar_value
if value == MISSING:
value = option_meta.default or default
value = default if default != MISSING else option_meta.default
if value == MISSING:
return None

View File

@ -123,6 +123,8 @@ def test_defaults(config):
)
assert config.get("env:extra_2", "lib_compat_mode") == "soft"
assert config.get("env:extra_2", "build_type") == "release"
assert config.get("env:extra_2", "build_type", None) is None
assert config.get("env:extra_2", "lib_archive", "no") is False
def test_sections(config):