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

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

Issue 1885103003: gyp-win-tool: Don't use shell=True on non-Windows hosts. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: back Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 Google Inc. All rights reserved. 3 # Copyright (c) 2012 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Utility functions for Windows builds. 7 """Utility functions for Windows builds.
8 8
9 These functions are executed via gyp-win-tool when using the ninja generator. 9 These functions are executed via gyp-win-tool when using the ninja generator.
10 """ 10 """
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 """Filter diagnostic output from link that looks like: 112 """Filter diagnostic output from link that looks like:
113 ' Creating library ui.dll.lib and object ui.dll.exp' 113 ' Creating library ui.dll.lib and object ui.dll.exp'
114 This happens when there are exports from the dll or exe. 114 This happens when there are exports from the dll or exe.
115 """ 115 """
116 env = self._GetEnv(arch) 116 env = self._GetEnv(arch)
117 if use_separate_mspdbsrv == 'True': 117 if use_separate_mspdbsrv == 'True':
118 self._UseSeparateMspdbsrv(env, args) 118 self._UseSeparateMspdbsrv(env, args)
119 if sys.platform == 'win32': 119 if sys.platform == 'win32':
120 args = list(args) # *args is a tuple by default, which is read-only. 120 args = list(args) # *args is a tuple by default, which is read-only.
121 args[0] = args[0].replace('/', '\\') 121 args[0] = args[0].replace('/', '\\')
122 link = subprocess.Popen(args, shell=True, env=env, 122 # https://docs.python.org/2/library/subprocess.html:
123 # "On Unix with shell=True [...] if args is a sequence, the first item
124 # specifies the command string, and any additional items will be treated as
125 # additional arguments to the shell itself. That is to say, Popen does the
126 # equivalent of:
127 # Popen(['/bin/sh', '-c', args[0], args[1], ...])"
128 # For that reason, since going through the shell doesn't seem necessary on
129 # non-Windows don't do that there.
130 link = subprocess.Popen(args, shell=sys.platform == 'win32', env=env,
123 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 131 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
124 out, _ = link.communicate() 132 out, _ = link.communicate()
125 for line in out.splitlines(): 133 for line in out.splitlines():
126 if (not line.startswith(' Creating library ') and 134 if (not line.startswith(' Creating library ') and
127 not line.startswith('Generating code') and 135 not line.startswith('Generating code') and
128 not line.startswith('Finished generating code')): 136 not line.startswith('Finished generating code')):
129 print line 137 print line
130 return link.returncode 138 return link.returncode
131 139
132 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, 140 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 project_dir = os.path.relpath(project_dir, BASE_DIR) 313 project_dir = os.path.relpath(project_dir, BASE_DIR)
306 selected_files = selected_files.split(';') 314 selected_files = selected_files.split(';')
307 ninja_targets = [os.path.join(project_dir, filename) + '^^' 315 ninja_targets = [os.path.join(project_dir, filename) + '^^'
308 for filename in selected_files] 316 for filename in selected_files]
309 cmd = ['ninja.exe'] 317 cmd = ['ninja.exe']
310 cmd.extend(ninja_targets) 318 cmd.extend(ninja_targets)
311 return subprocess.call(cmd, shell=True, cwd=BASE_DIR) 319 return subprocess.call(cmd, shell=True, cwd=BASE_DIR)
312 320
313 if __name__ == '__main__': 321 if __name__ == '__main__':
314 sys.exit(main(sys.argv[1:])) 322 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698