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

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

Issue 1970443002: win toolchain: Always use ; for all env vars except PATH, even on non-Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 7 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 | « no previous file | 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 # the setup script from the SDK if so. |cpu| should be either 88 # the setup script from the SDK if so. |cpu| should be either
89 # 'x86' or 'x64'. 89 # 'x86' or 'x64'.
90 assert cpu in ('x86', 'x64') 90 assert cpu in ('x86', 'x64')
91 if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir: 91 if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir:
92 # Load environment from json file. 92 # Load environment from json file.
93 env = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.%s.json' % cpu)) 93 env = os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.%s.json' % cpu))
94 env = json.load(open(env))['env'] 94 env = json.load(open(env))['env']
95 for k in env: 95 for k in env:
96 entries = [os.path.join(*([os.path.join(sdk_dir, 'bin')] + e)) 96 entries = [os.path.join(*([os.path.join(sdk_dir, 'bin')] + e))
97 for e in env[k]] 97 for e in env[k]]
98 env[k] = os.pathsep.join(entries) 98 # clang-cl wants INCLUDE to be ;-separated even on non-Windows,
99 # lld-link wants LIB to be ;-separated even on non-Windows. Path gets :.
100 # The separator for INCLUDE here must match the one used in main() below.
101 sep = os.pathsep if k == 'PATH' else ';'
102 env[k] = sep.join(entries)
99 # PATH is a bit of a special case, it's in addition to the current PATH. 103 # PATH is a bit of a special case, it's in addition to the current PATH.
100 env['PATH'] = env['PATH'] + os.pathsep + os.environ['PATH'] 104 env['PATH'] = env['PATH'] + os.pathsep + os.environ['PATH']
101 # Augment with the current env to pick up TEMP and friends. 105 # Augment with the current env to pick up TEMP and friends.
102 for k in os.environ: 106 for k in os.environ:
103 if k not in env: 107 if k not in env:
104 env[k] = os.environ[k] 108 env[k] = os.environ[k]
105 109
106 varlines = [] 110 varlines = []
107 for k in sorted(env.keys()): 111 for k in sorted(env.keys()):
108 varlines.append('%s=%s' % (str(k), str(env[k]))) 112 varlines.append('%s=%s' % (str(k), str(env[k])))
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 for cpu in cpus: 195 for cpu in cpus:
192 # Extract environment variables for subprocesses. 196 # Extract environment variables for subprocesses.
193 env = _LoadToolchainEnv(cpu, win_sdk_path) 197 env = _LoadToolchainEnv(cpu, win_sdk_path)
194 env['PATH'] = runtime_dirs + os.pathsep + env['PATH'] 198 env['PATH'] = runtime_dirs + os.pathsep + env['PATH']
195 199
196 if cpu == target_cpu: 200 if cpu == target_cpu:
197 for path in env['PATH'].split(os.pathsep): 201 for path in env['PATH'].split(os.pathsep):
198 if os.path.exists(os.path.join(path, 'cl.exe')): 202 if os.path.exists(os.path.join(path, 'cl.exe')):
199 vc_bin_dir = os.path.realpath(path) 203 vc_bin_dir = os.path.realpath(path)
200 break 204 break
205 # The separator for INCLUDE here must match the one used in
206 # _LoadToolchainEnv() above.
201 include = ' '.join([include_prefix + p 207 include = ' '.join([include_prefix + p
202 for p in env['INCLUDE'].split(';')]) 208 for p in env['INCLUDE'].split(';')])
203 209
204 env_block = _FormatAsEnvironmentBlock(env) 210 env_block = _FormatAsEnvironmentBlock(env)
205 with open('environment.' + cpu, 'wb') as f: 211 with open('environment.' + cpu, 'wb') as f:
206 f.write(env_block) 212 f.write(env_block)
207 213
208 # Create a store app version of the environment. 214 # Create a store app version of the environment.
209 if 'LIB' in env: 215 if 'LIB' in env:
210 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') 216 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE')
211 if 'LIBPATH' in env: 217 if 'LIBPATH' in env:
212 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') 218 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE')
213 env_block = _FormatAsEnvironmentBlock(env) 219 env_block = _FormatAsEnvironmentBlock(env)
214 with open('environment.winrt_' + cpu, 'wb') as f: 220 with open('environment.winrt_' + cpu, 'wb') as f:
215 f.write(env_block) 221 f.write(env_block)
216 222
217 assert vc_bin_dir 223 assert vc_bin_dir
218 assert '"' not in vc_bin_dir 224 assert '"' not in vc_bin_dir
219 print 'vc_bin_dir = "%s"' % vc_bin_dir 225 print 'vc_bin_dir = "%s"' % vc_bin_dir
220 assert include 226 assert include
221 assert '"' not in include 227 assert '"' not in include
222 print 'include_flags = "%s"' % include 228 print 'include_flags = "%s"' % include
223 229
224 if __name__ == '__main__': 230 if __name__ == '__main__':
225 main() 231 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698