OLD | NEW |
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2016 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 """Helper functions for gcc_toolchain.gni wrappers.""" | 5 """Helper functions for gcc_toolchain.gni wrappers.""" |
6 | 6 |
7 import os | 7 import os |
8 import re | 8 import re |
9 import subprocess | 9 import subprocess |
10 import shlex | 10 import shlex |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 lines = text.splitlines() | 85 lines = text.splitlines() |
86 for ln in lines: | 86 for ln in lines: |
87 match = _WHITELIST_RE.search(ln) | 87 match = _WHITELIST_RE.search(ln) |
88 if match: | 88 if match: |
89 resource_id = int(match.group('resource_id')) | 89 resource_id = int(match.group('resource_id')) |
90 used_resources.add(resource_id) | 90 used_resources.add(resource_id) |
91 | 91 |
92 return used_resources | 92 return used_resources |
93 | 93 |
94 | 94 |
95 def CaptureCommandStderr(command): | 95 def CaptureCommandStderr(command, env=None): |
96 """Returns the stderr of a command. | 96 """Returns the stderr of a command. |
97 | 97 |
98 Args: | 98 Args: |
99 args: A list containing the command and arguments. | 99 command: A list containing the command and arguments. |
100 cwd: The working directory from where the command should be made. | |
101 env: Environment variables for the new process. | 100 env: Environment variables for the new process. |
102 """ | 101 """ |
103 child = subprocess.Popen(command, stderr=subprocess.PIPE) | 102 child = subprocess.Popen(command, stderr=subprocess.PIPE, env=env) |
104 _, stderr = child.communicate() | 103 _, stderr = child.communicate() |
105 return child.returncode, stderr | 104 return child.returncode, stderr |
OLD | NEW |