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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 # Check that the json file contained the same environment as the .cmd file. | 111 # Check that the json file contained the same environment as the .cmd file. |
112 if sys.platform in ('win32', 'cygwin'): | 112 if sys.platform in ('win32', 'cygwin'): |
113 script = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.cmd')) | 113 script = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.cmd')) |
114 assert _ExtractImportantEnvironment(variables) == \ | 114 assert _ExtractImportantEnvironment(variables) == \ |
115 _ExtractImportantEnvironment(_LoadEnvFromBat([script, '/' + cpu])) | 115 _ExtractImportantEnvironment(_LoadEnvFromBat([script, '/' + cpu])) |
116 else: | 116 else: |
117 if 'GYP_MSVS_OVERRIDE_PATH' not in os.environ: | 117 if 'GYP_MSVS_OVERRIDE_PATH' not in os.environ: |
118 os.environ['GYP_MSVS_OVERRIDE_PATH'] = _DetectVisualStudioPath() | 118 os.environ['GYP_MSVS_OVERRIDE_PATH'] = _DetectVisualStudioPath() |
119 # We only support x64-hosted tools. | 119 # We only support x64-hosted tools. |
120 args = [os.path.normpath(os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'], | 120 script_path = os.path.normpath(os.path.join( |
121 'VC/vcvarsall.bat')), | 121 os.environ['GYP_MSVS_OVERRIDE_PATH'], |
122 'amd64_x86' if cpu == 'x86' else 'amd64'] | 122 'VC/vcvarsall.bat')) |
| 123 if not os.path.exists(script_path): |
| 124 raise Exception('%s is missing - make sure VC++ tools are installed.' % |
| 125 script_path) |
| 126 args = [script_path, 'amd64_x86' if cpu == 'x86' else 'amd64'] |
123 variables = _LoadEnvFromBat(args) | 127 variables = _LoadEnvFromBat(args) |
124 return _ExtractImportantEnvironment(variables) | 128 return _ExtractImportantEnvironment(variables) |
125 | 129 |
126 | 130 |
127 def _FormatAsEnvironmentBlock(envvar_dict): | 131 def _FormatAsEnvironmentBlock(envvar_dict): |
128 """Format as an 'environment block' directly suitable for CreateProcess. | 132 """Format as an 'environment block' directly suitable for CreateProcess. |
129 Briefly this is a list of key=value\0, terminated by an additional \0. See | 133 Briefly this is a list of key=value\0, terminated by an additional \0. See |
130 CreateProcess documentation for more details.""" | 134 CreateProcess documentation for more details.""" |
131 block = '' | 135 block = '' |
132 nul = '\0' | 136 nul = '\0' |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 env_block = _FormatAsEnvironmentBlock(env) | 197 env_block = _FormatAsEnvironmentBlock(env) |
194 with open('environment.winrt_' + cpu, 'wb') as f: | 198 with open('environment.winrt_' + cpu, 'wb') as f: |
195 f.write(env_block) | 199 f.write(env_block) |
196 | 200 |
197 assert vc_bin_dir | 201 assert vc_bin_dir |
198 print 'vc_bin_dir = "%s"' % vc_bin_dir | 202 print 'vc_bin_dir = "%s"' % vc_bin_dir |
199 | 203 |
200 | 204 |
201 if __name__ == '__main__': | 205 if __name__ == '__main__': |
202 main() | 206 main() |
OLD | NEW |