OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. 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 """Utility functions for Windows builds. | 5 """Utility functions for Windows builds. |
6 | 6 |
7 This file is copied to the build directory as part of toolchain setup and | 7 This file is copied to the build directory as part of toolchain setup and |
8 is used to set up calls to tools used by the build that need wrappers. | 8 is used to set up calls to tools used by the build that need wrappers. |
9 """ | 9 """ |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 # https://docs.python.org/2/library/subprocess.html: | 126 # https://docs.python.org/2/library/subprocess.html: |
127 # "On Unix with shell=True [...] if args is a sequence, the first item | 127 # "On Unix with shell=True [...] if args is a sequence, the first item |
128 # specifies the command string, and any additional items will be treated as | 128 # specifies the command string, and any additional items will be treated as |
129 # additional arguments to the shell itself. That is to say, Popen does the | 129 # additional arguments to the shell itself. That is to say, Popen does the |
130 # equivalent of: | 130 # equivalent of: |
131 # Popen(['/bin/sh', '-c', args[0], args[1], ...])" | 131 # Popen(['/bin/sh', '-c', args[0], args[1], ...])" |
132 # For that reason, since going through the shell doesn't seem necessary on | 132 # For that reason, since going through the shell doesn't seem necessary on |
133 # non-Windows don't do that there. | 133 # non-Windows don't do that there. |
134 link = subprocess.Popen(args, shell=sys.platform == 'win32', env=env, | 134 link = subprocess.Popen(args, shell=sys.platform == 'win32', env=env, |
135 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 135 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
136 out, _ = link.communicate() | 136 # Read output one line at a time as it shows up to avoid OOM failures when |
137 for line in out.splitlines(): | 137 # GBs of output is produced. |
138 while True: | |
139 line = link.stdout.readline() | |
140 if len(line) == 0: # Read of zero bytes means EOF | |
scottmg
2016/12/07 22:20:56
I'm not sure about the loop termination...
for li
brucedawson
2016/12/07 23:00:24
Agreed. I started with a solution that read stderr
| |
141 break | |
138 if (not line.startswith(' Creating library ') and | 142 if (not line.startswith(' Creating library ') and |
139 not line.startswith('Generating code') and | 143 not line.startswith('Generating code') and |
140 not line.startswith('Finished generating code')): | 144 not line.startswith('Finished generating code')): |
141 print line | 145 print line, |
146 link.wait() | |
142 return link.returncode | 147 return link.returncode |
143 | 148 |
144 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, | 149 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, |
145 mt, rc, intermediate_manifest, *manifests): | 150 mt, rc, intermediate_manifest, *manifests): |
146 """A wrapper for handling creating a manifest resource and then executing | 151 """A wrapper for handling creating a manifest resource and then executing |
147 a link command.""" | 152 a link command.""" |
148 # The 'normal' way to do manifests is to have link generate a manifest | 153 # The 'normal' way to do manifests is to have link generate a manifest |
149 # based on gathering dependencies from the object files, then merge that | 154 # based on gathering dependencies from the object files, then merge that |
150 # manifest with other manifests supplied as sources, convert the merged | 155 # manifest with other manifests supplied as sources, convert the merged |
151 # manifest to a resource, and then *relink*, including the compiled | 156 # manifest to a resource, and then *relink*, including the compiled |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 project_dir = os.path.relpath(project_dir, BASE_DIR) | 325 project_dir = os.path.relpath(project_dir, BASE_DIR) |
321 selected_files = selected_files.split(';') | 326 selected_files = selected_files.split(';') |
322 ninja_targets = [os.path.join(project_dir, filename) + '^^' | 327 ninja_targets = [os.path.join(project_dir, filename) + '^^' |
323 for filename in selected_files] | 328 for filename in selected_files] |
324 cmd = ['ninja.exe'] | 329 cmd = ['ninja.exe'] |
325 cmd.extend(ninja_targets) | 330 cmd.extend(ninja_targets) |
326 return subprocess.call(cmd, shell=True, cwd=BASE_DIR) | 331 return subprocess.call(cmd, shell=True, cwd=BASE_DIR) |
327 | 332 |
328 if __name__ == '__main__': | 333 if __name__ == '__main__': |
329 sys.exit(main(sys.argv[1:])) | 334 sys.exit(main(sys.argv[1:])) |
OLD | NEW |