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 for line in link.stdout: |
138 if (not line.startswith(' Creating library ') and | 139 if (not line.startswith(' Creating library ') and |
139 not line.startswith('Generating code') and | 140 not line.startswith('Generating code') and |
140 not line.startswith('Finished generating code')): | 141 not line.startswith('Finished generating code')): |
141 print line | 142 print line, |
142 return link.returncode | 143 return link.wait() |
143 | 144 |
144 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, | 145 def ExecLinkWithManifests(self, arch, embed_manifest, out, ldcmd, resname, |
145 mt, rc, intermediate_manifest, *manifests): | 146 mt, rc, intermediate_manifest, *manifests): |
146 """A wrapper for handling creating a manifest resource and then executing | 147 """A wrapper for handling creating a manifest resource and then executing |
147 a link command.""" | 148 a link command.""" |
148 # The 'normal' way to do manifests is to have link generate a manifest | 149 # 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 | 150 # based on gathering dependencies from the object files, then merge that |
150 # manifest with other manifests supplied as sources, convert the merged | 151 # manifest with other manifests supplied as sources, convert the merged |
151 # manifest to a resource, and then *relink*, including the compiled | 152 # manifest to a resource, and then *relink*, including the compiled |
152 # version of the manifest resource. This breaks incremental linking, and | 153 # version of the manifest resource. This breaks incremental linking, and |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 project_dir = os.path.relpath(project_dir, BASE_DIR) | 321 project_dir = os.path.relpath(project_dir, BASE_DIR) |
321 selected_files = selected_files.split(';') | 322 selected_files = selected_files.split(';') |
322 ninja_targets = [os.path.join(project_dir, filename) + '^^' | 323 ninja_targets = [os.path.join(project_dir, filename) + '^^' |
323 for filename in selected_files] | 324 for filename in selected_files] |
324 cmd = ['ninja.exe'] | 325 cmd = ['ninja.exe'] |
325 cmd.extend(ninja_targets) | 326 cmd.extend(ninja_targets) |
326 return subprocess.call(cmd, shell=True, cwd=BASE_DIR) | 327 return subprocess.call(cmd, shell=True, cwd=BASE_DIR) |
327 | 328 |
328 if __name__ == '__main__': | 329 if __name__ == '__main__': |
329 sys.exit(main(sys.argv[1:])) | 330 sys.exit(main(sys.argv[1:])) |
OLD | NEW |