Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: build/toolchain/win/setup_toolchain.py

Issue 2728233002: win: Decide how to include system dirs at toolchain time instead of globally. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/win/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 CreateProcess documentation for more details.""" 145 CreateProcess documentation for more details."""
146 block = '' 146 block = ''
147 nul = '\0' 147 nul = '\0'
148 for key, value in envvar_dict.iteritems(): 148 for key, value in envvar_dict.iteritems():
149 block += key + '=' + value + nul 149 block += key + '=' + value + nul
150 block += nul 150 block += nul
151 return block 151 return block
152 152
153 153
154 def main(): 154 def main():
155 if len(sys.argv) != 6: 155 if len(sys.argv) != 5:
156 print('Usage setup_toolchain.py ' 156 print('Usage setup_toolchain.py '
157 '<visual studio path> <win sdk path> ' 157 '<visual studio path> <win sdk path> '
158 '<runtime dirs> <target_cpu> <include prefix>') 158 '<runtime dirs> <target_cpu> <include prefix>')
159 sys.exit(2) 159 sys.exit(2)
160 win_sdk_path = sys.argv[2] 160 win_sdk_path = sys.argv[2]
161 runtime_dirs = sys.argv[3] 161 runtime_dirs = sys.argv[3]
162 target_cpu = sys.argv[4] 162 target_cpu = sys.argv[4]
163 include_prefix = sys.argv[5]
164 163
165 cpus = ('x86', 'x64') 164 cpus = ('x86', 'x64')
166 assert target_cpu in cpus 165 assert target_cpu in cpus
167 vc_bin_dir = '' 166 vc_bin_dir = ''
168 include = '' 167 include = ''
169 168
170 # TODO(scottmg|goma): Do we need an equivalent of 169 # TODO(scottmg|goma): Do we need an equivalent of
171 # ninja_use_custom_environment_files? 170 # ninja_use_custom_environment_files?
172 171
173 for cpu in cpus: 172 for cpu in cpus:
174 # Extract environment variables for subprocesses. 173 # Extract environment variables for subprocesses.
175 env = _LoadToolchainEnv(cpu, win_sdk_path) 174 env = _LoadToolchainEnv(cpu, win_sdk_path)
176 env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] 175 env['PATH'] = runtime_dirs + os.pathsep + env['PATH']
177 176
178 if cpu == target_cpu: 177 if cpu == target_cpu:
179 for path in env['PATH'].split(os.pathsep): 178 for path in env['PATH'].split(os.pathsep):
180 if os.path.exists(os.path.join(path, 'cl.exe')): 179 if os.path.exists(os.path.join(path, 'cl.exe')):
181 vc_bin_dir = os.path.realpath(path) 180 vc_bin_dir = os.path.realpath(path)
182 break 181 break
183 # The separator for INCLUDE here must match the one used in 182 # The separator for INCLUDE here must match the one used in
184 # _LoadToolchainEnv() above. 183 # _LoadToolchainEnv() above.
185 include = [include_prefix + p for p in env['INCLUDE'].split(';') if p] 184 include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p]
186 include = ' '.join(['"' + i.replace('"', r'\"') + '"' for i in include]) 185 include_I = ' '.join(['"/I' + i + '"' for i in include])
186 include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include])
187 187
188 env_block = _FormatAsEnvironmentBlock(env) 188 env_block = _FormatAsEnvironmentBlock(env)
189 with open('environment.' + cpu, 'wb') as f: 189 with open('environment.' + cpu, 'wb') as f:
190 f.write(env_block) 190 f.write(env_block)
191 191
192 # Create a store app version of the environment. 192 # Create a store app version of the environment.
193 if 'LIB' in env: 193 if 'LIB' in env:
194 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') 194 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE')
195 if 'LIBPATH' in env: 195 if 'LIBPATH' in env:
196 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') 196 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE')
197 env_block = _FormatAsEnvironmentBlock(env) 197 env_block = _FormatAsEnvironmentBlock(env)
198 with open('environment.winrt_' + cpu, 'wb') as f: 198 with open('environment.winrt_' + cpu, 'wb') as f:
199 f.write(env_block) 199 f.write(env_block)
200 200
201 assert vc_bin_dir 201 assert vc_bin_dir
202 print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir) 202 print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir)
203 assert include 203 assert include_I
204 print 'include_flags = ' + gn_helpers.ToGNString(include) 204 print 'include_flags_I = ' + gn_helpers.ToGNString(include_I)
Nico 2017/03/03 22:17:48 this is currently not read anywhere, but if the MS
205 assert include_imsvc
206 print 'include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc)
205 207
206 if __name__ == '__main__': 208 if __name__ == '__main__':
207 main() 209 main()
OLDNEW
« no previous file with comments | « build/toolchain/win/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698