Skip to content

Commit 90a325a

Browse files
committed
Merge branch 'release/v5.1.0'
2 parents 3f3c8ca + fd54014 commit 90a325a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+884
-572
lines changed

.github/workflows/core.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
fail-fast: false
99
matrix:
1010
os: [ubuntu-latest, windows-latest, macos-latest]
11-
python-version: [2.7, 3.7, 3.8]
11+
python-version: [3.6, 3.7, 3.8, 3.9]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- uses: actions/checkout@v2

.github/workflows/examples.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
fail-fast: false
99
matrix:
1010
os: [ubuntu-16.04, windows-latest, macos-latest]
11-
python-version: [2.7, 3.7]
11+
python-version: [3.7]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- uses: actions/checkout@v2

.isort.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[settings]
22
line_length=88
3-
known_third_party=OpenSSL, SCons, autobahn, jsonrpc, twisted, zope
3+
known_third_party=OpenSSL, SCons, jsonrpc, twisted, zope

.pylintrc

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ disable=
1414
too-few-public-methods,
1515
useless-object-inheritance,
1616
useless-import-alias,
17-
fixme,
1817
bad-option-value,
1918

2019
; PY2 Compat

HISTORY.rst

+42-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,54 @@ PlatformIO Core 5
88

99
**A professional collaborative platform for embedded development**
1010

11+
5.1.0 (2021-01-28)
12+
~~~~~~~~~~~~~~~~~~
13+
14+
* **PlatformIO Home**
15+
16+
- Boosted PlatformIO Home performance thanks to migrating the codebase to the pure Python 3 Asynchronous I/O stack
17+
- Added a new ``--session-id`` option to `pio home <https://docs.platformio.org/page/core/userguide/cmd_home.html>`__ command that helps to keep PlatformIO Home isolated from other instances and protect from 3rd party access (`issue #3397 <https://github.com/platformio/platformio-core/issues/3397>`_)
18+
19+
* **Build System**
20+
21+
- Upgraded build engine to the SCons 4.1 (`release notes <https://scons.org/scons-410-is-available.html>`_)
22+
- Refactored a workaround for a maximum command line character limitation (`issue #3792 <https://github.com/platformio/platformio-core/issues/3792>`_)
23+
- Fixed an issue with Python 3.8+ on Windows when a network drive is used (`issue #3417 <https://github.com/platformio/platformio-core/issues/3417>`_)
24+
25+
* **Package Management**
26+
27+
- New options for `pio system prune <https://docs.platformio.org/page/core/userguide/system/cmd_prune.html>`__ command:
28+
29+
+ ``--dry-run`` option to show data that will be removed
30+
+ ``--core-packages`` option to remove unnecessary core packages
31+
+ ``--platform-packages`` option to remove unnecessary development platform packages (`issue #923 <https://github.com/platformio/platformio-core/issues/923>`_)
32+
33+
- Added new `check_prune_system_threshold <https://docs.platformio.org/page/core/userguide/cmd_settings.html#check-prune-system-threshold>`__ setting
34+
- Disabled automatic removal of unnecessary development platform packages (`issue #3708 <https://github.com/platformio/platformio-core/issues/3708>`_, `issue #3770 <https://github.com/platformio/platformio-core/issues/3770>`_)
35+
- Fixed an issue when unnecessary packages were removed in ``update --dry-run`` mode (`issue #3809 <https://github.com/platformio/platformio-core/issues/3809>`_)
36+
- Fixed a "ValueError: Invalid simple block" when uninstalling a package with a custom name and external source (`issue #3816 <https://github.com/platformio/platformio-core/issues/3816>`_)
37+
38+
* **Debugging**
39+
40+
- Configure a custom debug adapter speed using a new `debug_speed <https://docs.platformio.org/page/projectconf/section_env_debug.html#debug-speed>`__ option (`issue #3799 <https://github.com/platformio/platformio-core/issues/3799>`_)
41+
- Handle debugging server's "ready_pattern" in "stderr" output
42+
43+
* **Miscellaneous**
44+
45+
- Improved listing of `multicast DNS services <https://docs.platformio.org/page/core/userguide/device/cmd_list.html>`_
46+
- Fixed a "UnicodeDecodeError: 'utf-8' codec can't decode byte" when using J-Link for firmware uploading on Linux (`issue #3804 <https://github.com/platformio/platformio-core/issues/3804>`_)
47+
- Fixed an issue with a compiler driver for ".ccls" language server (`issue #3808 <https://github.com/platformio/platformio-core/issues/3808>`_)
48+
- Fixed an issue when `pio device monitor --eol <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#cmdoption-pio-device-monitor-eol>`__ and "send_on_enter" filter do not work properly (`issue #3787 <https://github.com/platformio/platformio-core/issues/3787>`_)
49+
1150
5.0.4 (2020-12-30)
1251
~~~~~~~~~~~~~~~~~~
1352

