From ff221b103a4fb91889f7e8e2ebc6fd6dd43d7083 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 7 Jul 2023 22:36:43 +0300 Subject: [PATCH] Resolved an issue that caused generated projects for PlatformIO IDE for VSCode to break when the ``-iprefix`` compiler flag was used --- HISTORY.rst | 2 ++ platformio/builder/tools/piointegration.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index aa87ed80..2ed70050 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,8 @@ PlatformIO Core 6 6.1.10 (2023-??-??) ~~~~~~~~~~~~~~~~~~~ +* Resolved an issue that caused generated projects for `PlatformIO IDE for VSCode `__ to break when the ``-iprefix`` compiler flag was used + 6.1.9 (2023-07-06) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/piointegration.py b/platformio/builder/tools/piointegration.py index 25ca1eb0..88368929 100644 --- a/platformio/builder/tools/piointegration.py +++ b/platformio/builder/tools/piointegration.py @@ -12,11 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. - import glob import os +import shlex -import click import SCons.Defaults # pylint: disable=import-error import SCons.Subst # pylint: disable=import-error from SCons.Script import COMMAND_LINE_TARGETS # pylint: disable=import-error @@ -145,6 +144,11 @@ def _subst_cmd(env, cmd): return " ".join([SCons.Subst.quote_spaces(arg) for arg in args]) +def _split_flags_string(s): + flags = shlex.split(s, posix=False) + return [f[1:-1] if f.startswith('"') and f.endswith('"') else f for f in flags] + + def DumpIntegrationData(*args): projenv, globalenv = args[0:2] # pylint: disable=unbalanced-tuple-unpacking data = { @@ -155,10 +159,10 @@ def DumpIntegrationData(*args): ], "defines": dump_defines(projenv), "includes": projenv.DumpIntegrationIncludes(), - "cc_flags": click.parser.split_arg_string( + "cc_flags": _split_flags_string( _subst_cmd(projenv, "$CFLAGS $CCFLAGS $CPPFLAGS") ), - "cxx_flags": click.parser.split_arg_string( + "cxx_flags": _split_flags_string( _subst_cmd(projenv, "$CXXFLAGS $CCFLAGS $CPPFLAGS") ), "cc_path": where_is_program(