Merge branch 'release/v6.1.2'

This commit is contained in:
Ivan Kravets
2022-07-18 17:26:24 +03:00
12 changed files with 66 additions and 25 deletions

View File

@ -13,6 +13,15 @@ PlatformIO Core 6
**A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.**
6.1.2 (2022-07-18)
~~~~~~~~~~~~~~~~~~
* Export a ``PIO_UNIT_TESTING`` macro to the project source files and dependent libraries in the |UNITTESTING| mode
* Improved detection of Windows architecture (`issue #4353 <https://github.com/platformio/platformio-core/issues/4353>`_)
* Warn about unknown `device monitor filters <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#filters>`__ (`issue #4362 <https://github.com/platformio/platformio-core/issues/4362>`_)
* Fixed a regression bug when `libArchive <https://docs.platformio.org/en/latest/manifests/library-json/fields/build/libarchive.html>`__ option declared in the `library.json <https://docs.platformio.org/en/latest/manifests/library-json/index.html>`__ manifest was ignored (`issue #4351 <https://github.com/platformio/platformio-core/issues/4351>`_)
* Fixed an issue when the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command didn't work with Python 3.6 (`issue #4352 <https://github.com/platformio/platformio-core/issues/4352>`_)
6.1.1 (2022-07-11) 6.1.1 (2022-07-11)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

2
docs

Submodule docs updated: f4accb77c8...0a58185b4a

View File

@ -14,7 +14,7 @@
import sys import sys
VERSION = (6, 1, 1) VERSION = (6, 1, 2)
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -30,7 +30,7 @@ from SCons.Script import DefaultEnvironment # pylint: disable=import-error
from platformio import exception, fs from platformio import exception, fs
from platformio.builder.tools import platformio as piotool from platformio.builder.tools import platformio as piotool
from platformio.compat import IS_WINDOWS, MISSING, hashlib_encode_data, string_types from platformio.compat import IS_WINDOWS, hashlib_encode_data, string_types
from platformio.http import HTTPClientError, InternetIsOffline from platformio.http import HTTPClientError, InternetIsOffline
from platformio.package.exception import ( from platformio.package.exception import (
MissingPackageManifestError, MissingPackageManifestError,
@ -145,6 +145,10 @@ class LibBuilderBase:
self._circular_deps = [] self._circular_deps = []
self._processed_search_files = [] self._processed_search_files = []
# pass a macro to the projenv + libs
if "test" in env.GetBuildType():
self.env.Append(CPPDEFINES=["PIO_UNIT_TESTING"])
# reset source filter, could be overridden with extra script # reset source filter, could be overridden with extra script
self.env["SRC_FILTER"] = "" self.env["SRC_FILTER"] = ""
@ -576,10 +580,11 @@ class ArduinoLibBuilder(LibBuilderBase):
# pylint: disable=no-member # pylint: disable=no-member
if not self._manifest.get("dependencies"): if not self._manifest.get("dependencies"):
return LibBuilderBase.lib_ldf_mode.fget(self) return LibBuilderBase.lib_ldf_mode.fget(self)
missing = object()
global_value = self.env.GetProjectConfig().getraw( global_value = self.env.GetProjectConfig().getraw(
"env:" + self.env["PIOENV"], "lib_ldf_mode", MISSING "env:" + self.env["PIOENV"], "lib_ldf_mode", missing
) )
if global_value != MISSING: if global_value != missing:
return LibBuilderBase.lib_ldf_mode.fget(self) return LibBuilderBase.lib_ldf_mode.fget(self)
# automatically enable C++ Preprocessing in runtime # automatically enable C++ Preprocessing in runtime
# (Arduino IDE has this behavior) # (Arduino IDE has this behavior)
@ -831,10 +836,11 @@ class PlatformIOLibBuilder(LibBuilderBase):
@property @property
def lib_archive(self): def lib_archive(self):
missing = object()
global_value = self.env.GetProjectConfig().getraw( global_value = self.env.GetProjectConfig().getraw(
"env:" + self.env["PIOENV"], "lib_archive", MISSING "env:" + self.env["PIOENV"], "lib_archive", missing
) )
if global_value != MISSING: if global_value != missing:
return self.env.GetProjectConfig().get( return self.env.GetProjectConfig().get(
"env:" + self.env["PIOENV"], "lib_archive" "env:" + self.env["PIOENV"], "lib_archive"
) )

View File

@ -23,7 +23,7 @@ from platformio.test.runners.factory import TestRunnerFactory
def ConfigureTestTarget(env): def ConfigureTestTarget(env):
env.Append( env.Append(
CPPDEFINES=["UNIT_TEST", "PIO_UNIT_TESTING"], CPPDEFINES=["UNIT_TEST"], # deprecated, use PIO_UNIT_TESTING
PIOTEST_SRC_FILTER=[f"+<*.{ext}>" for ext in piotool.SRC_BUILD_EXT], PIOTEST_SRC_FILTER=[f"+<*.{ext}>" for ext in piotool.SRC_BUILD_EXT],
) )
env.Prepend(CPPPATH=["$PROJECT_TEST_DIR"]) env.Prepend(CPPPATH=["$PROJECT_TEST_DIR"])

View File

@ -41,6 +41,15 @@ def is_bytes(x):
return isinstance(x, (bytes, memoryview, bytearray)) return isinstance(x, (bytes, memoryview, bytearray))
def isascii(text):
if sys.version_info >= (3, 7):
return text.isascii()
for c in text or "":
if ord(c) > 127:
return False
return True
def ci_strings_are_equal(a, b): def ci_strings_are_equal(a, b):
if a == b: if a == b:
return True return True

View File

@ -16,7 +16,7 @@ import json
import os import os
from platformio import fs, proc, util from platformio import fs, proc, util
from platformio.compat import MISSING, string_types from platformio.compat import string_types
from platformio.debug.exception import DebugInvalidOptionsError from platformio.debug.exception import DebugInvalidOptionsError
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
from platformio.project.helpers import load_build_metadata from platformio.project.helpers import load_build_metadata
@ -96,8 +96,9 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes
@property @property
def init_break(self): def init_break(self):
result = self.env_options.get("debug_init_break", MISSING) missed = object()
if result != MISSING: result = self.env_options.get("debug_init_break", missed)
if result != missed:
return result return result
result = None result = None
if not result: if not result:

View File

@ -20,7 +20,7 @@ import click
from platformio import exception, fs from platformio import exception, fs
from platformio.device.finder import find_serial_port from platformio.device.finder import find_serial_port
from platformio.device.monitor.filters.base import register_filters from platformio.device.monitor.filters.base import register_filters
from platformio.device.monitor.terminal import start_terminal from platformio.device.monitor.terminal import get_available_filters, start_terminal
from platformio.platform.factory import PlatformFactory from platformio.platform.factory import PlatformFactory
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
from platformio.project.exception import NotPlatformIOProjectError from platformio.project.exception import NotPlatformIOProjectError
@ -138,6 +138,17 @@ def device_monitor_cmd(**options):
"--exit-char can not be the same as --menu-char" "--exit-char can not be the same as --menu-char"
) )
# check for unknown filters
known_filters = set(get_available_filters())
unknown_filters = set(options["filters"]) - known_filters
if unknown_filters:
options["filters"] = list(known_filters & set(options["filters"]))
click.secho(
("Warning! Skipping unknown filters `%s`. Known filters are `%s`")
% (", ".join(unknown_filters), ", ".join(sorted(known_filters))),
fg="yellow",
)
start_terminal(options) start_terminal(options)

