Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: pylib/gyp/msvs_emulation.py

Issue 10269018: ninja windows: handle more cases in program quoting (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: fancier quoting Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/win/command-quote/a.S » ('j') | test/win/command-quote/command-quote.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 This module helps emulate Visual Studio 2008 behavior on top of other 6 This module helps emulate Visual Studio 2008 behavior on top of other
7 build systems, primarily ninja. 7 build systems, primarily ninja.
8 """ 8 """
9 9
10 import os 10 import os
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 # These commands are used in rsp files, so no escaping for the shell (via ^) 46 # These commands are used in rsp files, so no escaping for the shell (via ^)
47 # is necessary. 47 # is necessary.
48 48
49 # Finally, wrap the whole thing in quotes so that the above quote rule 49 # Finally, wrap the whole thing in quotes so that the above quote rule
50 # applies and whitespace isn't a word break. 50 # applies and whitespace isn't a word break.
51 return '"' + arg + '"' 51 return '"' + arg + '"'
52 52
53 53
54 def EncodeRspFileList(args): 54 def EncodeRspFileList(args):
55 """Process a list of arguments using QuoteCmdExeArgument.""" 55 """Process a list of arguments using QuoteCmdExeArgument."""
56 return ' '.join(QuoteForRspFile(arg) for arg in args) 56 # Note that the first argument is assumed to be the command. We take extra
57 # steps to make sure that calls to .bat files are handled correctly, and
58 # that paths are normalized and quoted as necessary.
59 program = args[0] if args else ''
Nico 2012/05/01 17:17:26 nit: I'd `if not args: return ''` at the top inste
scottmg 2012/05/01 18:40:14 Done.
60 if program.startswith('call '):
61 call, space, batch = program.partition(' ')
Nico 2012/05/01 17:17:26 call, batch = program.split(' ', 1) ? Or at least
scottmg 2012/05/01 18:40:14 I always forget about [, maxsplit] on split for so
62 program = 'call ' + QuoteForRspFile(os.path.normpath(batch))
63 else:
64 program = os.path.normpath(program)
65 if ' ' in program:
66 program = QuoteForRspFile(program)
Nico 2012/05/01 17:17:26 You do this here only if ' ' in program, but uncon
scottmg 2012/05/01 18:40:14 Yes, unfortunately. Not adding the quotes here han
67 return program + ' ' + ' '.join(QuoteForRspFile(arg) for arg in args[1:])
57 68
58 69
59 def _GenericRetrieve(root, default, path): 70 def _GenericRetrieve(root, default, path):
60 """Given a list of dictionary keys |path| and a tree of dicts |root|, find 71 """Given a list of dictionary keys |path| and a tree of dicts |root|, find
61 value at path, or return |default| if any of the path doesn't exist.""" 72 value at path, or return |default| if any of the path doesn't exist."""
62 if not root: 73 if not root:
63 return default 74 return default
64 if not path: 75 if not path:
65 return root 76 return root
66 return _GenericRetrieve(root.get(path[0]), default, path[1:]) 77 return _GenericRetrieve(root.get(path[0]), default, path[1:])
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 """Get a dict of variables mapping internal VS macro names to their gyp 157 """Get a dict of variables mapping internal VS macro names to their gyp
147 equivalents.""" 158 equivalents."""
148 replacements = { 159 replacements = {
149 '$(VSInstallDir)': self.vs_version.Path(), 160 '$(VSInstallDir)': self.vs_version.Path(),
150 '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC'), 161 '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC'),
151 '$(OutDir)\\': base_to_build + '\\' if base_to_build else '', 162 '$(OutDir)\\': base_to_build + '\\' if base_to_build else '',
152 '$(IntDir)': '$!INTERMEDIATE_DIR', 163 '$(IntDir)': '$!INTERMEDIATE_DIR',
153 '$(InputPath)': '${source}', 164 '$(InputPath)': '${source}',
154 '$(InputName)': '${root}', 165 '$(InputName)': '${root}',
155 '$(ProjectName)': self.spec['target_name'], 166 '$(ProjectName)': self.spec['target_name'],
156 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain. 167 '$(PlatformName)': 'Win32', # TODO(scottmg): Support for x64 toolchain.
Nico 2012/05/01 17:17:26 That part landed already and needs a rebase, right
scottmg 2012/05/01 18:40:14 You lost me. There's nothing here that's related t
Nico 2012/05/01 20:10:27 Doh, looked at the delta from a previous patch set
157 } 168 }
158 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be 169 # Chromium uses DXSDK_DIR in include/lib paths, but it may or may not be
159 # set. This happens when the SDK is sync'd via src-internal, rather than 170 # set. This happens when the SDK is sync'd via src-internal, rather than
160 # by typical end-user installation of the SDK. If it's not set, we don't 171 # by typical end-user installation of the SDK. If it's not set, we don't
161 # want to leave the unexpanded variable in the path, so simply strip it. 172 # want to leave the unexpanded variable in the path, so simply strip it.
162 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else '' 173 replacements['$(DXSDK_DIR)'] = self.dxsdk_dir if self.dxsdk_dir else ''
163 return replacements 174 return replacements
164 175
165 def ConvertVSMacros(self, s, base_to_build=None): 176 def ConvertVSMacros(self, s, base_to_build=None):
166 """Convert from VS macro names to something equivalent.""" 177 """Convert from VS macro names to something equivalent."""
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 vs.Path(), r'Common7\Tools\vsvars32.bat')) 481 vs.Path(), r'Common7\Tools\vsvars32.bat'))
471 482
472 def ExpandMacros(string, expansions): 483 def ExpandMacros(string, expansions):
473 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv 484 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv
474 for the canonical way to retrieve a suitable dict.""" 485 for the canonical way to retrieve a suitable dict."""
475 if '$' in string: 486 if '$' in string:
476 for old, new in expansions.iteritems(): 487 for old, new in expansions.iteritems():
477 assert '$(' not in new, new 488 assert '$(' not in new, new
478 string = string.replace(old, new) 489 string = string.replace(old, new)
479 return string 490 return string
OLDNEW
« no previous file with comments | « no previous file | test/win/command-quote/a.S » ('j') | test/win/command-quote/command-quote.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698