1453
- Added "Core" suffix when showing PlatformIO Core version using ``pio --version`` command
15-
- Improved ``.ccls`` configuration file for Emacs, Vim, and Sublime Text integrations
54+
- Improved ".ccls" configuration file for Emacs, Vim, and Sublime Text integrations
1655
- Updated analysis tools:
1756

18-
* `Cppcheck <https://docs.platformio.org/page/plus/check-tools/cppcheck.html>`__ v2.3 with improved C++ parser and several new MISRA rules
19-
* `PVS-Studio <https://docs.platformio.org/page/plus/check-tools/pvs-studio.html>`__ v7.11 with new diagnostics and updated mass suppression mechanism
57+
* `Cppcheck <https://docs.platformio.org/page/plus/check-tools/cppcheck.html>`__ v2.3 with improved C++ parser and several new MISRA rules
58+
* `PVS-Studio <https://docs.platformio.org/page/plus/check-tools/pvs-studio.html>`__ v7.11 with new diagnostics and updated mass suppression mechanism
2059

2160
- Show a warning message about deprecated support for Python 2 and Python 3.5
2261
- Do not provide "intelliSenseMode" option when generating configuration for VSCode C/C++ extension

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ lint:
33
pylint -j 6 --rcfile=./.pylintrc ./tests
44

55
isort:
6-
isort -rc ./platformio
7-
isort -rc ./tests
6+
isort ./platformio
7+
isort ./tests
88

99
format:
1010
black --target-version py27 ./platformio

docs

Submodule docs updated 47 files

platformio/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import sys
1616

17-
VERSION = (5, 0, 4)
17+
VERSION = (5, 1, 0)
1818
__version__ = ".".join([str(s) for s in VERSION])
1919

2020
__title__ = "platformio"
@@ -47,10 +47,10 @@
4747
__default_requests_timeout__ = (10, None) # (connect, read)
4848

4949
__core_packages__ = {
50-
"contrib-piohome": "~3.3.1",
50+
"contrib-piohome": "~3.3.3",
5151
"contrib-pysite": "~2.%d%d.0" % (sys.version_info.major, sys.version_info.minor),
5252
"tool-unity": "~1.20500.0",
53-
"tool-scons": "~2.20501.7" if sys.version_info.major == 2 else "~4.40001.0",
53+
"tool-scons": "~2.20501.7" if sys.version_info.major == 2 else "~4.40100.2",
5454
"tool-cppcheck": "~1.230.0",
5555
"tool-clangtidy": "~1.100000.0",
5656
"tool-pvs-studio": "~7.11.0",

platformio/app.py

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def projects_dir_validate(projects_dir):
5555
"description": "Check for the platform updates interval (days)",
5656
"value": 7,
5757
},
58+
"check_prune_system_threshold": {
59+
"description": "Check for pruning unnecessary data threshold (megabytes)",
60+
"value": 1024,
61+
},
5862
"enable_cache": {
5963
"description": "Enable caching for HTTP API requests",
6064
"value": True,

platformio/builder/main.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,19 @@
8181
IDE_EXTRA_DATA={},
8282
)
8383

84+
# Declare command verbose messages
85+
command_strings = dict(
86+
ARCOM="Archiving",
87+
LINKCOM="Linking",
88+
RANLIBCOM="Indexing",
89+
ASCOM="Compiling",
90+
ASPPCOM="Compiling",
91+
CCCOM="Compiling",
92+
CXXCOM="Compiling",
93+
)
8494
if not int(ARGUMENTS.get("PIOVERBOSE", 0)):
85-
DEFAULT_ENV_OPTIONS["ARCOMSTR"] = "Archiving $TARGET"
86-
DEFAULT_ENV_OPTIONS["LINKCOMSTR"] = "Linking $TARGET"
87-
DEFAULT_ENV_OPTIONS["RANLIBCOMSTR"] = "Indexing $TARGET"
88-
for k in ("ASCOMSTR", "ASPPCOMSTR", "CCCOMSTR", "CXXCOMSTR"):
89-
DEFAULT_ENV_OPTIONS[k] = "Compiling $TARGET"
95+
for name, value in command_strings.items():
96+
DEFAULT_ENV_OPTIONS["%sSTR" % name] = "%s $TARGET" % (value)
9097

9198
env = DefaultEnvironment(**DEFAULT_ENV_OPTIONS)
9299

platformio/builder/tools/compilation_db.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# should hold the compilation database, otherwise, the file defaults to compile_commands.json,
4242
# which is the name that most clang tools search for by default.
4343

