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

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

Issue 1724533002: clang/gn/win: Stop running the compiler through `ninja -t msvc -e environment.foo` (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: actually Created 4 years, 10 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
« build/toolchain/win/BUILD.gn ('K') | « 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 # Add header and write it out to the current directory (which should be the 120 # Add header and write it out to the current directory (which should be the
121 # root build dir). 121 # root build dir).
122 with open("gyp-win-tool", 'w') as tool_file: 122 with open("gyp-win-tool", 'w') as tool_file:
123 tool_file.write(''.join([tool_source[0], 123 tool_file.write(''.join([tool_source[0],
124 '# Generated by setup_toolchain.py do not edit.\n'] 124 '# Generated by setup_toolchain.py do not edit.\n']
125 + tool_source[1:])) 125 + tool_source[1:]))
126 126
127 127
128 def main(): 128 def main():
129 if len(sys.argv) != 6: 129 if len(sys.argv) not in (6, 7):
130 print('Usage setup_toolchain.py ' 130 print('Usage setup_toolchain.py '
131 '<visual studio path> <win tool path> <win sdk path> ' 131 '<visual studio path> <win tool path> <win sdk path> '
132 '<runtime dirs> <target_cpu>') 132 '<runtime dirs> <target_cpu>, <include prefix>')
133 sys.exit(2) 133 sys.exit(2)
134 tool_source = sys.argv[2] 134 tool_source = sys.argv[2]
135 win_sdk_path = sys.argv[3] 135 win_sdk_path = sys.argv[3]
136 runtime_dirs = sys.argv[4] 136 runtime_dirs = sys.argv[4]
137 target_cpu = sys.argv[5] 137 target_cpu = sys.argv[5]
138 138
139 include_prefix = None
140 if len(sys.argv) > 6:
141 include_prefix = sys.argv[6]
142
139 _CopyTool(tool_source) 143 _CopyTool(tool_source)
140 144
141 cpus = ('x86', 'x64') 145 cpus = ('x86', 'x64')
142 assert target_cpu in cpus 146 assert target_cpu in cpus
143 vc_bin_dir = '' 147 vc_bin_dir = ''
148 include = ''
144 149
145 # TODO(scottmg|goma): Do we need an equivalent of 150 # TODO(scottmg|goma): Do we need an equivalent of
146 # ninja_use_custom_environment_files? 151 # ninja_use_custom_environment_files?
147 152
148 for cpu in cpus: 153 for cpu in cpus:
149 # Extract environment variables for subprocesses. 154 # Extract environment variables for subprocesses.
150 env = _LoadToolchainEnv(cpu, win_sdk_path) 155 env = _LoadToolchainEnv(cpu, win_sdk_path)
151 env['PATH'] = runtime_dirs + os.path.pathsep + env['PATH'] 156 env['PATH'] = runtime_dirs + os.path.pathsep + env['PATH']
152 157
153 if cpu == target_cpu: 158 if cpu == target_cpu:
154 for path in env['PATH'].split(os.pathsep): 159 for path in env['PATH'].split(os.pathsep):
155 if os.path.exists(os.path.join(path, 'cl.exe')): 160 if os.path.exists(os.path.join(path, 'cl.exe')):
156 vc_bin_dir = os.path.realpath(path) 161 vc_bin_dir = os.path.realpath(path)
157 break 162 break
163 if include_prefix:
164 include = ' '.join([include_prefix + p
165 for p in env['INCLUDE'].split(';')])
158 166
159 # The Windows SDK include directories must be first. They both have a sal.h, 167 # The Windows SDK include directories must be first. They both have a sal.h,
160 # and the SDK one is newer and the SDK uses some newer features from it not 168 # and the SDK one is newer and the SDK uses some newer features from it not
161 # present in the Visual Studio one. 169 # present in the Visual Studio one.
162 # Having the Windows SDK first is also the only way to control which SDK 170 # Having the Windows SDK first is also the only way to control which SDK
163 # version is used. 171 # version is used.
164 172
165 if win_sdk_path: 173 if win_sdk_path:
166 additional_includes = [ 174 additional_includes = [
167 os.path.join(win_sdk_path, 'Include', '10.0.10586.0', p) 175 os.path.join(win_sdk_path, 'Include', '10.0.10586.0', p)
168 for p in ['shared', 'um', 'winrt']] 176 for p in ['shared', 'um', 'winrt']]
169 additional_includes = os.path.pathsep.join(additional_includes) 177 additional_includes = os.path.pathsep.join(additional_includes)
170 env['INCLUDE'] = additional_includes + os.path.pathsep + env['INCLUDE'] 178 env['INCLUDE'] = additional_includes + os.path.pathsep + env['INCLUDE']
171 env_block = _FormatAsEnvironmentBlock(env) 179 env_block = _FormatAsEnvironmentBlock(env)
172 with open('environment.' + cpu, 'wb') as f: 180 with open('environment.' + cpu, 'wb') as f:
173 f.write(env_block) 181 f.write(env_block)
174 182
175 # Create a store app version of the environment. 183 # Create a store app version of the environment.
176 if 'LIB' in env: 184 if 'LIB' in env:
177 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE') 185 env['LIB'] = env['LIB'] .replace(r'\VC\LIB', r'\VC\LIB\STORE')
178 if 'LIBPATH' in env: 186 if 'LIBPATH' in env:
179 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE') 187 env['LIBPATH'] = env['LIBPATH'].replace(r'\VC\LIB', r'\VC\LIB\STORE')
180 env_block = _FormatAsEnvironmentBlock(env) 188 env_block = _FormatAsEnvironmentBlock(env)
181 with open('environment.winrt_' + cpu, 'wb') as f: 189 with open('environment.winrt_' + cpu, 'wb') as f:
182 f.write(env_block) 190 f.write(env_block)
183 191
184 assert vc_bin_dir 192 assert vc_bin_dir
193 assert '"' not in vc_bin_dir
185 print 'vc_bin_dir = "%s"' % vc_bin_dir 194 print 'vc_bin_dir = "%s"' % vc_bin_dir
186 195 if include_prefix:
196 assert include
197 assert '"' not in include
198 print 'include_flags = "%s"' % include
187 199
188 if __name__ == '__main__': 200 if __name__ == '__main__':
189 main() 201 main()
OLDNEW
« build/toolchain/win/BUILD.gn ('K') | « build/toolchain/win/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698