mirror of
https://github.com/platformio/platformio-core.git
synced 2025-08-01 10:54:27 +02:00
This commit is contained in:
@@ -14,6 +14,7 @@ PlatformIO Core 5
|
|||||||
- Allowed to override a default library builder via a new ``builder`` field in a ``build`` group of `library.json <https://docs.platformio.org/page/librarymanager/config.html#build>`__ manifest (`issue #3957 <https://github.com/platformio/platformio-core/issues/3957>`_)
|
- Allowed to override a default library builder via a new ``builder`` field in a ``build`` group of `library.json <https://docs.platformio.org/page/librarymanager/config.html#build>`__ manifest (`issue #3957 <https://github.com/platformio/platformio-core/issues/3957>`_)
|
||||||
- Fixed a "KeyError: Invalid board option 'build.cpu'" when using a precompiled library with a board that does not have a CPU field in the manifest (`issue #4056 <https://github.com/platformio/platformio-core/issues/4056>`_)
|
- Fixed a "KeyError: Invalid board option 'build.cpu'" when using a precompiled library with a board that does not have a CPU field in the manifest (`issue #4056 <https://github.com/platformio/platformio-core/issues/4056>`_)
|
||||||
- Fixed a "FileExist" error when the `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ command is used in pair with the ``--keep-build-dir`` option (`issue #4011 <https://github.com/platformio/platformio-core/issues/4011>`_)
|
- Fixed a "FileExist" error when the `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ command is used in pair with the ``--keep-build-dir`` option (`issue #4011 <https://github.com/platformio/platformio-core/issues/4011>`_)
|
||||||
|
- Fixed an issue with draft values of C++ language standards that broke static analysis via Cppcheck (`issue #3944 <https://github.com/platformio/platformio-core/issues/3944>`_)
|
||||||
|
|
||||||
5.2.0 (2021-09-13)
|
5.2.0 (2021-09-13)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@@ -141,10 +141,11 @@ class CppcheckCheckTool(CheckToolBase):
|
|||||||
|
|
||||||
build_flags = self.cxx_flags if language == "c++" else self.cc_flags
|
build_flags = self.cxx_flags if language == "c++" else self.cc_flags
|
||||||
|
|
||||||
for flag in build_flags:
|
if not self.is_flag_set("--std", flags):
|
||||||
if "-std" in flag:
|
# Try to guess the standard version from the build flags
|
||||||
# Standards with GNU extensions are not allowed
|
for flag in build_flags:
|
||||||
cmd.append("-" + flag.replace("gnu", "c"))
|
if "-std" in flag:
|
||||||
|
cmd.append("-" + self.convert_language_standard(flag))
|
||||||
|
|
||||||
cmd.extend(
|
cmd.extend(
|
||||||
["-D%s" % d for d in self.cpp_defines + self.toolchain_defines[language]]
|
["-D%s" % d for d in self.cpp_defines + self.toolchain_defines[language]]
|
||||||
@@ -224,6 +225,21 @@ class CppcheckCheckTool(CheckToolBase):
|
|||||||
# Cppcheck is configured to return '3' if a defect is found
|
# Cppcheck is configured to return '3' if a defect is found
|
||||||
return cmd_result["returncode"] in (0, 3)
|
return cmd_result["returncode"] in (0, 3)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def convert_language_standard(flag):
|
||||||
|
cpp_standards_map = {
|
||||||
|
"0x": "11",
|
||||||
|
"1y": "14",
|
||||||
|
"1z": "17",
|
||||||
|
"2a": "20",
|
||||||
|
}
|
||||||
|
|
||||||
|
standard = flag[-2:]
|
||||||
|
# Note: GNU extensions are not supported and converted to regular standards
|
||||||
|
return flag.replace("gnu", "c").replace(
|
||||||
|
standard, cpp_standards_map.get(standard, standard)
|
||||||
|
)
|
||||||
|
|
||||||
def check(self, on_defect_callback=None):
|
def check(self, on_defect_callback=None):
|
||||||
self._on_defect_callback = on_defect_callback
|
self._on_defect_callback = on_defect_callback
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
# pylint: disable=redefined-outer-name
|
# pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -132,6 +131,47 @@ def test_check_language_standard_definition_passed(clirunner, tmpdir):
|
|||||||
assert "--std=c++17" in result.output
|
assert "--std=c++17" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_language_standard_option_is_converted(clirunner, tmpdir):
|
||||||
|
config = (
|
||||||
|
DEFAULT_CONFIG
|
||||||
|
+ """
|
||||||
|
build_flags = -std=gnu++1y
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
tmpdir.join("platformio.ini").write(config)
|
||||||
|
tmpdir.mkdir("src").join("main.cpp").write(TEST_CODE)
|
||||||
|
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir), "-v"])
|
||||||
|
|
||||||
|
assert "--std=c++14" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_language_standard_is_prioritized_over_build_flags(clirunner, tmpdir):
|
||||||
|
config = (
|
||||||
|
DEFAULT_CONFIG
|
||||||
|
+ """
|
||||||
|
check_flags = --std=c++03
|
||||||
|
build_flags = -std=c++17
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
tmpdir.join("platformio.ini").write(config)
|
||||||
|
tmpdir.mkdir("src").join("main.cpp").write(TEST_CODE)
|
||||||
|
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir), "-v"])
|
||||||
|
|
||||||
|
assert "--std=c++03" in result.output
|
||||||
|
assert "--std=c++17" not in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_language_standard_for_c_language(clirunner, tmpdir):
|
||||||
|
config = DEFAULT_CONFIG + "\nbuild_flags = -std=c11"
|
||||||
|
tmpdir.join("platformio.ini").write(config)
|
||||||
|
tmpdir.mkdir("src").join("main.c").write(TEST_CODE)
|
||||||
|
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir), "-v"])
|
||||||
|
|
||||||
|
assert "--std=c11" in result.output
|
||||||
|
assert "__STDC_VERSION__=201112L" in result.output
|
||||||
|
assert "__cplusplus" not in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_check_severity_threshold(clirunner, validate_cliresult, check_dir):
|
def test_check_severity_threshold(clirunner, validate_cliresult, check_dir):
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_check, ["--project-dir", str(check_dir), "--severity=high"]
|
cmd_check, ["--project-dir", str(check_dir), "--severity=high"]
|
||||||
@@ -451,12 +491,11 @@ int main() {
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
frameworks = ["arduino", "stm32cube"]
|
for framework in (
|
||||||
if sys.version_info[0] == 3:
|
"arduino",
|
||||||
# Zephyr only supports Python 3
|
"stm32cube",
|
||||||
frameworks.append("zephyr")
|
"zephyr",
|
||||||
|
):
|
||||||
for framework in frameworks:
|
|
||||||
for tool in ("cppcheck", "clangtidy", "pvs-studio"):
|
for tool in ("cppcheck", "clangtidy", "pvs-studio"):
|
||||||
tmpdir.join("platformio.ini").write(config % (framework, tool))
|
tmpdir.join("platformio.ini").write(config % (framework, tool))
|
||||||
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)])
|
result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)])
|
||||||
|
Reference in New Issue
Block a user