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

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

Issue 10340002: Don't support spaces in command, simplify msvs_emulation (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: explicitly don't support spaces in command name, simplify msvs_emulation 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/gyptest-command-quote.py » ('j') | no next file with comments »
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 # Note that the first argument is assumed to be the command. We take extra 56 # Note that the first argument is assumed to be the command. Don't add
57 # steps to make sure that calls to .bat files are handled correctly, and 57 # quotes around it because then commands like 'call x.bat' or shell
58 # that paths are normalized and quoted as necessary. 58 # built-ins like 'echo', etc. won't work. Also, don't bother special casing
59 # to get quotes around the remainder (after 'call') since other generators
60 # and gyp in general don't really support spaces in paths.
59 if not args: return '' 61 if not args: return ''
60 program = args[0] 62 program = args[0]
61 if program.startswith('call '):
62 call, batch = program.split(' ', 1)
63 program = 'call ' + QuoteForRspFile(os.path.normpath(batch))
64 else:
65 program = os.path.normpath(program)
66 # Don't add quotes around things without spaces so that 'call', 'echo',
67 # etc. will work if they're specified as individual arguments.
68 if ' ' in program:
69 program = QuoteForRspFile(program)
70 return program + ' ' + ' '.join(QuoteForRspFile(arg) for arg in args[1:]) 63 return program + ' ' + ' '.join(QuoteForRspFile(arg) for arg in args[1:])
71 64
72 65
73 def _GenericRetrieve(root, default, path): 66 def _GenericRetrieve(root, default, path):
74 """Given a list of dictionary keys |path| and a tree of dicts |root|, find 67 """Given a list of dictionary keys |path| and a tree of dicts |root|, find
75 value at path, or return |default| if any of the path doesn't exist.""" 68 value at path, or return |default| if any of the path doesn't exist."""
76 if not root: 69 if not root:
77 return default 70 return default
78 if not path: 71 if not path:
79 return root 72 return root
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 vs.Path(), r'Common7\Tools\vsvars32.bat')) 477 vs.Path(), r'Common7\Tools\vsvars32.bat'))
485 478
486 def ExpandMacros(string, expansions): 479 def ExpandMacros(string, expansions):
487 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv 480 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv
488 for the canonical way to retrieve a suitable dict.""" 481 for the canonical way to retrieve a suitable dict."""
489 if '$' in string: 482 if '$' in string:
490 for old, new in expansions.iteritems(): 483 for old, new in expansions.iteritems():
491 assert '$(' not in new, new 484 assert '$(' not in new, new
492 string = string.replace(old, new) 485 string = string.replace(old, new)
493 return string 486 return string
OLDNEW
« no previous file with comments | « no previous file | test/win/gyptest-command-quote.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698