From b17acd7605c5b03050afb1474487e90e6295f51c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 10 Feb 2016 17:16:52 +0200 Subject: [PATCH] Fix issue with "CPPDEFINES" which contain space and break PlatformIO IDE Linter --- HISTORY.rst | 2 +- platformio/builder/tools/piomisc.py | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3fcd121a..a63a32dd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,7 +7,7 @@ PlatformIO 2.0 2.8.4 (2016-02-??) ~~~~~~~~~~~~~~~~~~ -* Temporary disabled ``CPPDEFINES`` which contain space and break PlatformIO +* Fixed issue with ``CPPDEFINES`` which contain space and break PlatformIO IDE Linter (`IDE issue #34 `_) diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 83db55ec..e366b821 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -215,14 +215,7 @@ def DumpIDEData(env): env_ = env.Clone() - # TODO tmp fix https://github.com/platformio/platformio-atom-ide/issues/34 - _new_defines = [] - for item in env_.get("CPPDEFINES", []): - if " " not in item: - _new_defines.append(item) - env_.Replace(CPPDEFINES=_new_defines) - - return { + data = { "defines": get_defines(env_), "includes": get_includes(env_), "cc_flags": env_.subst("$SHCFLAGS $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS"), @@ -232,6 +225,23 @@ def DumpIDEData(env): env_.subst("$CXX"), env_.subst("${ENV['PATH']}")) } + # https://github.com/platformio/platformio-atom-ide/issues/34 + _new_defines = [] + for item in env_.get("CPPDEFINES", []): + if " " in item: + _new_defines.append(item.replace(" ", "\\\\ ")) + else: + _new_defines.append(item) + env_.Replace(CPPDEFINES=_new_defines) + + data.update({ + "cc_flags": env_.subst("$SHCFLAGS $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS"), + "cxx_flags": env_.subst( + "$SHCXXFLAGS $SHCCFLAGS $CPPFLAGS $_CPPDEFFLAGS") + }) + + return data + def GetCompilerType(env): try: