From 186580d794dfe12fb74fca885a5551b7e2087e22 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 18 Dec 2015 15:20:37 +0200 Subject: [PATCH] Fix issue with code builder when build path contains spaces // Resolve #387 --- HISTORY.rst | 2 ++ platformio/__init__.py | 2 +- platformio/builder/scripts/espressif.py | 13 +++++++------ platformio/builder/scripts/frameworks/cmsis.py | 2 +- platformio/builder/scripts/ststm32.py | 7 ++++--- platformio/builder/scripts/titiva.py | 2 +- platformio/builder/tools/pioar.py | 8 ++++++-- platformio/builder/tools/platformio.py | 2 +- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8f972019d8..e14be58310 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,8 @@ PlatformIO 2.0 (`issue #379 `_) * Fixed reset method for Espressif NodeMCU (ESP-12E Module) (`issue #380 `_) +* Fixed issue with code builder when build path contains spaces + (`issue #387 `_) 2.6.0 (2015-12-15) diff --git a/platformio/__init__.py b/platformio/__init__.py index fdcf1b1e48..af4c57ac36 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (2, 6, "1.dev2") +VERSION = (2, 6, "1.dev3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index b1a298580a..6ffa0fb04e 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -92,7 +92,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 "-cp", "$UPLOAD_PORT", "-cf", "$SOURCE" ], - UPLOADCMD='$UPLOADER $UPLOADERFLAGS', + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS', PROGNAME="firmware", PROGSUFFIX=".elf" @@ -104,9 +104,10 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 BUILDERS=dict( ElfToBin=Builder( action=" ".join([ - "$UPLOADER", - "-eo", join("$PLATFORMFW_DIR", "bootloaders", - "eboot", "eboot.elf"), + '"$UPLOADER"', + "-eo", + '"%s"' % join("$PLATFORMFW_DIR", "bootloaders", + "eboot", "eboot.elf"), "-bo", "$TARGET", "-bm", "dio", "-bf", "${BOARD_OPTIONS['build']['f_cpu'][:2]}", @@ -147,7 +148,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 "-i", "$UPLOAD_PORT", "-f", "$SOURCE" ], - UPLOADCMD='$UPLOADEROTA $UPLOADERFLAGS' + UPLOADCMD='"$UPLOADEROTA" $UPLOADERFLAGS' ) except socket.error: pass @@ -163,7 +164,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 BUILDERS=dict( ElfToBin=Builder( action=" ".join([ - "$UPLOADER", + '"$UPLOADER"', "-eo", "$SOURCES", "-bo", "${TARGETS[0]}", "-bm", "qio", diff --git a/platformio/builder/scripts/frameworks/cmsis.py b/platformio/builder/scripts/frameworks/cmsis.py index c83ab4780e..f3d7a7ff31 100644 --- a/platformio/builder/scripts/frameworks/cmsis.py +++ b/platformio/builder/scripts/frameworks/cmsis.py @@ -61,7 +61,7 @@ if "mbed" in env.get("BOARD_OPTIONS", {}).get("frameworks", {}): env.Append( LINKFLAGS=[ - "-Wl,-T", + '-Wl,-T"%s"' % join( "$PIOPACKAGES_DIR", "framework-mbed", "variant", env.subst("$BOARD").upper(), "mbed", diff --git a/platformio/builder/scripts/ststm32.py b/platformio/builder/scripts/ststm32.py index 276192bca7..1b35cb5d0b 100644 --- a/platformio/builder/scripts/ststm32.py +++ b/platformio/builder/scripts/ststm32.py @@ -41,10 +41,11 @@ UPLOADERFLAGS=[ join("$BUILD_DIR", "firmware.elf"), "-batch", - "-x", join("$PROJECT_DIR", "upload.gdb") + "-x", + '"%s"' % join("$PROJECT_DIR", "upload.gdb") ], - UPLOADCMD="$UPLOADER $UPLOADERFLAGS" + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' ) else: env.Replace( @@ -55,7 +56,7 @@ "0x08000000" # flash start adress ], - UPLOADCMD="$UPLOADER $UPLOADERFLAGS" + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' ) diff --git a/platformio/builder/scripts/titiva.py b/platformio/builder/scripts/titiva.py index 800f9a7607..8dbaaf3f4f 100644 --- a/platformio/builder/scripts/titiva.py +++ b/platformio/builder/scripts/titiva.py @@ -28,7 +28,7 @@ env.Replace( UPLOADER=join("$PIOPACKAGES_DIR", "tool-lm4flash", "lm4flash"), - UPLOADCMD="$UPLOADER $SOURCES" + UPLOADCMD='"$UPLOADER" $SOURCES' ) env.Append( diff --git a/platformio/builder/tools/pioar.py b/platformio/builder/tools/pioar.py index cd3b9be02d..624ff6fc1a 100644 --- a/platformio/builder/tools/pioar.py +++ b/platformio/builder/tools/pioar.py @@ -26,9 +26,13 @@ def _huge_sources_hook(sources): tmp_file = join(gettempdir(), "pioarargs-%s" % md5(_sources).hexdigest()) with open(tmp_file, "w") as f: - f.write(_sources) + # fix space in paths + for line in _sources.split(".o "): + if not line.endswith(".o"): + line += ".o" + f.write('"%s" ' % line) - return "@%s" % tmp_file + return '@"%s"' % tmp_file def exists(_): diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index bd8c655842..ad5dfb0bc6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -58,7 +58,7 @@ def BuildProgram(env): if ("LDSCRIPT_PATH" in env and not any(["-Wl,-T" in f for f in env['LINKFLAGS']])): env.Append( - LINKFLAGS=["-Wl,-T", "$LDSCRIPT_PATH"] + LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"'] ) # enable "cyclic reference" for linker