44-
# TODO: Is there a better way to do this than this global? Right now this exists so that the
44+
# Is there a better way to do this than this global? Right now this exists so that the
4545
# emitter we add can record all of the things it emits, so that the scanner for the top level
4646
# compilation database can access the complete list, and also so that the writer has easy
4747
# access to write all of the files. But it seems clunky. How can the emitter and the scanner
@@ -104,7 +104,7 @@ def EmitCompilationDbEntry(target, source, env):
104104
__COMPILATIONDB_ENV=env,
105105
)
106106

107-
# TODO: Technically, these next two lines should not be required: it should be fine to
107+
# Technically, these next two lines should not be required: it should be fine to
108108
# cache the entries. However, they don't seem to update properly. Since they are quick
109109
# to re-generate disable caching and sidestep this problem.
110110
env.AlwaysBuild(entry)

platformio/builder/tools/pioide.py

+24-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import os
1818
from glob import glob
1919

20-
from SCons.Defaults import processDefines # pylint: disable=import-error
20+
import SCons.Defaults # pylint: disable=import-error
21+
import SCons.Subst # pylint: disable=import-error
2122

2223
from platformio.compat import glob_escape
2324
from platformio.package.manager.core import get_core_package_dir
@@ -58,8 +59,16 @@ def _dump_includes(env):
5859
for g in toolchain_incglobs:
5960
includes["toolchain"].extend([os.path.realpath(inc) for inc in glob(g)])
6061

62+
# include Unity framework if there are tests in project
6163
includes["unity"] = []
62-
unity_dir = get_core_package_dir("tool-unity")
64+
auto_install_unity = False
65+
test_dir = env.GetProjectConfig().get_optional_dir("test")
66+
if os.path.isdir(test_dir) and os.listdir(test_dir) != ["README"]:
67+
auto_install_unity = True
68+
unity_dir = get_core_package_dir(
69+
"tool-unity",
70+
auto_install=auto_install_unity,
71+
)
6372
if unity_dir:
6473
includes["unity"].append(unity_dir)
6574

@@ -92,7 +101,7 @@ def _get_gcc_defines(env):
92101
def _dump_defines(env):
93102
defines = []
94103
# global symbols
95-
for item in processDefines(env.get("CPPDEFINES", [])):
104+
for item in SCons.Defaults.processDefines(env.get("CPPDEFINES", [])):
96105
item = item.strip()
97106
if item:
98107
defines.append(env.subst(item).replace("\\", ""))
@@ -141,25 +150,17 @@ def _get_svd_path(env):
141150
return None
142151

143152

144-
def _escape_build_flag(flags):
145-
return [flag if " " not in flag else '"%s"' % flag for flag in flags]
153+
def _subst_cmd(env, cmd):
154+
args = env.subst_list(cmd, SCons.Subst.SUBST_CMD)[0]
155+
return " ".join([SCons.Subst.quote_spaces(arg) for arg in args])
146156

147157

148158
def DumpIDEData(env, globalenv):
149159
""" env here is `projenv`"""
150160

151-
env["__escape_build_flag"] = _escape_build_flag
152-
153-
LINTCCOM = (
154-
"${__escape_build_flag(CFLAGS)} ${__escape_build_flag(CCFLAGS)} $CPPFLAGS"
155-
)
156-
LINTCXXCOM = (
157-
"${__escape_build_flag(CXXFLAGS)} ${__escape_build_flag(CCFLAGS)} $CPPFLAGS"
158-
)
159-
160161
data = {
161162
"env_name": env["PIOENV"],
162-
"libsource_dirs": [env.subst(l) for l in env.GetLibSourceDirs()],
163+
"libsource_dirs": [env.subst(item) for item in env.GetLibSourceDirs()],
163164
"defines": _dump_defines(env),
164165
"includes": _dump_includes(env),
165166
"cc_path": where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
@@ -181,15 +182,21 @@ def DumpIDEData(env, globalenv):
181182
env_ = env.Clone()
182183
# https://github.com/platformio/platformio-atom-ide/issues/34
183184
_new_defines = []
184-
for item in processDefines(env_.get("CPPDEFINES", [])):
185+
for item in SCons.Defaults.processDefines(env_.get("CPPDEFINES", [])):
185186
item = item.replace('\\"', '"')
186187
if " " in item:
187188
_new_defines.append(item.replace(" ", "\\\\ "))
188189
else:
189190
_new_defines.append(item)
190191
env_.Replace(CPPDEFINES=_new_defines)
191192

192-
data.update({"cc_flags": env_.subst(LINTCCOM), "cxx_flags": env_.subst(LINTCXXCOM)})
193+
# export C/C++ build flags
194+
data.update(
195+
{
196+
"cc_flags": _subst_cmd(env_, "$CFLAGS $CCFLAGS $CPPFLAGS"),
197+
"cxx_flags": _subst_cmd(env_, "$CXXFLAGS $CCFLAGS $CPPFLAGS"),
198+
}
199+
)
193200

194201
return data
195202

platformio/builder/tools/piomaxlen.py

+42-39
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,30 @@
1414

1515
from __future__ import absolute_import
1616

17-
from hashlib import md5
18-
from os import makedirs
19-
from os.path import isdir, isfile, join
17+
import hashlib
18+
import os
19+
import re
20+
21+
from SCons.Platform import TempFileMunge # pylint: disable=import-error
22+
from SCons.Subst import quote_spaces # pylint: disable=import-error
2023

2124
from platformio.compat import WINDOWS, hashlib_encode_data
2225

23-
# Windows CLI has limit with command length to 8192
24-
# Leave 2000 chars for flags and other options
25-
MAX_LINE_LENGTH = 6000 if WINDOWS else 128072
26+
# There are the next limits depending on a platform:
27+
# - Windows = 8192
28+
# - Unix = 131072
29+
# We need ~256 characters for a temporary file path
30+
MAX_LINE_LENGTH = (8192 if WINDOWS else 131072) - 256
31+
32+
WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)")
33+
34+
35+
def tempfile_arg_esc_func(arg):
36+
arg = quote_spaces(arg)
37+
if not WINDOWS:
38+
return arg
39+
# GCC requires double Windows slashes, let's use UNIX separator
40+
return WINPATHSEP_RE.sub(r"/\1", arg)
2641