View File

@ -41,6 +41,10 @@ class Terminal(miniterm.Miniterm):
self.pio_unexpected_exception = exc self.pio_unexpected_exception = exc
def get_available_filters():
return sorted(miniterm.TRANSFORMATIONS.keys())
def start_terminal(options): def start_terminal(options):
retries = 0 retries = 0
is_port_valid = False is_port_valid = False
@ -116,7 +120,7 @@ def print_terminal_settings(terminal):
) )
click.echo( click.echo(
"--- Available filters and text transformations: %s" "--- Available filters and text transformations: %s"
% ", ".join(sorted(miniterm.TRANSFORMATIONS.keys())) % ", ".join(get_available_filters())
) )
click.echo("--- More details at https://bit.ly/pio-monitor-filters") click.echo("--- More details at https://bit.ly/pio-monitor-filters")
click.echo( click.echo(

View File

@ -13,7 +13,6 @@
# limitations under the License. # limitations under the License.
import json import json
import math
import os import os
import socket import socket
from urllib.parse import urljoin from urllib.parse import urljoin
@ -63,9 +62,10 @@ class EndpointSessionIterator:
endpoints = [endpoints] endpoints = [endpoints]
self.endpoints = endpoints self.endpoints = endpoints
self.endpoints_iter = iter(endpoints) self.endpoints_iter = iter(endpoints)
# https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html
self.retry = Retry( self.retry = Retry(
total=math.ceil(6 / len(self.endpoints)), total=5,
backoff_factor=1, backoff_factor=1, # [0, 2, 4, 8, 16] secs
# method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"], # method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"],
status_forcelist=[413, 429, 500, 502, 503, 504], status_forcelist=[413, 429, 500, 502, 503, 504],
) )
@ -129,10 +129,7 @@ class HTTPClient:
while True: while True:
try: try:
return getattr(self._session, method)(path, **kwargs) return getattr(self._session, method)(path, **kwargs)
except ( except requests.exceptions.RequestException as exc:
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
) as exc:
try: try:
self._next_session() self._next_session()
except Exception as exc2: except Exception as exc2:

View File

@ -22,6 +22,7 @@ from tabulate import tabulate
from platformio import fs from platformio import fs
from platformio.account.client import AccountClient from platformio.account.client import AccountClient
from platformio.compat import isascii
from platformio.exception import UserSideException from platformio.exception import UserSideException
from platformio.package.manifest.parser import ManifestParserFactory from platformio.package.manifest.parser import ManifestParserFactory
from platformio.package.manifest.schema import ManifestSchema from platformio.package.manifest.schema import ManifestSchema
@ -155,7 +156,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals
def check_archive_file_names(archive_path): def check_archive_file_names(archive_path):
with tarfile.open(archive_path, mode="r:gz") as tf: with tarfile.open(archive_path, mode="r:gz") as tf:
for name in tf.getnames(): for name in tf.getnames():
if not name.isascii(): if not isascii(name) or not name.isprintable():
click.secho( click.secho(
f"Warning! The `{name}` file contains non-ASCII chars and can " f"Warning! The `{name}` file contains non-ASCII chars and can "
"lead to the unpacking issues on a user machine", "lead to the unpacking issues on a user machine",

View File

@ -139,11 +139,14 @@ def singleton(cls):
def get_systype(): def get_systype():
type_ = platform.system().lower() system = platform.system().lower()
arch = platform.machine().lower() arch = platform.machine().lower()
if type_ == "windows" and "x86" in arch: if system == "windows":
arch = "amd64" if "64" in arch else "x86" if not arch: # issue #4353
return "%s_%s" % (type_, arch) if arch else type_ arch = "x86_" + platform.architecture()[0]
if "x86" in arch:
arch = "amd64" if "64" in arch else "x86"
return "%s_%s" % (system, arch) if arch else system
def pioversion_to_intstr(): def pioversion_to_intstr():