diff --git a/HISTORY.rst b/HISTORY.rst index 5ea68cce..120c45cb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,19 @@ Release Notes PlatformIO 3.0 -------------- +3.6.2 (2018-11-29) +~~~~~~~~~~~~~~~~~~ + +* Improved IntelliSense for `PlatformIO IDE for VSCode `__ via passing extra compiler information for C/C++ Code Parser (resolves issues with spurious project's "Problems") +* Fixed an issue with VSCode IntelliSense warning about the missed headers located in `include `__ folder +* Fixed incorrect wording when initializing/updating project +* Fixed an issue with incorrect order for library dependencies ``CPPPATH`` + (`issue #1914 `_) +* Fixed an issue when Library Dependency Finder (LDF) does not handle project `src_filter `__ + (`issue #1905 `_) +* Fixed an issue when Library Dependency Finder (LDF) finds spurious dependencies in ``chain+`` and ``deep+`` modes + (`issue #1930 `_) + 3.6.1 (2018-10-29) ~~~~~~~~~~~~~~~~~~ diff --git a/docs b/docs index 30c88f62..cfdb7d89 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 30c88f624780bd003f105bab7ddfc56f20de850c +Subproject commit cfdb7d89681470706bb6bb2c5ea8e9356475f1cd diff --git a/platformio/__init__.py b/platformio/__init__.py index b980d065..e4a8ed38 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 6, 1) +VERSION = (3, 6, 2) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index 063ce45d..0e6bf31a 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -25,7 +25,7 @@ from platformio.managers.core import get_core_package_dir def _dump_includes(env): - includes = [env.subst("$PROJECTINCLUDE_DIR"), env.subst("$PROJECTSRC_DIR")] + includes = [] for item in env.get("CPPPATH", []): includes.append(env.subst(item)) @@ -53,6 +53,10 @@ def _dump_includes(env): if unity_dir: includes.append(unity_dir) + includes.extend( + [env.subst("$PROJECTINCLUDE_DIR"), + env.subst("$PROJECTSRC_DIR")]) + # remove duplicates result = [] for item in includes: @@ -130,8 +134,8 @@ def _get_svd_path(env): def DumpIDEData(env): - LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS" - LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS" + LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS" + LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS" data = { "libsource_dirs": diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index d9e5733c..574c9ed9 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -347,7 +347,7 @@ class LibBuilderBase(object): for path in self._validate_search_files(search_files): try: assert "+" in self.lib_ldf_mode - incs = LibBuilderBase.CCONDITIONAL_SCANNER( + candidates = LibBuilderBase.CCONDITIONAL_SCANNER( self.env.File(path), self.env, tuple(include_dirs), @@ -357,26 +357,26 @@ class LibBuilderBase(object): sys.stderr.write( "Warning! Classic Pre Processor is used for `%s`, " "advanced has failed with `%s`\n" % (path, e)) - _incs = LibBuilderBase.CLASSIC_SCANNER( + candidates = LibBuilderBase.CLASSIC_SCANNER( self.env.File(path), self.env, tuple(include_dirs)) - incs = [] - for inc in _incs: - incs.append(inc) - if not self.PARSE_SRC_BY_H_NAME: + + # print(path, map(lambda n: n.get_abspath(), candidates)) + for item in candidates: + if item not in result: + result.append(item) + if not self.PARSE_SRC_BY_H_NAME: + continue + _h_path = item.get_abspath() + if not self.env.IsFileWithExt(_h_path, piotool.SRC_HEADER_EXT): + continue + _f_part = _h_path[:_h_path.rindex(".")] + for ext in piotool.SRC_C_EXT: + if not isfile("%s.%s" % (_f_part, ext)): continue - _h_path = inc.get_abspath() - if not self.env.IsFileWithExt(_h_path, - piotool.SRC_HEADER_EXT): - continue - _f_part = _h_path[:_h_path.rindex(".")] - for ext in piotool.SRC_C_EXT: - if isfile("%s.%s" % (_f_part, ext)): - incs.append( - self.env.File("%s.%s" % (_f_part, ext))) - # print(path, map(lambda n: n.get_abspath(), incs)) - for inc in incs: - if inc not in result: - result.append(inc) + _c_path = self.env.File("%s.%s" % (_f_part, ext)) + if _c_path not in result: + result.append(_c_path) + return result def depend_recursive(self, lb, search_files=None): @@ -432,23 +432,23 @@ class LibBuilderBase(object): libs.extend(lb.build()) # copy shared information to self env for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): - self.env.AppendUnique(**{key: lb.env.get(key)}) + self.env.PrependUnique(**{key: lb.env.get(key)}) for lb in self._circular_deps: - self.env.AppendUnique(CPPPATH=lb.get_include_dirs()) + self.env.PrependUnique(CPPPATH=lb.get_include_dirs()) if self._is_built: return libs self._is_built = True - self.env.AppendUnique(CPPPATH=self.get_include_dirs()) + self.env.PrependUnique(CPPPATH=self.get_include_dirs()) if self.lib_ldf_mode == "off": for lb in self.env.GetLibBuilders(): if self == lb or not lb.is_built: continue for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): - self.env.AppendUnique(**{key: lb.env.get(key)}) + self.env.PrependUnique(**{key: lb.env.get(key)}) if self.lib_archive: libs.append( @@ -663,6 +663,12 @@ class PlatformIOLibBuilder(LibBuilderBase): class ProjectAsLibBuilder(LibBuilderBase): + def __init__(self, env, *args, **kwargs): + # backup original value, will be reset in base.__init__ + project_src_filter = env.get("SRC_FILTER") + super(ProjectAsLibBuilder, self).__init__(env, *args, **kwargs) + self.env['SRC_FILTER'] = project_src_filter + @property def include_dir(self): include_dir = self.env.subst("$PROJECTINCLUDE_DIR") @@ -701,7 +707,8 @@ class ProjectAsLibBuilder(LibBuilderBase): @property def src_filter(self): - return self.env.get("SRC_FILTER", LibBuilderBase.src_filter.fget(self)) + return (self.env.get("SRC_FILTER") + or LibBuilderBase.src_filter.fget(self)) def process_extra_options(self): # skip for project, options are already processed @@ -743,7 +750,7 @@ class ProjectAsLibBuilder(LibBuilderBase): def build(self): self._is_built = True # do not build Project now - self.env.AppendUnique(CPPPATH=self.get_include_dirs()) + self.env.PrependUnique(CPPPATH=self.get_include_dirs()) return LibBuilderBase.build(self) diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 3033ea25..9d37ae77 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -124,15 +124,15 @@ def LoadPioPlatform(env, variables): def PrintConfiguration(env): platform = env.PioPlatform() platform_data = ["PLATFORM: %s >" % platform.title] - system_data = ["SYSTEM:"] + hardware_data = ["HARDWARE:"] configuration_data = ["CONFIGURATION:"] mcu = env.subst("$BOARD_MCU") f_cpu = env.subst("$BOARD_F_CPU") if mcu: - system_data.append(mcu.upper()) + hardware_data.append(mcu.upper()) if f_cpu: f_cpu = int("".join([c for c in str(f_cpu) if c.isdigit()])) - system_data.append("%dMHz" % (f_cpu / 1000000)) + hardware_data.append("%dMHz" % (f_cpu / 1000000)) debug_tools = None if "BOARD" in env: @@ -142,13 +142,14 @@ def PrintConfiguration(env): debug_tools = board_config.get("debug", {}).get("tools") ram = board_config.get("upload", {}).get("maximum_ram_size") flash = board_config.get("upload", {}).get("maximum_size") - system_data.append("%s RAM (%s Flash)" % (util.format_filesize(ram), - util.format_filesize(flash))) + hardware_data.append( + "%s RAM (%s Flash)" % (util.format_filesize(ram), + util.format_filesize(flash))) configuration_data.append( "https://docs.platformio.org/page/boards/%s/%s.html" % (platform.name, board_config.id)) - for data in (configuration_data, platform_data, system_data): + for data in (configuration_data, platform_data, hardware_data): if len(data) > 1: print(" ".join(data)) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 321e8ea1..b93499ae 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -44,10 +44,10 @@ def scons_patched_match_splitext(path, suffixes=None): def _build_project_deps(env): project_lib_builder = env.ConfigureProjectLibBuilder() - # append project libs to the beginning of list + # prepend project libs to the beginning of list env.Prepend(LIBS=project_lib_builder.build()) - # append extra linker related options from libs - env.AppendUnique( + # prepend extra linker related options from libs + env.PrependUnique( **{ key: project_lib_builder.env.get(key) for key in ("LIBS", "LIBPATH", "LINKFLAGS") diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 1e3cbeb9..e90bc2fd 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -87,7 +87,7 @@ def cli( click.echo("%s - Project Configuration File" % click.style( "platformio.ini", fg="cyan")) - is_new_project = util.is_platformio_project(project_dir) + is_new_project = not util.is_platformio_project(project_dir) init_base_project(project_dir) if board: diff --git a/platformio/ide/tpls/atom/.gcc-flags.json.tpl b/platformio/ide/tpls/atom/.gcc-flags.json.tpl index 5af2ea3a..20942a7a 100644 --- a/platformio/ide/tpls/atom/.gcc-flags.json.tpl +++ b/platformio/ide/tpls/atom/.gcc-flags.json.tpl @@ -1,7 +1,8 @@ +% _defines = " ".join(["-D%s" % d for d in defines]) { "execPath": "{{ cxx_path.replace("\\", "/") }}", - "gccDefaultCFlags": "-fsyntax-only {{! cc_flags.replace(' -MMD ', ' ').replace('"', '\\"') }}", - "gccDefaultCppFlags": "-fsyntax-only {{! cxx_flags.replace(' -MMD ', ' ').replace('"', '\\"') }}", + "gccDefaultCFlags": "-fsyntax-only {{! cc_flags.replace(' -MMD ', ' ').replace('"', '\\"') }} {{ !_defines.replace('"', '\\"') }}", + "gccDefaultCppFlags": "-fsyntax-only {{! cxx_flags.replace(' -MMD ', ' ').replace('"', '\\"') }} {{ !_defines.replace('"', '\\"') }}", "gccErrorLimit": 15, "gccIncludePaths": "{{ ','.join(includes).replace("\\", "/") }}", "gccSuppressWarnings": false diff --git a/platformio/ide/tpls/vim/.gcc-flags.json.tpl b/platformio/ide/tpls/vim/.gcc-flags.json.tpl index 07acafd0..b904e1a3 100644 --- a/platformio/ide/tpls/vim/.gcc-flags.json.tpl +++ b/platformio/ide/tpls/vim/.gcc-flags.json.tpl @@ -1,7 +1,8 @@ +% _defines = " ".join(["-D%s" % d for d in defines]) { "execPath": "{{ cxx_path.replace("\\", "/") }}", - "gccDefaultCFlags": "-fsyntax-only {{! cc_flags.replace(' -MMD ', ' ').replace('"', '\\"') }}", - "gccDefaultCppFlags": "-fsyntax-only {{! cxx_flags.replace(' -MMD ', ' ').replace('"', '\\"') }}", + "gccDefaultCFlags": "-fsyntax-only {{! cc_flags.replace(' -MMD ', ' ').replace('"', '\\"') }} {{ !_defines.replace('"', '\\"') }}", + "gccDefaultCppFlags": "-fsyntax-only {{! cxx_flags.replace(' -MMD ', ' ').replace('"', '\\"') }} {{ !_defines.replace('"', '\\"') }}", "gccErrorLimit": 15, "gccIncludePaths": "{{! ','.join("'{}'".format(w.replace("\\", '/')) for w in includes)}}", "gccSuppressWarnings": false 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 2497f743..c90ca667 100644 --- a/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl +++ b/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl @@ -7,10 +7,14 @@ % % systype = platform.system().lower() % +% def _escape(text): +% return text.replace('\\\\', '/').replace('\\', '/').replace('"', '\\"') +% end +% % cleaned_includes = [] % for include in includes: % if "toolchain-" not in dirname(commonprefix([include, cc_path])): -% cleaned_includes.append(include) +% cleaned_includes.append(include) % end % end % @@ -24,7 +28,7 @@ % end "includePath": [ % for include in cleaned_includes: - "{{include.replace('\\\\', '/').replace('\\', '/').replace('"', '\\"')}}", + "{{! _escape(include) }}", % end "" ], @@ -33,14 +37,14 @@ "databaseFilename": "${workspaceRoot}/.vscode/.browse.c_cpp.db", "path": [ % for include in cleaned_includes: - "{{include.replace('\\\\', '/').replace('\\', '/').replace('"', '\\"')}}", + "{{! _escape(include) }}", % end "" ] }, "defines": [ % for define in defines: - "{{!define.replace('"', '\\"')}}", + "{{! _escape(define) }}", % end "" ], @@ -56,7 +60,7 @@ % if cxx_stds: "cppStandard": "c++{{ cxx_stds[-1] }}", % end - "compilerPath": "{{ cc_path.replace('\\\\', '/').replace('\\', '/').replace('"', '\\"') }}" + "compilerPath": "{{! _escape(cc_path) }} {{! _escape(STD_RE.sub("", cc_flags)) }}" } ] } \ No newline at end of file diff --git a/platformio/maintenance.py b/platformio/maintenance.py index bafe4fa9..7894dbda 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -66,11 +66,12 @@ def on_platformio_exception(e): def in_silence(ctx=None): ctx = ctx or app.get_session_var("command_ctx") - assert ctx - ctx_args = ctx.args or [] - return ctx_args and any([ - ctx.args[0] == "upgrade", "--json-output" in ctx_args, - "--version" in ctx_args + if not ctx: + return True + return ctx.args and any([ + ctx.args[0] == "debug" and "--interpreter" in " ".join(ctx.args), + ctx.args[0] == "upgrade", "--json-output" in ctx.args, + "--version" in ctx.args ]) diff --git a/platformio/managers/core.py b/platformio/managers/core.py index 0ea1cb15..2a516f04 100644 --- a/platformio/managers/core.py +++ b/platformio/managers/core.py @@ -24,11 +24,11 @@ from platformio import __version__, exception, util from platformio.managers.package import PackageManager CORE_PACKAGES = { - "contrib-piohome": "^1.0.2", - "contrib-pysite": ">=0.3.2,<2", - "tool-pioplus": "^1.5.0", + "contrib-piohome": "^2.0.0", + "contrib-pysite": "~2.%d%d.0" % (sys.version_info[0], sys.version_info[1]), + "tool-pioplus": "^2.0.0", "tool-unity": "~1.20403.0", - "tool-scons": "~2.20501.4" + "tool-scons": "~2.20501.7" } PIOPLUS_AUTO_UPDATES_MAX = 100 @@ -106,12 +106,12 @@ def update_core_packages(only_check=False, silent=False): def shutdown_piohome_servers(): port = 8010 - while port < 9000: + while port < 8100: try: requests.get("http://127.0.0.1:%d?__shutdown__=1" % port) - port += 1 except: # pylint: disable=bare-except - return + pass + port += 1 def pioplus_call(args, **kwargs): diff --git a/scripts/docspregen.py b/scripts/docspregen.py index d2072ed2..721d39da 100644 --- a/scripts/docspregen.py +++ b/scripts/docspregen.py @@ -628,8 +628,8 @@ def update_embedded_board(rst_path, board): lines.append(""" .. contents:: -System ------- +Hardware +-------- Platform :ref:`platform_{platform}`: {platform_description} @@ -822,7 +822,7 @@ Boards # Debug tools for tool, platforms in tool_to_platforms.items(): tool_path = join(DOCS_ROOT_DIR, "plus", "debug-tools", "%s.rst" % tool) - assert isfile(tool_path) + assert isfile(tool_path), tool platforms = sorted(set(platforms)) lines = [".. begin_platforms"]