2742

2843
def long_sources_hook(env, sources):
@@ -41,30 +56,14 @@ def long_sources_hook(env, sources):
4156
return '@"%s"' % _file_long_data(env, " ".join(data))
4257

4358

44-
def long_incflags_hook(env, incflags):
45-
_incflags = env.subst(incflags).replace("\\", "/")
46-
if len(_incflags) < MAX_LINE_LENGTH:
47-
return incflags
48-
49-
# fix space in paths
50-
data = []
51-
for line in _incflags.split(" -I"):
52-
line = line.strip()
53-
if not line.startswith("-I"):
54-
line = "-I" + line
55-
data.append('-I"%s"' % line[2:])
56-
57-
return '@"%s"' % _file_long_data(env, " ".join(data))
58-
59-
6059
def _file_long_data(env, data):
6160
build_dir = env.subst("$BUILD_DIR")
62-
if not isdir(build_dir):
63-
makedirs(build_dir)
64-
tmp_file = join(
65-
build_dir, "longcmd-%s" % md5(hashlib_encode_data(data)).hexdigest()
61+
if not os.path.isdir(build_dir):
62+
os.makedirs(build_dir)
63+
tmp_file = os.path.join(
64+
build_dir, "longcmd-%s" % hashlib.md5(hashlib_encode_data(data)).hexdigest()
6665
)
67-
if isfile(tmp_file):
66+
if os.path.isfile(tmp_file):
6867
return tmp_file
6968
with open(tmp_file, "w") as fp:
7069
fp.write(data)
@@ -76,17 +75,21 @@ def exists(_):
7675

7776

7877
def generate(env):
79-
env.Replace(_long_sources_hook=long_sources_hook)
80-
env.Replace(_long_incflags_hook=long_incflags_hook)
81-
coms = {}
82-
for key in ("ARCOM", "LINKCOM"):
83-
coms[key] = env.get(key, "").replace(
84-
"$SOURCES", "${_long_sources_hook(__env__, SOURCES)}"
85-
)
86-
for key in ("_CCCOMCOM", "ASPPCOM"):
87-
coms[key] = env.get(key, "").replace(
88-
"$_CPPINCFLAGS", "${_long_incflags_hook(__env__, _CPPINCFLAGS)}"
89-
)
90-
env.Replace(**coms)
78+
kwargs = dict(
79+
_long_sources_hook=long_sources_hook,
80+
TEMPFILE=TempFileMunge,
81+
MAXLINELENGTH=MAX_LINE_LENGTH,
82+
TEMPFILEARGESCFUNC=tempfile_arg_esc_func,
83+
TEMPFILESUFFIX=".tmp",
84+
TEMPFILEDIR="$BUILD_DIR",
85+
)
86+
87+
for name in ("LINKCOM", "ASCOM", "ASPPCOM", "CCCOM", "CXXCOM"):
88+
kwargs[name] = "${TEMPFILE('%s','$%sSTR')}" % (env.get(name), name)
89+
90+
kwargs["ARCOM"] = env.get("ARCOM", "").replace(
91+
"$SOURCES", "${_long_sources_hook(__env__, SOURCES)}"
92+
)
93+
env.Replace(**kwargs)
9194

9295
return env

platformio/commands/debug/helpers.py

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def _cleanup_cmds(items):
176176
tool_name,
177177
tool_settings,
178178
),
179+
speed=env_options.get("debug_speed", tool_settings.get("speed")),
179180
server=server_options,
180181
)
181182
return result

0 commit comments

Comments
 (0)