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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 # Add header and write it out to the current directory (which should be the | 149 # Add header and write it out to the current directory (which should be the |
150 # root build dir). | 150 # root build dir). |
151 with open("gyp-win-tool", 'w') as tool_file: | 151 with open("gyp-win-tool", 'w') as tool_file: |
152 tool_file.write(''.join([tool_source[0], | 152 tool_file.write(''.join([tool_source[0], |
153 '# Generated by setup_toolchain.py do not edit.\n'] | 153 '# Generated by setup_toolchain.py do not edit.\n'] |
154 + tool_source[1:])) | 154 + tool_source[1:])) |
155 | 155 |
156 | 156 |
157 def main(): | 157 def main(): |
158 if len(sys.argv) != 6: | 158 if len(sys.argv) != 7: |
159 print('Usage setup_toolchain.py ' | 159 print('Usage setup_toolchain.py ' |
160 '<visual studio path> <win tool path> <win sdk path> ' | 160 '<visual studio path> <win tool path> <win sdk path> ' |
161 '<runtime dirs> <target_cpu>') | 161 '<runtime dirs> <target_cpu> <include prefix>') |
162 sys.exit(2) | 162 sys.exit(2) |
163 tool_source = sys.argv[2] | 163 tool_source = sys.argv[2] |
164 win_sdk_path = sys.argv[3] | 164 win_sdk_path = sys.argv[3] |
165 runtime_dirs = sys.argv[4] | 165 runtime_dirs = sys.argv[4] |
166 target_cpu = sys.argv[5] | 166 target_cpu = sys.argv[5] |
| 167 include_prefix = sys.argv[6] |
167 | 168 |
168 _CopyTool(tool_source) | 169 _CopyTool(tool_source) |
169 | 170 |
170 cpus = ('x86', 'x64') | 171 cpus = ('x86', 'x64') |
171 assert target_cpu in cpus | 172 assert target_cpu in cpus |
172 vc_bin_dir = '' | 173 vc_bin_dir = '' |
| 174 include = '' |
173 | 175 |
174 # TODO(scottmg|goma): Do we need an equivalent of | 176 # TODO(scottmg|goma): Do we need an equivalent of |
175 # ninja_use_custom_environment_files? | 177 # ninja_use_custom_environment_files? |
176 | 178 |
177 for cpu in cpus: | 179 for cpu in cpus: |
178 # Extract environment variables for subprocesses. | 180 # Extract environment variables for subprocesses. |
179 env = _LoadToolchainEnv(cpu, win_sdk_path) | 181 env = _LoadToolchainEnv(cpu, win_sdk_path) |
180 env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] | 182 env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] |
181 | 183 |
182 if cpu == target_cpu: | 184 if cpu == target_cpu: |
183 for path in env['PATH'].split(os.pathsep): | 185 for path in env['PATH'].split(os.pathsep): |
184 if os.path.exists(os.path.join(path, 'cl.exe')): | 186 if os.path.exists(os.path.join(path, 'cl.exe')): |
185 vc_bin_dir = os.path.realpath(path) | 187 vc_bin_dir = os.path.realpath(path) |
186 break | 188 break |
| 189 include = ' '.join([include_prefix + p |
| 190 for p in env['INCLUDE'].split(';')]) |
187 | 191 |
188 env_block = _FormatAsEnvironmentBlock(env) | 192 env_block = _FormatAsEnvironmentBlock(env) |
189 with open('environment.' + cpu, 'wb') as f: | 193 with open('environment.' + cpu, 'wb') as f: |
190 f.write(env_block) | 194 f.write(env_block) |
191 | 195 |
192 # Create a store app version of the environment. | 196 # Create a store app version of the environment. |
193 if 'LIB' in env: | 197 if 'LIB' in env: |
194 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') | 198 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') |
195 if 'LIBPATH' in env: | 199 if 'LIBPATH' in env: |
196 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') | 200 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') |
197 env_block = _FormatAsEnvironmentBlock(env) | 201 env_block = _FormatAsEnvironmentBlock(env) |
198 with open('environment.winrt_' + cpu, 'wb') as f: | 202 with open('environment.winrt_' + cpu, 'wb') as f: |
199 f.write(env_block) | 203 f.write(env_block) |
200 | 204 |
201 assert vc_bin_dir | 205 assert vc_bin_dir |
| 206 assert '"' not in vc_bin_dir |
202 print 'vc_bin_dir = "%s"' % vc_bin_dir | 207 print 'vc_bin_dir = "%s"' % vc_bin_dir |
203 | 208 assert include |
| 209 assert '"' not in include |
| 210 print 'include_flags = "%s"' % include |
204 | 211 |
205 if __name__ == '__main__': | 212 if __name__ == '__main__': |
206 main() | 213 main() |
OLD | NEW |