From 6b6ff76945c80fb8b11b71d402b5146c85b86859 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Thu, 30 Jun 2016 14:19:41 +0000 Subject: Adding features to MSVC CROSSTOOL This stops Bazel from passing some of the gcc options to wrapper script. Options we get rid of: -c -o -MD -MF -frandom-seed -isystem -iquote -I -- Change-Id: I416b393c6875a2033d5382a644471c416cd5e8d1 Reviewed-on: https://bazel-review.googlesource.com/#/c/3930 MOS_MIGRATED_REVID=126299789 --- tools/cpp/wrapper/bin/pydir/msvc_cl.py | 10 +--------- tools/cpp/wrapper/bin/pydir/msvc_tools.py | 30 +++++------------------------- 2 files changed, 6 insertions(+), 34 deletions(-) (limited to 'tools/cpp/wrapper/bin/pydir') diff --git a/tools/cpp/wrapper/bin/pydir/msvc_cl.py b/tools/cpp/wrapper/bin/pydir/msvc_cl.py index b8d4c8a7fd..7983099311 100644 --- a/tools/cpp/wrapper/bin/pydir/msvc_cl.py +++ b/tools/cpp/wrapper/bin/pydir/msvc_cl.py @@ -26,11 +26,9 @@ GCCPATTERNS = [ ('-Xcompilation-mode=(dbg|fastbuild|opt)', ['$COMPILATION_MODE']), ('-msse', ['/arch:SSE']), ('-msse2', ['/arch:SSE2']), - ('-c', ['/c']), ('-D(.+)', ['/D$0']), ('-U(.+)', ['/U$0']), ('-E', ['/E']), - (('-o', '(.+)'), ['$COMPILE_OUTPUT0']), ('-O0', ['/Od']), ('-Os', ['/O1']), ('-O2', ['/O2']), @@ -38,18 +36,13 @@ GCCPATTERNS = [ ('-g', ['/MTd']), ('-fexceptions', ['/U_HAS_EXCEPTIONS', '/D_HAS_EXCEPTIONS=1', '/EHsc']), ('-fomit-frame-pointer', ['/Oy']), - ('-frandom-seed(.+)', []), ('-fno-rtti', ['/GR-']), ('-frtti', ['/GR']), ('-fPIC', []), # This is unneeded for Windows. - (('-isystem', '(.*)'), ['/I$PATH0']), - (('-iquote', '(.*)'), ['/I$PATH0']), - ('-I(.+)', ['/I$PATH0']), (('-include', '(.+)'), ['/FI$PATH0']), - ('-MD', []), - (('-MF', '(.+)'), ['$GENERATE_DEPS0']), + (('/DEPENDENCY_FILE', '(.+)'), ['$GENERATE_DEPS0']), ('-w', ['/w']), ('-Wall', ['/Wall']), ('-Wsign-compare', ['/we4018']), @@ -68,7 +61,6 @@ GCCPATTERNS = [ ('-Wno-string-plus-int', []), ('-Wl,S', []), # Stripping is unnecessary since msvc uses pdb files. ('-Wl,-rpath(.+)', []), - (('-x', r'c\+\+-header'), ['$CREATE_PRECOMPILED_HEADER']), ('-B(.+)', []), ('-static', []), ('-shared', []), diff --git a/tools/cpp/wrapper/bin/pydir/msvc_tools.py b/tools/cpp/wrapper/bin/pydir/msvc_tools.py index 9d3162b0da..f84efc33de 100644 --- a/tools/cpp/wrapper/bin/pydir/msvc_tools.py +++ b/tools/cpp/wrapper/bin/pydir/msvc_tools.py @@ -19,7 +19,6 @@ import ntpath import os import re import subprocess -import sys MAX_PATH = 260 # The maximum number of characters in a Windows path. MAX_OPTION_LENGTH = 10 # The maximum length of a compiler/linker option. @@ -123,10 +122,14 @@ class ArgParser(object): matched = [] unmatched = [] files = [] - is_pch = False while i < len(argv): num_matched, action, groups = self._MatchOneArg(argv[i:]) arg = argv[i] + if arg.startswith('/Fo') or arg.startswith('/Fa') or arg.startswith( + '/Fi'): + self.output_file = arg[3:] + self.options.append( + '/Fd%s.pdb' % self.NormPath(os.path.splitext(self.output_file)[0])) if num_matched == 0: # Strip out any .a's that have 0 size, they are header or intermediate # dependency libraries and don't contain any code. 0-length files are @@ -155,13 +158,6 @@ class ArgParser(object): matched += argv[i:i + num_matched] # Handle special options. for entry in action: - if entry == '$CREATE_PRECOMPILED_HEADER': - # The PCH flag comes _first_ on blaze-generated command-lines, so all - # we can do is set a flag here since we have not yet parsed any other - # options. - is_pch = True - continue - if entry == '$TARGET_ARCH': if arg == '-m32': self.target_arch = 'x86' @@ -205,22 +201,6 @@ class ArgParser(object): exit(-1) continue - # Depending on whether we are creating precompiled headers cl.exe - # needs different options for specifying the output file. - if entry == ('$COMPILE_OUTPUT%d' % g): - if is_pch: - # Just touch the PCH file so that blaze is happy. - with open(value, 'a'): - os.utime(value, None) - # Exit since we don't want to actually try to process a PCH. - sys.exit(0) - else: - self.output_file = value - self.options.append('/Fo%s' % self.NormPath(value)) - self.options.append('/Fd%s.pdb' % - self.NormPath(os.path.splitext(value)[0])) - continue - if entry == ('$GENERATE_DEPS%d' % g): self.options.append('/showIncludes') self.deps_file = value -- cgit v1.2.3