From b87048020d8d1a8f1bf83c41d551eb5cc4bedb9a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 12 Feb 2020 21:08:08 +0200 Subject: [PATCH 01/18] Add warning that overriding board data will not work for device monitor command // Issue #3349 --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index dc25f117fd..af3b3c424a 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit dc25f117fd3b3acceed43ebae225e5b4a9f20105 +Subproject commit af3b3c424a2c10fc0f6ab37eacec3ba6cbafc11c From 206054b35f17f84ae7d6d2b29730c217be087804 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 12 Feb 2020 23:58:39 +0200 Subject: [PATCH 02/18] Docs: Sync dev-platforms --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index af3b3c424a..7fffc7853e 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit af3b3c424a2c10fc0f6ab37eacec3ba6cbafc11c +Subproject commit 7fffc7853ec1d2bdd3dd68cab015e0360d4b0afd From 36a222822019b243ec254ab19b8b4e83462b90d3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 13 Feb 2020 13:34:34 +0200 Subject: [PATCH 03/18] Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser // Resolve #3377 --- HISTORY.rst | 28 +++++++++++++++++----------- platformio/project/config.py | 4 +++- tests/test_projectconf.py | 4 ++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e142359986..a36f0409e7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,10 +1,16 @@ Release Notes ============= -.. _release_notes_4_0: +.. _release_notes_4: + +PlatformIO Core 4 +----------------- + +4.2.1 (2020-02-??) +~~~~~~~~~~~~~~~~~~ + +* Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) -PlatformIO Core 4.0 -------------------- 4.2.0 (2020-02-12) ~~~~~~~~~~~~~~~~~~ @@ -182,8 +188,8 @@ PlatformIO Core 4.0 - Fixed "systemd-udevd" warnings in `99-platformio-udev.rules `__ (`issue #2442 `_) - Fixed an issue when package cache (Library Manager) expires too fast (`issue #2559 `_) -PlatformIO Core 3.0 -------------------- +PlatformIO Core 3 +----------------- 3.6.7 (2019-04-23) ~~~~~~~~~~~~~~~~~~ @@ -783,8 +789,8 @@ PlatformIO Core 3.0 (`issue #742 `_) * Stopped supporting Python 2.6 -PlatformIO Core 2.0 --------------------- +PlatformIO Core 2 +----------------- 2.11.2 (2016-08-02) ~~~~~~~~~~~~~~~~~~~ @@ -1569,8 +1575,8 @@ PlatformIO Core 2.0 * Fixed bug with creating copies of source files (`issue #177 `_) -PlatformIO Core 1.0 -------------------- +PlatformIO Core 1 +----------------- 1.5.0 (2015-05-15) ~~~~~~~~~~~~~~~~~~ @@ -1760,8 +1766,8 @@ PlatformIO Core 1.0 error (`issue #81 `_) * Several bug fixes, increased stability and performance improvements -PlatformIO Core 0.0 -------------------- +PlatformIO Core Preview +----------------------- 0.10.2 (2015-01-06) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/config.py b/platformio/project/config.py index 2e063fac05..4dc3c38c26 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -273,7 +273,9 @@ def getraw( # pylint: disable=too-many-branches if envvar_value: break if envvar_value and option_meta.multiple: - value += ("" if value == MISSING else "\n") + envvar_value + if value == MISSING: + value = "" + value += ("\n" if value else "") + envvar_value elif envvar_value and value == MISSING: value = envvar_value diff --git a/tests/test_projectconf.py b/tests/test_projectconf.py index 447318753a..8172e69225 100644 --- a/tests/test_projectconf.py +++ b/tests/test_projectconf.py @@ -185,6 +185,7 @@ def test_sysenv_options(config): assert config.get("env:base", "upload_port") is None assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port" os.environ["PLATFORMIO_BUILD_FLAGS"] = "-DSYSENVDEPS1 -DSYSENVDEPS2" + os.environ["PLATFORMIO_BUILD_UNFLAGS"] = "-DREMOVE_MACRO" os.environ["PLATFORMIO_UPLOAD_PORT"] = "/dev/sysenv/port" os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"] = "-L /usr/local/lib" assert config.get("custom", "extra_flags") == "-L /usr/local/lib" @@ -194,6 +195,7 @@ def test_sysenv_options(config): ] assert config.get("env:base", "upload_port") == "/dev/sysenv/port" assert config.get("env:extra_2", "upload_port") == "/dev/extra_2/port" + assert config.get("env:base", "build_unflags") == ["-DREMOVE_MACRO"] # env var as option assert config.options(env="test_extends") == [ @@ -206,6 +208,7 @@ def test_sysenv_options(config): "lib_deps", "lib_ignore", "custom_builtin_option", + "build_unflags", "upload_port", ] @@ -215,6 +218,7 @@ def test_sysenv_options(config): # cleanup system environment variables del os.environ["PLATFORMIO_BUILD_FLAGS"] + del os.environ["PLATFORMIO_BUILD_UNFLAGS"] del os.environ["PLATFORMIO_UPLOAD_PORT"] del os.environ["__PIO_TEST_CNF_EXTRA_FLAGS"] del os.environ["PLATFORMIO_HOME_DIR"] From 42020e24980663a2ff6aa7ae252569ab0ccd44d1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 13 Feb 2020 13:35:38 +0200 Subject: [PATCH 04/18] Bump version to 4.2.1a1 --- docs | 2 +- platformio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 7fffc7853e..6dd2fec114 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 7fffc7853ec1d2bdd3dd68cab015e0360d4b0afd +Subproject commit 6dd2fec1141b104dc4867b746d9335263cdf209e diff --git a/platformio/__init__.py b/platformio/__init__.py index 208873da9a..ef86e1f2b5 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (4, 2, 0) +VERSION = (4, 2, "1a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From a10625a0529d57c3fc385898e362b4239669b2d6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 13 Feb 2020 15:53:42 +0200 Subject: [PATCH 05/18] Automatically rebuild contrib-pysite package when import fails // Issue #3313 --- docs | 2 +- platformio/commands/home/command.py | 14 +++++- platformio/managers/core.py | 78 ++++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/docs b/docs index 6dd2fec114..3a399f127b 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 6dd2fec1141b104dc4867b746d9335263cdf209e +Subproject commit 3a399f127b6e16c75e47ff06d90f2aace7a5f94b diff --git a/platformio/commands/home/command.py b/platformio/commands/home/command.py index c5d5dc147f..82844b7ab0 100644 --- a/platformio/commands/home/command.py +++ b/platformio/commands/home/command.py @@ -22,7 +22,11 @@ from platformio import exception from platformio.compat import WINDOWS -from platformio.managers.core import get_core_package_dir, inject_contrib_pysite +from platformio.managers.core import ( + build_contrib_pysite_deps, + get_core_package_dir, + inject_contrib_pysite, +) @click.command("home", short_help="PIO Home") @@ -50,7 +54,13 @@ def cli(port, host, no_open, shutdown_timeout): # import contrib modules inject_contrib_pysite() - from autobahn.twisted.resource import WebSocketResource + + try: + from autobahn.twisted.resource import WebSocketResource + except (ImportError, ModuleNotFoundError): + build_contrib_pysite_deps(get_core_package_dir("contrib-pysite")) + from autobahn.twisted.resource import WebSocketResource + from twisted.internet import reactor from twisted.web import server diff --git a/platformio/managers/core.py b/platformio/managers/core.py index c7203eca2d..55a0ece423 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import os import subprocess import sys from os.path import dirname, join -from platformio import __version__, exception, fs +from platformio import __version__, exception, fs, util from platformio.compat import PY2, WINDOWS from platformio.managers.package import PackageManager from platformio.proc import copy_pythonpath_to_osenv, get_pythonexe_path @@ -25,7 +26,7 @@ CORE_PACKAGES = { "contrib-piohome": "~3.1.0", - "contrib-pysite": "~2.%d%d.0" % (sys.version_info[0], sys.version_info[1]), + "contrib-pysite": "~2.%d%d.0" % (sys.version_info.major, sys.version_info.minor), "tool-pioplus": "^2.6.1", "tool-unity": "~1.20500.0", "tool-scons": "~2.20501.7" if PY2 else "~3.30102.0", @@ -113,6 +114,79 @@ def inject_contrib_pysite(): sys.path.insert(0, contrib_pysite_dir) +def build_contrib_pysite_deps(target_dir): + if os.path.isdir(target_dir): + util.rmtree_(target_dir) + os.makedirs(target_dir) + with open(os.path.join(target_dir, "package.json"), "w") as fp: + json.dump( + dict( + name="contrib-pysite", + version="2.%d%d.0" % (sys.version_info.major, sys.version_info.minor), + system=util.get_systype(), + ), + fp, + ) + + pythonexe = get_pythonexe_path() + for dep in get_contrib_pysite_deps(): + subprocess.call( + [ + pythonexe, + "-m", + "pip", + "install", + "--no-cache-dir", + "--no-compile", + "-t", + target_dir, + dep, + ] + ) + return True + + +def get_contrib_pysite_deps(): + sys_type = util.get_systype() + py_version = "%d%d" % (sys.version_info.major, sys.version_info.minor) + + twisted_version = "19.7.0" + result = [ + "twisted == %s" % twisted_version, + "autobahn == 19.10.1", + "json-rpc == 1.12.1", + ] + + # twisted[tls], see setup.py for %twisted_version% + result.extend( + ["pyopenssl >= 16.0.0", "service_identity >= 18.1.0", "idna >= 0.6, != 2.3"] + ) + + # zeroconf + if sys.version_info.major < 3: + result.append( + "https://github.com/ivankravets/python-zeroconf/" "archive/pio-py27.zip" + ) + else: + result.append("zeroconf == 0.23.0") + + if "windows" in sys_type: + result.append("pypiwin32 == 223") + # workaround for twisted wheels + twisted_wheel = ( + "https://download.lfd.uci.edu/pythonlibs/g5apjq5m/Twisted-" + "%s-cp%s-cp%sm-win%s.whl" + % ( + twisted_version, + py_version, + py_version, + "_amd64" if "amd64" in sys_type else "32", + ) + ) + result[0] = twisted_wheel + return result + + def pioplus_call(args, **kwargs): if WINDOWS and sys.version_info < (2, 7, 6): raise exception.PlatformioException( From 22e8e02f3d963efaeffa7d65a371a94d13e34404 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 13 Feb 2020 22:06:46 +0200 Subject: [PATCH 06/18] Automatically rebuild contrib-pysite package when import fails // Resolve #3313 --- HISTORY.rst | 1 + platformio/commands/home/command.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index a36f0409e7..0df431e277 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,6 +9,7 @@ PlatformIO Core 4 4.2.1 (2020-02-??) ~~~~~~~~~~~~~~~~~~ +* Improved support of PIO Home on card-sized PC (Raspberry Pi, etc.) (`issue #3313 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) diff --git a/platformio/commands/home/command.py b/platformio/commands/home/command.py index 82844b7ab0..208354bf65 100644 --- a/platformio/commands/home/command.py +++ b/platformio/commands/home/command.py @@ -57,7 +57,7 @@ def cli(port, host, no_open, shutdown_timeout): try: from autobahn.twisted.resource import WebSocketResource - except (ImportError, ModuleNotFoundError): + except: # pylint: disable=bare-except build_contrib_pysite_deps(get_core_package_dir("contrib-pysite")) from autobahn.twisted.resource import WebSocketResource From a57ea79bf85cc6ee1be29a7d13a3d7ca93d09a69 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 14 Feb 2020 13:49:41 +0200 Subject: [PATCH 07/18] Froze "marshmallow" dependency to 2.X for Python 2 // Resolve #3380 --- HISTORY.rst | 1 + setup.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0df431e277..6aa9204d85 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,7 @@ PlatformIO Core 4 ~~~~~~~~~~~~~~~~~~ * Improved support of PIO Home on card-sized PC (Raspberry Pi, etc.) (`issue #3313 `_) +* Froze "marshmallow" dependency to 2.X for Python 2 (`issue #3380 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) diff --git a/setup.py b/setup.py index 6413ffbd0e..edccd3b9eb 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,8 @@ __url__, __version__, ) +from platformio.compat import PY2 + install_requires = [ "bottle<0.13", @@ -33,9 +35,10 @@ "semantic_version>=2.8.1,<3", "tabulate>=0.8.3,<1", "pyelftools>=0.25,<1", - "marshmallow>=2.20.5", + "marshmallow%s" % (">=2,<3" if PY2 else ">=3"), ] + setup( name=__title__, version=__version__, From fbfbf340c12caf56d8566e24df8c14441d5c9c68 Mon Sep 17 00:00:00 2001 From: valeros Date: Fri, 14 Feb 2020 16:43:20 +0200 Subject: [PATCH 08/18] Add "forceInclude" field to VSCode template VScode doesn't recognize header files included via "-include" flag in "compilerArgs" field. Instead, absolute paths to these files should be specified in a special section "forceInclude". --- .../vscode/.vscode/c_cpp_properties.json.tpl | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index bb94aba28d..f8911d2d23 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -5,7 +5,7 @@ }, { % import platform -% from os.path import commonprefix, dirname, isdir +% from os.path import commonprefix, dirname, isabs, isdir, isfile, join % % systype = platform.system().lower() % @@ -17,6 +17,35 @@ % return " " in flag and systype == "windows" % end % +% def _find_abs_path(inc, inc_paths): +% for path in inc_paths: +% if isfile(join(path, inc)): +% return join(path, inc) +% end +% end +% return inc +% end +% +% def _find_forced_includes(flags, inc_paths): +% result = [] +% i = 0 +% length = len(flags) +% while(i < length): +% if flags[i].startswith("-include"): +% i = i + 1 +% if i < length and not flags[i].startswith("-"): +% inc = flags[i] +% if not isabs(inc): +% inc = _find_abs_path(inc, inc_paths) +% end +% result.append(to_unix_path(inc)) +% end +% end +% i = i + 1 +% end +% return result +% end +% % def _split_flags(flags): % result = [] % i = 0 @@ -83,17 +112,30 @@ % STD_RE = re.compile(r"\-std=[a-z\+]+(\d+)") % cc_stds = STD_RE.findall(cc_flags) % cxx_stds = STD_RE.findall(cxx_flags) +% cc_m_flags = _split_flags(cc_flags) +% forced_includes = _find_forced_includes(cc_m_flags, cleaned_includes) % % if cc_stds: "cStandard": "c{{ cc_stds[-1] }}", % end % if cxx_stds: "cppStandard": "c++{{ cxx_stds[-1] }}", +% end +% if forced_includes: + "forcedInclude": [ +% for include in forced_includes: + "{{ include }}", +% end + "" + ], % end "compilerPath": "{{ cc_path }}", "compilerArgs": [ -% for flag in [ '"%s"' % _escape(f) if _escape_required(f) else f for f in _split_flags( -% cc_flags) if f.startswith(("-m", "-i", "@"))]: +% for flag in [ +% '"%s"' % _escape(f) if _escape_required(f) else f +% for f in cc_m_flags +% if f.startswith(("-m", "-i", "@")) and not f.startswith("-include") +% ]: "{{ flag }}", % end "" From ed4452b115daec022d45d532ac526bf35cba3f0b Mon Sep 17 00:00:00 2001 From: valeros Date: Fri, 14 Feb 2020 17:09:48 +0200 Subject: [PATCH 09/18] Get rid of direct imports --- .../ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index f8911d2d23..6e61501ea0 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -4,8 +4,8 @@ "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags" }, { +% import os % import platform -% from os.path import commonprefix, dirname, isabs, isdir, isfile, join % % systype = platform.system().lower() % @@ -19,8 +19,8 @@ % % def _find_abs_path(inc, inc_paths): % for path in inc_paths: -% if isfile(join(path, inc)): -% return join(path, inc) +% if os.path.isfile(os.path.join(path, inc)): +% return os.path.join(path, inc) % end % end % return inc @@ -35,7 +35,7 @@ % i = i + 1 % if i < length and not flags[i].startswith("-"): % inc = flags[i] -% if not isabs(inc): +% if not os.path.isabs(inc): % inc = _find_abs_path(inc, inc_paths) % end % result.append(to_unix_path(inc)) @@ -73,7 +73,8 @@ % % cleaned_includes = [] % for include in includes: -% if "toolchain-" not in dirname(commonprefix([include, cc_path])) and isdir(include): +% if "toolchain-" not in os.path.dirname(os.path.commonprefix( +% [include, cc_path])) and os.path.isdir(include): % cleaned_includes.append(include) % end % end From 292049199afff48a35c94fc8deaadf64970ae067 Mon Sep 17 00:00:00 2001 From: valeros Date: Fri, 14 Feb 2020 17:24:52 +0200 Subject: [PATCH 10/18] Add new record to history log --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index 6aa9204d85..bf65b80f49 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,7 @@ PlatformIO Core 4 * Improved support of PIO Home on card-sized PC (Raspberry Pi, etc.) (`issue #3313 `_) * Froze "marshmallow" dependency to 2.X for Python 2 (`issue #3380 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) +* Improved VSCode template with special `forceInclude` field for direct inludes via `-include` flag (`issue #3379 `_) 4.2.0 (2020-02-12) From 6556c37e5870c7bbf5b067bc5f201e84d6a0e062 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 14 Feb 2020 20:57:40 +0200 Subject: [PATCH 11/18] Bump version to 4.2.1a2 --- HISTORY.rst | 2 +- platformio/__init__.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index bf65b80f49..8185432e97 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,10 +9,10 @@ PlatformIO Core 4 4.2.1 (2020-02-??) ~~~~~~~~~~~~~~~~~~ +* Improved VSCode template with special ``forceInclude`` field for direct inludes via ``-include`` flag (`issue #3379 `_) * Improved support of PIO Home on card-sized PC (Raspberry Pi, etc.) (`issue #3313 `_) * Froze "marshmallow" dependency to 2.X for Python 2 (`issue #3380 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) -* Improved VSCode template with special `forceInclude` field for direct inludes via `-include` flag (`issue #3379 `_) 4.2.0 (2020-02-12) diff --git a/platformio/__init__.py b/platformio/__init__.py index ef86e1f2b5..461bc7b6b2 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (4, 2, "1a1") +VERSION = (4, 2, "1a2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/setup.py b/setup.py index edccd3b9eb..06a915a60f 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ "semantic_version>=2.8.1,<3", "tabulate>=0.8.3,<1", "pyelftools>=0.25,<1", - "marshmallow%s" % (">=2,<3" if PY2 else ">=3"), + "marshmallow%s" % (">=2,<3" if PY2 else ">=2"), ] From 5cc9a328ab4d64c42f3cda714f65e150eca31128 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 14 Feb 2020 22:57:51 +0200 Subject: [PATCH 12/18] Fixed an issue when Library Dependency Finder (LDF) ignores custom "libLDFMode" and "libCompatMode" options in `library.json` --- HISTORY.rst | 1 + platformio/builder/tools/piolib.py | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8185432e97..c7ef7e113d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,6 +13,7 @@ PlatformIO Core 4 * Improved support of PIO Home on card-sized PC (Raspberry Pi, etc.) (`issue #3313 `_) * Froze "marshmallow" dependency to 2.X for Python 2 (`issue #3380 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) +* Fixed an issue when Library Dependency Finder (LDF) ignores custom "libLDFMode" and "libCompatMode" options in `library.json `__ 4.2.0 (2020-02-12) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index e20226d1aa..b55c492ed1 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -727,22 +727,16 @@ def lib_archive(self): @property def lib_ldf_mode(self): return self.validate_ldf_mode( - self.env.GetProjectOption( - "lib_ldf_mode", - self._manifest.get("build", {}).get( - "libLDFMode", LibBuilderBase.lib_ldf_mode.fget(self) - ), + self._manifest.get("build", {}).get( + "libLDFMode", LibBuilderBase.lib_ldf_mode.fget(self) ) ) @property def lib_compat_mode(self): return self.validate_compat_mode( - self.env.GetProjectOption( - "lib_compat_mode", - self._manifest.get("build", {}).get( - "libCompatMode", LibBuilderBase.lib_compat_mode.fget(self) - ), + self._manifest.get("build", {}).get( + "libCompatMode", LibBuilderBase.lib_compat_mode.fget(self) ) ) From 43664672fc272409ee5569201f1866dbec719e75 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 14 Feb 2020 22:59:16 +0200 Subject: [PATCH 13/18] Bump version to 4.2.1a3 --- HISTORY.rst | 2 +- platformio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c7ef7e113d..342ec2bb4d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,7 +9,7 @@ PlatformIO Core 4 4.2.1 (2020-02-??) ~~~~~~~~~~~~~~~~~~ -* Improved VSCode template with special ``forceInclude`` field for direct inludes via ``-include`` flag (`issue #3379 `_) +* Improved VSCode template with special ``forceInclude`` field for direct includes via ``-include`` flag (`issue #3379 `_) * Improved support of PIO Home on card-sized PC (Raspberry Pi, etc.) (`issue #3313 `_) * Froze "marshmallow" dependency to 2.X for Python 2 (`issue #3380 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index 461bc7b6b2..adcc9d7c58 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (4, 2, "1a2") +VERSION = (4, 2, "1a3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From b8c9eee8afb406a9424c04597d0aa527855e6307 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 16 Feb 2020 21:25:30 +0200 Subject: [PATCH 14/18] Force docs to HTTPS --- platformio/commands/debug/server.py | 2 +- platformio/commands/run/helpers.py | 2 +- platformio/exception.py | 2 +- platformio/package/exception.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio/commands/debug/server.py b/platformio/commands/debug/server.py index 3b16b61dce..855628c3fa 100644 --- a/platformio/commands/debug/server.py +++ b/platformio/commands/debug/server.py @@ -58,7 +58,7 @@ def spawn(self, patterns): # pylint: disable=too-many-branches "\nCould not launch Debug Server '%s'. Please check that it " "is installed and is included in a system PATH\n\n" "See documentation or contact contact@platformio.org:\n" - "http://docs.platformio.org/page/plus/debugging.html\n" + "https://docs.platformio.org/page/plus/debugging.html\n" % server_executable ) diff --git a/platformio/commands/run/helpers.py b/platformio/commands/run/helpers.py index 0d41a569fe..ec038e8499 100644 --- a/platformio/commands/run/helpers.py +++ b/platformio/commands/run/helpers.py @@ -36,7 +36,7 @@ def handle_legacy_libdeps(project_dir, config): "DEPRECATED! A legacy library storage `{0}` has been found in a " "project. \nPlease declare project dependencies in `platformio.ini`" " file using `lib_deps` option and remove `{0}` folder." - "\nMore details -> http://docs.platformio.org/page/projectconf/" + "\nMore details -> https://docs.platformio.org/page/projectconf/" "section_env_library.html#lib-deps".format(legacy_libdeps_dir), fg="yellow", ) diff --git a/platformio/exception.py b/platformio/exception.py index cfd357a4b3..913bc137e2 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -301,6 +301,6 @@ class TestDirNotExists(PlatformioException): "A test folder '{0}' does not exist.\nPlease create 'test' " "directory in project's root and put a test set.\n" "More details about Unit " - "Testing: http://docs.platformio.org/page/plus/" + "Testing: https://docs.platformio.org/page/plus/" "unit-testing.html" ) diff --git a/platformio/package/exception.py b/platformio/package/exception.py index 7804e5197e..550a3628dd 100644 --- a/platformio/package/exception.py +++ b/platformio/package/exception.py @@ -41,5 +41,5 @@ def __init__(self, messages, data, valid_data): def __str__(self): return ( "Invalid manifest fields: %s. \nPlease check specification -> " - "http://docs.platformio.org/page/librarymanager/config.html" % self.messages + "htts://docs.platformio.org/page/librarymanager/config.html" % self.messages ) From 154be7fa8180180960ef28955a7f3531077c2f9f Mon Sep 17 00:00:00 2001 From: Valerii Koval Date: Mon, 17 Feb 2020 12:19:00 +0200 Subject: [PATCH 15/18] Improve VSCode template structure (#3385) * Switch to click argument parser * Typo fix * Tidy up VSCode template Co-authored-by: Ivan Kravets --- .../vscode/.vscode/c_cpp_properties.json.tpl | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl index 6e61501ea0..b228e8c280 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -1,11 +1,8 @@ -{ - "configurations": [ - { - "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags" - }, - { % import os % import platform +% import re +% +% import click % % systype = platform.system().lower() % @@ -17,6 +14,33 @@ % return " " in flag and systype == "windows" % end % +% def split_args(args_string): +% return click.parser.split_arg_string(to_unix_path(args_string)) +% end +% +% def filter_args(args, allowed, ignore=None): +% if not allowed: +% return [] +% end +% +% ignore = ignore or [] +% result = [] +% i = 0 +% length = len(args) +% while(i < length): +% if any(args[i].startswith(f) for f in allowed) and not any( +% args[i].startswith(f) for f in ignore): +% result.append(args[i]) +% if i + 1 < length and not args[i + 1].startswith("-"): +% i += 1 +% result.append(args[i]) +% end +% end +% i += 1 +% end +% return result +% end +% % def _find_abs_path(inc, inc_paths): % for path in inc_paths: % if os.path.isfile(os.path.join(path, inc)): @@ -28,45 +52,16 @@ % % def _find_forced_includes(flags, inc_paths): % result = [] -% i = 0 -% length = len(flags) -% while(i < length): -% if flags[i].startswith("-include"): -% i = i + 1 -% if i < length and not flags[i].startswith("-"): -% inc = flags[i] -% if not os.path.isabs(inc): -% inc = _find_abs_path(inc, inc_paths) -% end -% result.append(to_unix_path(inc)) -% end +% for f in flags: +% inc = "" +% if f.startswith("-include") and f.split("-include")[1].strip(): +% inc = f.split("-include")[1].strip() +% elif not f.startswith("-"): +% inc = f +% end +% if inc: +% result.append(_find_abs_path(inc, inc_paths)) % end -% i = i + 1 -% end -% return result -% end -% -% def _split_flags(flags): -% result = [] -% i = 0 -% flags = flags.strip() -% while i < len(flags): -% current_arg = [] -% while i < len(flags) and flags[i] != " ": -% if flags[i] == '"': -% quotes_idx = flags.find('"', i + 1) -% current_arg.extend(flags[i + 1:quotes_idx]) -% i = quotes_idx + 1 -% else: -% current_arg.append(flags[i]) -% i = i + 1 -% end -% end -% arg = "".join(current_arg) -% if arg.strip(): -% result.append(arg.strip()) -% end -% i = i + 1 % end % return result % end @@ -79,6 +74,19 @@ % end % end % +% STD_RE = re.compile(r"\-std=[a-z\+]+(\d+)") +% cc_stds = STD_RE.findall(cc_flags) +% cxx_stds = STD_RE.findall(cxx_flags) +% cc_m_flags = split_args(cc_flags) +% forced_includes = _find_forced_includes( +% filter_args(cc_m_flags, ["-include"]), cleaned_includes) +% +{ + "configurations": [ + { + "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags" + }, + { % if systype == "windows": "name": "Win32", % elif systype == "darwin": @@ -109,13 +117,6 @@ "" ], "intelliSenseMode": "clang-x64", -% import re -% STD_RE = re.compile(r"\-std=[a-z\+]+(\d+)") -% cc_stds = STD_RE.findall(cc_flags) -% cxx_stds = STD_RE.findall(cxx_flags) -% cc_m_flags = _split_flags(cc_flags) -% forced_includes = _find_forced_includes(cc_m_flags, cleaned_includes) -% % if cc_stds: "cStandard": "c{{ cc_stds[-1] }}", % end @@ -134,8 +135,7 @@ "compilerArgs": [ % for flag in [ % '"%s"' % _escape(f) if _escape_required(f) else f -% for f in cc_m_flags -% if f.startswith(("-m", "-i", "@")) and not f.startswith("-include") +% for f in filter_args(cc_m_flags, ["-m", "-i", "@"], ["-include"]) % ]: "{{ flag }}", % end From 6328206e78bde3058f849f1c2875d3b76207f5c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 17 Feb 2020 13:05:01 +0200 Subject: [PATCH 16/18] Fixed an issue when generating of compilation database "compile_commands.json" does not work with Python 2.7 // Resolve #3378 --- HISTORY.rst | 1 + docs | 2 +- platformio/builder/tools/compilation_db.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 342ec2bb4d..2e4925da88 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,6 +14,7 @@ PlatformIO Core 4 * Froze "marshmallow" dependency to 2.X for Python 2 (`issue #3380 `_) * Fixed "TypeError: unsupported operand type(s)" when system environment variable is used by project configuration parser (`issue #3377 `_) * Fixed an issue when Library Dependency Finder (LDF) ignores custom "libLDFMode" and "libCompatMode" options in `library.json `__ +* Fixed an issue when generating of compilation database "compile_commands.json" does not work with Python 2.7 (`issue #3378 `_) 4.2.0 (2020-02-12) diff --git a/docs b/docs index 3a399f127b..ecc392b0bd 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 3a399f127b6e16c75e47ff06d90f2aace7a5f94b +Subproject commit ecc392b0bd21a83043118c9d8d05147b85e453a1 diff --git a/platformio/builder/tools/compilation_db.py b/platformio/builder/tools/compilation_db.py index c7a6b945ee..af54f5ebf9 100644 --- a/platformio/builder/tools/compilation_db.py +++ b/platformio/builder/tools/compilation_db.py @@ -49,7 +49,7 @@ def __init__(self, value): self.Decider(changed_since_last_build_node) -def changed_since_last_build_node(child, target, prev_ni, node): +def changed_since_last_build_node(*args, **kwargs): """ Dummy decider to force always building""" return True From 9f7c8275723d068d74f88a199fc6cd895c7e4316 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 17 Feb 2020 13:52:25 +0200 Subject: [PATCH 17/18] Resolve absolute path of toolchain when generating compilation database --- platformio/builder/tools/compilation_db.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platformio/builder/tools/compilation_db.py b/platformio/builder/tools/compilation_db.py index af54f5ebf9..2226f825ad 100644 --- a/platformio/builder/tools/compilation_db.py +++ b/platformio/builder/tools/compilation_db.py @@ -25,6 +25,7 @@ import SCons from platformio.builder.tools.platformio import SRC_ASM_EXT, SRC_C_EXT, SRC_CXX_EXT +from platformio.proc import where_is_program # Implements the ability for SCons to emit a compilation database for the MongoDB project. See # http://clang.llvm.org/docs/JSONCompilationDatabase.html for details on what a compilation @@ -145,7 +146,6 @@ def ScanCompilationDb(node, env, path): def generate(env, **kwargs): - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) env["COMPILATIONDB_COMSTR"] = kwargs.get( @@ -195,6 +195,14 @@ def generate(env, **kwargs): ) def CompilationDatabase(env, target): + # Resolve absolute path of toolchain + for cmd in ("CC", "CXX", "AS"): + if cmd not in env: + continue + env[cmd] = where_is_program( + env.subst("$%s" % cmd), env.subst("${ENV['PATH']}") + ) + result = env.__COMPILATIONDB_Database(target=target, source=[]) env.AlwaysBuild(result) From 82f36a1ac38c6d8bec72ebda565fe8d70fbc65e1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 17 Feb 2020 14:25:20 +0200 Subject: [PATCH 18/18] Bump version to 4.2.1 --- HISTORY.rst | 2 +- docs | 2 +- platformio/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2e4925da88..5660956c1b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,7 +6,7 @@ Release Notes PlatformIO Core 4 ----------------- -4.2.1 (2020-02-??) +4.2.1 (2020-02-17) ~~~~~~~~~~~~~~~~~~ * Improved VSCode template with special ``forceInclude`` field for direct includes via ``-include`` flag (`issue #3379 `_) diff --git a/docs b/docs index ecc392b0bd..4b50528d78 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit ecc392b0bd21a83043118c9d8d05147b85e453a1 +Subproject commit 4b50528d78ad3c5e36d149e275f20b5a7154e3a8 diff --git a/platformio/__init__.py b/platformio/__init__.py index adcc9d7c58..120df28d53 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (4, 2, "1a3") +VERSION = (4, 2, 1) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio"