diff --git a/HISTORY.rst b/HISTORY.rst index 41b7ab20..19b9b921 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,16 @@ PlatformIO Core 5 **A professional collaborative platform for embedded development** +5.0.3 (2020-11-12) +~~~~~~~~~~~~~~~~~~ + +- Added an error selector for `Sublime Text `__ build runner (`issue #3733 `_) +- Generate a working "projectEnvName" for PlatformIO IDE's debugger for VSCode +- Force VSCode's intelliSenseMode to "gcc-x64" when GCC toolchain is used +- Print ignored test suites and environments in the test summary report only in verbose mode (`issue #3726 `_) +- Fixed an issue when the package manager tries to install a built-in library from the registry (`issue #3662 `_) +- Fixed an issue when `pio package pack `__ ignores some folders (`issue #3730 `_) + 5.0.2 (2020-10-30) ~~~~~~~~~~~~~~~~~~ diff --git a/docs b/docs index deae09a8..8d9e8ef0 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit deae09a880822fb8c0b4973c29f75f2343476d6f +Subproject commit 8d9e8ef02b730c01c39a6e9355ede0111b3eee81 diff --git a/examples b/examples index 84855946..7255d5b8 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 84855946ea09b5e41ddbbae455f00e897060346d +Subproject commit 7255d5b897b402d981b843f88ee001b69c9f1407 diff --git a/platformio/__init__.py b/platformio/__init__.py index 55813e69..5fa70b0a 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (5, 0, 2) +VERSION = (5, 0, 3) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/app.py b/platformio/app.py index 0196fac4..9b22b638 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -255,6 +255,8 @@ def get_cid(): uid = None if os.getenv("C9_UID"): uid = os.getenv("C9_UID") + elif os.getenv("GITPOD_GIT_USER_NAME"): + uid = os.getenv("GITPOD_GIT_USER_NAME") elif os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")): try: uid = json.loads( diff --git a/platformio/commands/project.py b/platformio/commands/project.py index 592f3a48..e7809e25 100644 --- a/platformio/commands/project.py +++ b/platformio/commands/project.py @@ -149,15 +149,19 @@ def project_init( ): if not silent: if project_dir == os.getcwd(): - click.secho("\nThe current working directory", fg="yellow", nl=False) - click.secho(" %s " % project_dir, fg="cyan", nl=False) - click.secho("will be used for the project.", fg="yellow") + click.secho("\nThe current working directory ", fg="yellow", nl=False) + try: + click.secho(project_dir, fg="cyan", nl=False) + except UnicodeEncodeError: + click.secho(json.dumps(project_dir), fg="cyan", nl=False) + click.secho(" will be used for the project.", fg="yellow") click.echo("") - click.echo( - "The next files/directories have been created in %s" - % click.style(project_dir, fg="cyan") - ) + click.echo("The next files/directories have been created in ", nl=False) + try: + click.secho(project_dir, fg="cyan") + except UnicodeEncodeError: + click.secho(json.dumps(project_dir), fg="cyan") click.echo( "%s - Put project header files here" % click.style("include", fg="cyan") ) diff --git a/platformio/commands/test/command.py b/platformio/commands/test/command.py index 13104bb2..a4b6634f 100644 --- a/platformio/commands/test/command.py +++ b/platformio/commands/test/command.py @@ -177,7 +177,7 @@ def cli( # pylint: disable=redefined-builtin if without_testing: return - print_testing_summary(results) + print_testing_summary(results, verbose) command_failed = any(r.get("succeeded") is False for r in results) if command_failed: @@ -222,7 +222,7 @@ def print_processing_footer(result): ) -def print_testing_summary(results): +def print_testing_summary(results, verbose=False): click.echo() tabular_data = [] @@ -236,6 +236,8 @@ def print_testing_summary(results): failed_nums += 1 status_str = click.style("FAILED", fg="red") elif result.get("succeeded") is None: + if not verbose: + continue status_str = "IGNORED" else: succeeded_nums += 1 diff --git a/platformio/ide/tpls/emacs/.ccls.tpl b/platformio/ide/tpls/emacs/.ccls.tpl index b6d7d55a..232d2f8d 100644 --- a/platformio/ide/tpls/emacs/.ccls.tpl +++ b/platformio/ide/tpls/emacs/.ccls.tpl @@ -4,7 +4,7 @@ % cxx_stds = STD_RE.findall(cxx_flags) % % -clang +{{ cxx_path }} % if cc_stds: {{"%c"}} -std=c{{ cc_stds[-1] }} diff --git a/platformio/ide/tpls/qtcreator/platformio.pro.tpl b/platformio/ide/tpls/qtcreator/platformio.pro.tpl index 1c1a1adf..89774699 100644 --- a/platformio/ide/tpls/qtcreator/platformio.pro.tpl +++ b/platformio/ide/tpls/qtcreator/platformio.pro.tpl @@ -1,3 +1,13 @@ +% import re +% +% cpp_standards_remap = { +% "0x": "11", +% "1y": "14", +% "1z": "17", +% "2a": "20", +% "2b": "23" +% } + win32 { HOMEDIR += $$(USERPROFILE) } @@ -27,3 +37,9 @@ HEADERS += {{file}} SOURCES += {{file}} % end % end + +% STD_RE = re.compile(r"\-std=[a-z\+]+(\w+)") +% cxx_stds = STD_RE.findall(cxx_flags) +% if cxx_stds: +CONFIG += c++{{ cpp_standards_remap.get(cxx_stds[-1], cxx_stds[-1]) }} +% end diff --git a/platformio/ide/tpls/sublimetext/.ccls.tpl b/platformio/ide/tpls/sublimetext/.ccls.tpl new file mode 100644 index 00000000..232d2f8d --- /dev/null +++ b/platformio/ide/tpls/sublimetext/.ccls.tpl @@ -0,0 +1,22 @@ +% import re +% STD_RE = re.compile(r"\-std=[a-z\+]+(\w+)") +% cc_stds = STD_RE.findall(cc_flags) +% cxx_stds = STD_RE.findall(cxx_flags) +% +% +{{ cxx_path }} + +% if cc_stds: +{{"%c"}} -std=c{{ cc_stds[-1] }} +% end +% if cxx_stds: +{{"%cpp"}} -std=c++{{ cxx_stds[-1] }} +% end + +% for include in filter_includes(includes): +-I{{ include }} +% end + +% for define in defines: +-D{{ define }} +% end diff --git a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl index 160cd6ba..2b5d61d4 100644 --- a/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl +++ b/platformio/ide/tpls/sublimetext/platformio.sublime-project.tpl @@ -5,9 +5,10 @@ "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "run" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "PlatformIO", "variants": [ @@ -15,78 +16,73 @@ "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "run" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "Build" }, { "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "run", "--target", "upload" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "Upload" }, { "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "run", "--target", "clean" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "Clean" }, { "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "test" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "Test" }, { "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", - "run", - "--target", - "program" - ], - "name": "Upload using Programmer" - }, - { - "cmd": - [ - "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "run", "--target", "uploadfs" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "Upload SPIFFS image" }, { "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "update" ], + "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$", "name": "Update platforms and libraries" }, { "cmd": [ "{{ platformio_path }}", - "-f", "-c", "sublimetext", + "-c", "sublimetext", "upgrade" ], "name": "Upgrade PlatformIO Core" 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 e99957cb..dee165d4 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -118,7 +118,9 @@ % end "" ], - "intelliSenseMode": "clang-x64", +% if compiler_type == "gcc": + "intelliSenseMode": "gcc-x64", +% end % if cc_stds: "cStandard": "c{{ cc_stds[-1] }}", % end diff --git a/platformio/ide/tpls/vscode/.vscode/launch.json.tpl b/platformio/ide/tpls/vscode/.vscode/launch.json.tpl index 21e2bb41..4acea135 100644 --- a/platformio/ide/tpls/vscode/.vscode/launch.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/launch.json.tpl @@ -19,13 +19,18 @@ "request": "launch", "name": "PIO Debug", "executable": "{{ _escape_path(prog_path) }}", + "projectEnvName": "{{ env_name }}", "toolchainBinDir": "{{ _escape_path(dirname(gdb_path)) }}", % if svd_path: "svdPath": "{{ _escape_path(svd_path) }}", % end "preLaunchTask": { "type": "PlatformIO", +% if len(config.envs()) > 1: + "task": "Pre-Debug ({{ env_name }})" +% else: "task": "Pre-Debug" +% end }, "internalConsoleOptions": "openOnSessionStart" }, @@ -34,6 +39,7 @@ "request": "launch", "name": "PIO Debug (skip Pre-Debug)", "executable": "{{ _escape_path(prog_path) }}", + "projectEnvName": "{{ env_name }}", "toolchainBinDir": "{{ _escape_path(dirname(gdb_path)) }}", % if svd_path: "svdPath": "{{ _escape_path(svd_path) }}", diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 5fa66bd1..63674ad7 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -73,17 +73,20 @@ def on_platformio_exception(e): def set_caller(caller=None): caller = caller or getenv("PLATFORMIO_CALLER") - if not caller: - if getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): - caller = "vscode" - elif is_container(): - if getenv("C9_UID"): - caller = "C9" - elif getenv("USER") == "cabox": - caller = "CA" - elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")): - caller = "Che" - app.set_session_var("caller_id", caller) + if caller: + return app.set_session_var("caller_id", caller) + if getenv("VSCODE_PID") or getenv("VSCODE_NLS_CONFIG"): + caller = "vscode" + elif getenv("GITPOD_INSTANCE_ID") or getenv("GITPOD_WORKSPACE_URL"): + caller = "gitpod" + elif is_container(): + if getenv("C9_UID"): + caller = "C9" + elif getenv("USER") == "cabox": + caller = "CA" + elif getenv("CHE_API", getenv("CHE_API_ENDPOINT")): + caller = "Che" + return app.set_session_var("caller_id", caller) class Upgrader(object): diff --git a/platformio/package/manager/library.py b/platformio/package/manager/library.py index 2843e9ba..9f8bd28a 100644 --- a/platformio/package/manager/library.py +++ b/platformio/package/manager/library.py @@ -127,7 +127,13 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc for key, value in dependency.items() if key in ("authors", "platforms", "frameworks") } - return self._install(spec, search_filters=search_filters or None, silent=silent) + try: + return self._install( + spec, search_filters=search_filters or None, silent=silent + ) + except UnknownPackageError: + pass + return None def uninstall_dependencies(self, pkg, silent=False): assert isinstance(pkg, PackageItem) diff --git a/platformio/package/manifest/schema.py b/platformio/package/manifest/schema.py index f293ba5a..fdf2f4bb 100644 --- a/platformio/package/manifest/schema.py +++ b/platformio/package/manifest/schema.py @@ -141,7 +141,7 @@ class ExampleSchema(StrictSchema): name = fields.Str( required=True, validate=[ - validate.Length(min=1, max=100), + validate.Length(min=1, max=255), validate.Regexp( r"^[a-zA-Z\d\-\_/]+$", error="Only [a-zA-Z0-9-_/] chars are allowed" ), diff --git a/platformio/package/pack.py b/platformio/package/pack.py index ebdca496..164ce96c 100644 --- a/platformio/package/pack.py +++ b/platformio/package/pack.py @@ -46,6 +46,8 @@ class PackagePacker(object): ".git/", ".hg/", ".svn/", + ] + EXCLUDE_EXTRA = [ # Tests "tests?", # Docs @@ -120,7 +122,6 @@ class PackagePacker(object): src = tmp_dir src = self.find_source_root(src) - manifest = self.load_manifest(src) filename = self.get_archive_name( manifest["name"], @@ -188,7 +189,7 @@ class PackagePacker(object): return dst def compute_src_filters(self, src, include, exclude): - exclude_default = self.EXCLUDE_DEFAULT[:] + exclude_extra = self.EXCLUDE_EXTRA[:] # extend with library extra filters if any( os.path.isfile(os.path.join(src, name)) @@ -198,11 +199,15 @@ class PackagePacker(object): ManifestFileType.MODULE_JSON, ) ): - exclude_default.extend(self.EXCLUDE_LIBRARY_EXTRA) + exclude_extra.extend(self.EXCLUDE_LIBRARY_EXTRA) result = ["+<%s>" % p for p in include or ["*", ".*"]] + result += ["-<%s>" % p for p in self.EXCLUDE_DEFAULT] + # exclude items declared in manifest result += ["-<%s>" % p for p in exclude or []] - result += ["-<%s>" % p for p in exclude_default] + # apply extra excludes if no custom "export" field in manifest + if not include and not exclude: + result += ["-<%s>" % p for p in exclude_extra] # automatically include manifests result += ["+<%s>" % p for p in self.INCLUDE_DEFAULT] return result diff --git a/tests/commands/test_lib_complex.py b/tests/commands/test_lib_complex.py index 0014801b..c1314500 100644 --- a/tests/commands/test_lib_complex.py +++ b/tests/commands/test_lib_complex.py @@ -236,7 +236,9 @@ def test_global_lib_update_check(clirunner, validate_cliresult): result = clirunner.invoke(cmd_lib, ["-g", "update", "--dry-run", "--json-output"]) validate_cliresult(result) output = json.loads(result.output) - assert set(["ESPAsyncTCP", "NeoPixelBus"]) == set(lib["name"] for lib in output) + assert set(["Adafruit PN532", "ESPAsyncTCP", "NeoPixelBus"]) == set( + lib["name"] for lib in output + ) def test_global_lib_update(clirunner, validate_cliresult): @@ -256,7 +258,7 @@ def test_global_lib_update(clirunner, validate_cliresult): result = clirunner.invoke(cmd_lib, ["-g", "update"]) validate_cliresult(result) assert result.output.count("[Detached]") == 1 - assert result.output.count("[Up-to-date]") == 15 + assert result.output.count("[Up-to-date]") == 14 # update unknown library result = clirunner.invoke(cmd_lib, ["-g", "update", "Unknown"]) diff --git a/tests/commands/test_test.py b/tests/commands/test_test.py index a50b9fa7..4543ad92 100644 --- a/tests/commands/test_test.py +++ b/tests/commands/test_test.py @@ -34,9 +34,7 @@ def test_local_env(): if result["returncode"] != 1: pytest.fail(str(result)) # pylint: disable=unsupported-membership-test - assert all([s in result["err"] for s in ("PASSED", "IGNORED", "FAILED")]), result[ - "out" - ] + assert all([s in result["err"] for s in ("PASSED", "FAILED")]), result["out"] def test_multiple_env_build(clirunner, validate_cliresult, tmpdir):