Enable msvc toolchain to support params file
Also fixed a small bug
--
Change-Id: I22fa16272587471b9652f3b7f7d9cb1341fc6524
Reviewed-on: https://bazel-review.googlesource.com/#/c/3464
MOS_MIGRATED_REVID=120703703
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 70454cc..b121ddc 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -137,6 +137,7 @@
objcopy_files = ":empty",
static_runtime_libs = [":empty"],
strip_files = ":empty",
+ supports_param_files = 1,
)
filegroup(
diff --git a/tools/cpp/BUILD.static b/tools/cpp/BUILD.static
index 6f5f585..b7fbd70 100644
--- a/tools/cpp/BUILD.static
+++ b/tools/cpp/BUILD.static
@@ -89,6 +89,7 @@
objcopy_files = ":empty",
static_runtime_libs = [":empty"],
strip_files = ":empty",
+ supports_param_files = 1,
)
filegroup(
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index 8dc1b47..34c6e85 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -558,7 +558,7 @@
abi_version: "local"
abi_libc_version: "local"
- target_cpu: "x64_windows"
+ target_cpu: "x64_windows_msvc"
compiler: "cl"
target_libc: "msvcrt140"
default_python_version: "python2.7"
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py b/tools/cpp/wrapper/bin/pydir/msvc_tools.py
index ef6ae79..6e1f07c 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py
@@ -53,6 +53,7 @@
self.compilation_mode = None
self.deps_file = None
self.output_file = None
+ self.params_file = None
self._ParseArgs(argv)
def _MatchOneArg(self, args):
@@ -194,6 +195,9 @@
# regular command-line arguments.
params = [line.rstrip() for line in open(value, 'r')]
self._ParseArgs(params)
+ # Because we have no write permission to orginal params file,
+ # create a new params file with addtional suffix
+ self.params_file = value + '.msvc'
except IOError, e:
print 'Could not open', value, 'for reading:', str(e)
exit(-1)
@@ -425,7 +429,19 @@
output_filter = re.compile('(' + ')|('.join(filters) + ')')
includes_filter = re.compile(r'Note: including file:\s+(.*)')
# Run the command.
- cmd = [binary] + args
+ if parser.params_file:
+ try:
+ # 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.close()
+ except IOError, e:
+ print 'Could not open', parser.params_file, 'for writing:', str(e)
+ exit(-1)
+ cmd = [binary] + [('@' + os.path.normpath(parser.params_file))]
+ else:
+ cmd = [binary] + args
# Save stderr output to a temporary in case we need it.
proc = subprocess.Popen(cmd,
env=build_env,