diff --git a/HISTORY.rst b/HISTORY.rst index 6f0b02f1..fb8f8747 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,10 +4,27 @@ Release Notes PlatformIO 3.0 -------------- +3.6.4 (2019-01-23) +~~~~~~~~~~~~~~~~~~ + +* Improved Project Generator for IDEs: + + - Use full path to PlatformIO CLI when generating a project + (`issue #1674 `_) + - CLion: Improved project portability using "${CMAKE_CURRENT_LIST_DIR}" instead of full path + - Eclipse: Provide language standard to a project C/C++ indexer + (`issue #1010 `_) + +* Fixed an issue with incorrect detecting of compatibility (LDF) between generic library and Arduino or ARM mbed frameworks +* Fixed "Runtime Error: Dictionary size changed during iteration" + (`issue #2003 `_) +* Fixed an error "Could not extract item..." when extracting TAR archive with symbolic items on Windows platform + (`issue #2015 `_) + 3.6.3 (2018-12-12) ~~~~~~~~~~~~~~~~~~ -* Ignore *.asm and *.ASM files when building Arduino-based library (compatibility with Arduino builder) +* Ignore ``*.asm`` and ``*.ASM`` files when building Arduino-based library (compatibility with Arduino builder) * Fixed spurious project's "Problems" for `PlatformIO IDE for VSCode `__ when ARM mbed framework is used * Fixed an issue with a broken headers list when generating ".clang_complete" for `Emacs `__ (`issue #1960 `_) @@ -50,7 +67,6 @@ PlatformIO 3.0 (`issue #1873 `_) * Fixed an issue with incorrect handling of a custom package name when using `platformio lib install `__ or `platformio platform install `__ commands - 3.6.0 (2018-08-06) ~~~~~~~~~~~~~~~~~~ diff --git a/docs b/docs index c0dc8357..a48c700b 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit c0dc83570a14489da4e887215b08035a503b9d95 +Subproject commit a48c700ba11faa1da891ddeab613192c768252a9 diff --git a/examples b/examples index 322e1f2b..99f177e5 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 322e1f2bb79c42ea55a07900c97b70bfd5a7a62f +Subproject commit 99f177e5be7c595ac99167fd7b302ea117d64b42 diff --git a/platformio/__init__.py b/platformio/__init__.py index 3f6bf3af..bb0d7626 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 6, 3) +VERSION = (3, 6, 4) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/app.py b/platformio/app.py index 14c4de22..d3c82d25 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -226,9 +226,9 @@ class ContentCache(object): newlines = [] with open(self._db_path) as fp: for line in fp.readlines(): + line = line.strip() if "=" not in line: continue - line = line.strip() expire, path = line.split("=") if time() < int(expire) and isfile(path) and \ path not in paths_for_delete: diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 9259a8ac..17cefb0c 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -19,6 +19,7 @@ from __future__ import absolute_import import hashlib import os +import re import sys from glob import glob from os.path import (basename, commonprefix, dirname, isdir, isfile, join, @@ -64,6 +65,9 @@ class LibBuilderFactory(object): if isfile(join(path, "module.json")): return ["mbed"] + include_re = re.compile( + r'^#include\s+(<|")(Arduino|mbed)\.h(<|")', flags=re.MULTILINE) + # check source files for root, _, files in os.walk(path, followlinks=True): for fname in files: @@ -72,9 +76,9 @@ class LibBuilderFactory(object): continue with open(join(root, fname)) as f: content = f.read() - if "Arduino.h" in content: + if "Arduino.h" in content and include_re.search(content): return ["arduino"] - elif "mbed.h" in content: + elif "mbed.h" in content and include_re.search(content): return ["mbed"] return [] diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index efec49ad..8ec43aed 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -15,6 +15,7 @@ import json import os import re +import sys from os.path import abspath, basename, expanduser, isdir, isfile, join, relpath import bottle @@ -146,7 +147,8 @@ class ProjectGenerator(object): "project_libdeps_dir": util.get_projectlibdeps_dir(), "systype": util.get_systype(), "platformio_path": self._fix_os_path( - util.where_is_program("platformio")), + sys.argv[0] if isfile(sys.argv[0]) + else util.where_is_program("platformio")), "env_pathsep": os.pathsep, "env_path": self._fix_os_path(os.getenv("PATH")) }) # yapf: disable diff --git a/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl b/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl index 3c4bed47..a1c84d68 100644 --- a/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl +++ b/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl @@ -1,8 +1,20 @@ -set(ENV{PATH} "{{env_path}}") -set(PLATFORMIO_CMD "{{platformio_path}}") +% def _normalize_path(path): +% if project_dir in path: +% path = path.replace(project_dir, "${CMAKE_CURRENT_LIST_DIR}") +% elif user_home_dir in path: +% if "windows" in systype: +% path = path.replace(user_home_dir, "$ENV{HOMEDRIVE}$ENV{HOMEPATH}") +% else: +% path = path.replace(user_home_dir, "$ENV{HOME}") +% end +% end +% return path.replace("\\", "/") +% end -SET(CMAKE_C_COMPILER "{{cc_path.replace("\\", "/")}}") -SET(CMAKE_CXX_COMPILER "{{cxx_path.replace("\\", "/")}}") +set(PLATFORMIO_CMD "{{ _normalize_path(platformio_path) }}") + +SET(CMAKE_C_COMPILER "{{ _normalize_path(cc_path) }}") +SET(CMAKE_CXX_COMPILER "{{ _normalize_path(cxx_path) }}") SET(CMAKE_CXX_FLAGS_DISTRIBUTION "{{cxx_flags}}") SET(CMAKE_C_FLAGS_DISTRIBUTION "{{cc_flags}}") set(CMAKE_CXX_STANDARD 11) @@ -13,15 +25,7 @@ add_definitions(-D'{{!re.sub(r"([\"\(\)#])", r"\\\1", define)}}') % end % for include in includes: -% if include.startswith(user_home_dir): -% if "windows" in systype: -include_directories("$ENV{HOMEDRIVE}$ENV{HOMEPATH}{{include.replace(user_home_dir, '').replace("\\", "/")}}") -% else: -include_directories("$ENV{HOME}{{include.replace(user_home_dir, '').replace("\\", "/")}}") -% end -% else: -include_directories("{{include.replace("\\", "/")}}") -% end +include_directories("{{ _normalize_path(include) }}") % end -FILE(GLOB_RECURSE SRC_LIST "{{project_src_dir.replace("\\", "/")}}/*.*" "{{project_lib_dir.replace("\\", "/")}}/*.*" "{{project_libdeps_dir.replace("\\", "/")}}/*.*") +FILE(GLOB_RECURSE SRC_LIST "{{ _normalize_path(project_src_dir) }}/*.*" "{{ _normalize_path(project_lib_dir) }}/*.*" "{{ _normalize_path(project_libdeps_dir) }}/*.*") diff --git a/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl b/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl index 19740737..a119c8b2 100644 --- a/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl +++ b/platformio/ide/tpls/eclipse/.settings/language.settings.xml.tpl @@ -1,3 +1,8 @@ +% import re +% STD_RE = re.compile(r"(\-std=[a-z\+]+\d+)") +% cxx_stds = STD_RE.findall(cxx_flags) +% cxx_std = cxx_stds[-1] if cxx_stds else "" +% @@ -6,9 +11,9 @@ % if "windows" in systype: - + % else: - + % end @@ -21,9 +26,9 @@ % if "windows" in systype: - + % else: - + % end diff --git a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl index 6f24d6a1..160cd6ba 100644 --- a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl +++ b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl @@ -4,7 +4,7 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run" ], @@ -14,7 +14,7 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run" ], @@ -23,27 +23,7 @@ { "cmd": [ - "platformio", - "-f", "-c", "sublimetext", - "run", - "--target", - "clean" - ], - "name": "Clean" - }, - { - "cmd": - [ - "platformio", - "-f", "-c", "sublimetext", - "test" - ], - "name": "Test" - }, - { - "cmd": - [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run", "--target", @@ -54,7 +34,27 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", + "-f", "-c", "sublimetext", + "run", + "--target", + "clean" + ], + "name": "Clean" + }, + { + "cmd": + [ + "{{ platformio_path }}", + "-f", "-c", "sublimetext", + "test" + ], + "name": "Test" + }, + { + "cmd": + [ + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run", "--target", @@ -65,7 +65,7 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "run", "--target", @@ -76,16 +76,24 @@ { "cmd": [ - "platformio", + "{{ platformio_path }}", "-f", "-c", "sublimetext", "update" ], "name": "Update platforms and libraries" + }, + { + "cmd": + [ + "{{ platformio_path }}", + "-f", "-c", "sublimetext", + "upgrade" + ], + "name": "Upgrade PlatformIO Core" } ], "working_dir": "${project_path:${folder}}", - "selector": "source.c, source.c++", - "path": "{{env_path}}" + "selector": "source.c, source.c++" } ], "folders": @@ -98,7 +106,7 @@ { "sublimegdb_workingdir": "{{project_dir}}", "sublimegdb_exec_cmd": "", - "sublimegdb_commandline": "{{platformio_path}} -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit" + "sublimegdb_commandline": "{{ platformio_path }} -f -c sublimetext debug --interface=gdb --interpreter=mi -x .pioinit" } } diff --git a/platformio/unpacker.py b/platformio/unpacker.py index 8f55b42d..11c23814 100644 --- a/platformio/unpacker.py +++ b/platformio/unpacker.py @@ -13,7 +13,7 @@ # limitations under the License. from os import chmod -from os.path import exists, islink, join +from os.path import exists, join from tarfile import open as tarfile_open from time import mktime from zipfile import ZipFile @@ -56,6 +56,10 @@ class TARArchive(ArchiveBase): def get_item_filename(self, item): return item.name + @staticmethod + def islink(item): + return item.islnk() or item.issym() + class ZIPArchive(ArchiveBase): @@ -80,6 +84,9 @@ class ZIPArchive(ArchiveBase): def get_item_filename(self, item): return item.filename + def islink(self, item): + raise NotImplementedError() + def after_extract(self, item, dest_dir): self.preserve_permissions(item, dest_dir) self.preserve_mtime(item, dest_dir) @@ -120,7 +127,9 @@ class FileUnpacker(object): for item in self._unpacker.get_items(): filename = self._unpacker.get_item_filename(item) item_path = join(dest_dir, filename) - if not islink(item_path) and not exists(item_path): - raise exception.ExtractArchiveItemError(filename, dest_dir) - + try: + if not self._unpacker.islink(item) and not exists(item_path): + raise exception.ExtractArchiveItemError(filename, dest_dir) + except NotImplementedError: + pass return True diff --git a/platformio/util.py b/platformio/util.py index c5433ee3..5fe186d7 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -794,17 +794,20 @@ def merge_dicts(d1, d2, path=None): return d1 +def get_file_contents(path): + try: + with open(path) as f: + return f.read() + except UnicodeDecodeError: + with open(path, encoding="latin-1") as f: + return f.read() + + def ensure_udev_rules(): def _rules_to_set(rules_path): - result = set([]) - with open(rules_path, "rb") as fp: - for line in fp.readlines(): - line = line.strip() - if not line or line.startswith("#"): - continue - result.add(line) - return result + return set(l.strip() for l in get_file_contents(rules_path).split("\n") + if l.strip() and not l.startswith("#")) if "linux" not in get_systype(): return None diff --git a/tests/commands/test_lib.py b/tests/commands/test_lib.py index 7fc6ca90..b67cec39 100644 --- a/tests/commands/test_lib.py +++ b/tests/commands/test_lib.py @@ -170,7 +170,7 @@ def test_global_lib_list(clirunner, validate_cliresult): ] versions2 = [ 'ArduinoJson@5.8.2', 'ArduinoJson@5.10.1', 'AsyncMqttClient@0.8.2', - 'AsyncTCP@1.0.1', 'NeoPixelBus@2.2.4', 'PJON@07fe9aa', 'PJON@1fb26fd', + 'NeoPixelBus@2.2.4', 'PJON@07fe9aa', 'PJON@1fb26fd', 'PubSubClient@bef5814', 'RFcontrol@77d4eb3f8a', 'RadioHead-1.62@0.0.0' ] assert set(versions1) >= set(versions2) diff --git a/tests/test_examples.py b/tests/test_examples.py index d9588956..0727da75 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -37,7 +37,8 @@ def pytest_generate_tests(metafunc): if not p.is_embedded(): continue # issue with "version `CXXABI_1.3.9' not found (required by sdcc)" - if "linux" in util.get_systype() and p.name == "intel_mcs51": + if "linux" in util.get_systype() and p.name in ("intel_mcs51", + "ststm8"): continue examples_dir = join(p.get_dir(), "examples") assert isdir(examples_dir)