aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Alexander Chung <alexander.chung@uwaterloo.ca>2017-02-07 12:48:26 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-07 18:27:09 +0000
commitfc07142f08f9c32c1f3c757881078aba227de421 (patch)
tree70aba3849333ae98c2ce1a6824cb8b293fc60b5c /tools
parenta2c0192e0ca7647178d798cd6ff79699424623ad (diff)
Add quotes to improve space support
These changes addresses issues where Windows users have a space in their username. Allows the default output_base path to be used. Closes #2491. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/2491 PiperOrigin-RevId: 146773331 MOS_MIGRATED_REVID=146773331
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/wrapper/bin/call_python.bat.tpl4
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_link.py7
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl3
3 files changed, 8 insertions, 6 deletions
diff --git a/tools/cpp/wrapper/bin/call_python.bat.tpl b/tools/cpp/wrapper/bin/call_python.bat.tpl
index 1e8747c25e..1beb42698a 100644
--- a/tools/cpp/wrapper/bin/call_python.bat.tpl
+++ b/tools/cpp/wrapper/bin/call_python.bat.tpl
@@ -17,9 +17,9 @@
set arg0=%~1
for %%F in ("%arg0%") do set DRIVER_BIN=%%~dpF
-for /F %%i in ("%arg0%") do set TOOLNAME=%%~ni
+for /F "delims=" %%i in ("%arg0%") do set TOOLNAME=%%~ni
-set PYDIR="%DRIVER_BIN%pydir"
+set PYDIR=%DRIVER_BIN%pydir
if not defined MSVCPYTHON set MSVCPYTHON="%{python_binary}"
%MSVCPYTHON% -B "%PYDIR%\%TOOLNAME%.py" %*
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_link.py b/tools/cpp/wrapper/bin/pydir/msvc_link.py
index 98c1a0b5e7..91176446f8 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_link.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_link.py
@@ -15,6 +15,7 @@
"""Wrapper script for executing the Microsoft Linker."""
import os
+import re
import sys
import msvc_tools
@@ -25,8 +26,8 @@ sys.path.append(SCRIPT_DIR)
LINKPATTERNS = [
('-m(32|64)', ['$TARGET_ARCH']),
('-Xcompilation-mode=(dbg|fastbuild|opt)', ['$COMPILATION_MODE']),
- (('rcs.*', '(.+)'), ['/OUT:$PATH0']),
- (('-o', '(.+)'), ['/OUT:$PATH0']),
+ (('rcs.*', '(.+)'), ['/OUT:"$PATH0"']),
+ (('-o', '(.+)'), ['/OUT:"$PATH0"']),
('-B(.+)', []),
('-lpthread', []),
('-L(.+)', ['/LIBPATH:$PATH0']),
@@ -75,7 +76,7 @@ class MsvcLinker(msvc_tools.WindowsRunner):
name = ''
for arg in parser.options:
if '/OUT:' in arg:
- name = arg[5:]
+ name = re.sub(r'^"|"$', '', arg[5:])
if not name:
raise msvc_tools.Error('No output file name specified!')
# Check if the library is empty, which is what happens when we create header
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
index 7b46ef44bf..e3a9c7c499 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
+++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py.tpl
@@ -509,7 +509,8 @@ class WindowsRunner(object):
# Using parameter file as input when linking static libraries.
params_file = open(parser.params_file, 'w')
for arg in args:
- params_file.write(arg + '\n')
+ params_file.write(('"%s"' % arg) if os.path.isfile(arg) else arg)
+ params_file.write('\n')
params_file.close()
except (IOError, e):
print('Could not open', parser.params_file, 'for writing:', str(e))