OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 # Copies the given "win tool" (which the toolchain uses to wrap compiler | 5 # Copies the given "win tool" (which the toolchain uses to wrap compiler |
6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on | 6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on |
7 # Windows to the build directory. | 7 # Windows to the build directory. |
8 # | 8 # |
9 # The arguments are the visual studio install location and the location of the | 9 # The arguments are the visual studio install location and the location of the |
10 # win tool. The script assumes that the root build directory is the current dir | 10 # win tool. The script assumes that the root build directory is the current dir |
(...skipping 14 matching lines...) Expand all Loading... |
25 'include', | 25 'include', |
26 'lib', | 26 'lib', |
27 'libpath', | 27 'libpath', |
28 'path', | 28 'path', |
29 'pathext', | 29 'pathext', |
30 'systemroot', | 30 'systemroot', |
31 'temp', | 31 'temp', |
32 'tmp', | 32 'tmp', |
33 ) | 33 ) |
34 env = {} | 34 env = {} |
| 35 # This occasionally happens and leads to misleading SYSTEMROOT error messages |
| 36 # if not caught here. |
| 37 if output_of_set.count('=') == 0: |
| 38 raise Exception('Invalid output_of_set. Value is:\n%s' % output_of_set) |
35 for line in output_of_set.splitlines(): | 39 for line in output_of_set.splitlines(): |
36 for envvar in envvars_to_save: | 40 for envvar in envvars_to_save: |
37 if re.match(envvar + '=', line.lower()): | 41 if re.match(envvar + '=', line.lower()): |
38 var, setting = line.split('=', 1) | 42 var, setting = line.split('=', 1) |
39 if envvar == 'path': | 43 if envvar == 'path': |
40 # Our own rules (for running gyp-win-tool) and other actions in | 44 # Our own rules (for running gyp-win-tool) and other actions in |
41 # Chromium rely on python being in the path. Add the path to this | 45 # Chromium rely on python being in the path. Add the path to this |
42 # python here so that if it's not in the path when ninja is run | 46 # python here so that if it's not in the path when ninja is run |
43 # later, python will still be found. | 47 # later, python will still be found. |
44 setting = os.path.dirname(sys.executable) + os.pathsep + setting | 48 setting = os.path.dirname(sys.executable) + os.pathsep + setting |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 # TODO(scottmg|goma): Do we need an equivalent of | 120 # TODO(scottmg|goma): Do we need an equivalent of |
117 # ninja_use_custom_environment_files? | 121 # ninja_use_custom_environment_files? |
118 | 122 |
119 for cpu in cpus: | 123 for cpu in cpus: |
120 # Extract environment variables for subprocesses. | 124 # Extract environment variables for subprocesses. |
121 args = _SetupScript(cpu, win_sdk_path) | 125 args = _SetupScript(cpu, win_sdk_path) |
122 args.extend(('&&', 'set')) | 126 args.extend(('&&', 'set')) |
123 popen = subprocess.Popen( | 127 popen = subprocess.Popen( |
124 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 128 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
125 variables, _ = popen.communicate() | 129 variables, _ = popen.communicate() |
| 130 if popen.returncode != 0: |
| 131 raise Exception('"%s" failed with error %d' % (args, popen.returncode)) |
126 env = _ExtractImportantEnvironment(variables) | 132 env = _ExtractImportantEnvironment(variables) |
127 env['PATH'] = runtime_dirs + ';' + env['PATH'] | 133 env['PATH'] = runtime_dirs + ';' + env['PATH'] |
128 | 134 |
129 if cpu == target_cpu: | 135 if cpu == target_cpu: |
130 for path in env['PATH'].split(os.pathsep): | 136 for path in env['PATH'].split(os.pathsep): |
131 if os.path.exists(os.path.join(path, 'cl.exe')): | 137 if os.path.exists(os.path.join(path, 'cl.exe')): |
132 vc_bin_dir = os.path.realpath(path) | 138 vc_bin_dir = os.path.realpath(path) |
133 break | 139 break |
134 | 140 |
135 # The Windows SDK include directories must be first. They both have a sal.h, | 141 # The Windows SDK include directories must be first. They both have a sal.h, |
(...skipping 18 matching lines...) Expand all Loading... |
154 env_block = _FormatAsEnvironmentBlock(env) | 160 env_block = _FormatAsEnvironmentBlock(env) |
155 with open('environment.winrt_' + cpu, 'wb') as f: | 161 with open('environment.winrt_' + cpu, 'wb') as f: |
156 f.write(env_block) | 162 f.write(env_block) |
157 | 163 |
158 assert vc_bin_dir | 164 assert vc_bin_dir |
159 print 'vc_bin_dir = "%s"' % vc_bin_dir | 165 print 'vc_bin_dir = "%s"' % vc_bin_dir |
160 | 166 |
161 | 167 |
162 if __name__ == '__main__': | 168 if __name__ == '__main__': |
163 main() | 169 main() |
OLD | NEW |