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

Side by Side Diff: build/toolchain/win/BUILD.gn

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: foo 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
« no previous file with comments | « no previous file | build/toolchain/win/setup_toolchain.py » ('j') | 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 import("//build/config/sanitizers/sanitizers.gni") 5 import("//build/config/sanitizers/sanitizers.gni")
6 import("//build/config/win/visual_studio_version.gni") 6 import("//build/config/win/visual_studio_version.gni")
7 import("//build/toolchain/goma.gni") 7 import("//build/toolchain/goma.gni")
8 import("//build/toolchain/toolchain.gni") 8 import("//build/toolchain/toolchain.gni")
9 9
10 # Should only be running on Windows. 10 # Should only be running on Windows.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 # environment: File name of environment file. 55 # environment: File name of environment file.
56 template("msvc_toolchain") { 56 template("msvc_toolchain") {
57 if (defined(invoker.concurrent_links)) { 57 if (defined(invoker.concurrent_links)) {
58 concurrent_links = invoker.concurrent_links 58 concurrent_links = invoker.concurrent_links
59 } 59 }
60 60
61 env = invoker.environment 61 env = invoker.environment
62 62
63 cl = invoker.cl 63 cl = invoker.cl
64 64
65 # If possible, pass system includes as flags to the compiler. When that's
66 # not possible, load a full environment file (containing %INCLUDE% and
67 # %PATH%) -- e.g. 32-bit msvs builds require %PATH% to be set and just passing
68 # in a list of include directories isn't enough.
69 if (defined(invoker.sys_include_flags)) {
70 env_wrapper = ""
71 sys_include_flags = "${invoker.sys_include_flags} " # Note trailing space.
72 } else {
73 assert(!is_clang) # clang-cl doesn't need this env hoop, so omit it there.
scottmg 2016/02/26 03:32:03 Should this be invoker.is_clang?
Nico 2016/02/26 15:16:26 Oh, good catch, thanks, done! That's what I get fo
74 env_wrapper = "ninja -t msvc -e $env -- " # Note trailing space.
75 sys_include_flags = ""
76 }
77
65 toolchain(target_name) { 78 toolchain(target_name) {
66 # Make these apply to all tools below. 79 # Make these apply to all tools below.
67 lib_switch = "" 80 lib_switch = ""
68 lib_dir_switch = "/LIBPATH:" 81 lib_dir_switch = "/LIBPATH:"
69 82
70 # Object files go in this directory. 83 # Object files go in this directory.
71 object_subdir = "{{target_out_dir}}/{{label_name}}" 84 object_subdir = "{{target_out_dir}}/{{label_name}}"
72 85
73 tool("cc") { 86 tool("cc") {
74 rspfile = "{{output}}.rsp" 87 rspfile = "{{output}}.rsp"
75 precompiled_header_type = "msvc" 88 precompiled_header_type = "msvc"
76 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" 89 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
77 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil e /c {{source}} /Fo{{output}} /Fd$pdbname" 90 command = "$env_wrapper$cl /nologo /showIncludes /FC @$rspfile /c {{source }} /Fo{{output}} /Fd$pdbname"
78 depsformat = "msvc" 91 depsformat = "msvc"
79 description = "CC {{output}}" 92 description = "CC {{output}}"
80 outputs = [ 93 outputs = [
81 "$object_subdir/{{source_name_part}}.obj", 94 "$object_subdir/{{source_name_part}}.obj",
82 ] 95 ]
83 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" 96 rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags }} {{cflags_c}}"
84 } 97 }
85 98
86 tool("cxx") { 99 tool("cxx") {
87 rspfile = "{{output}}.rsp" 100 rspfile = "{{output}}.rsp"
88 precompiled_header_type = "msvc" 101 precompiled_header_type = "msvc"
89 102
90 # The PDB name needs to be different between C and C++ compiled files. 103 # The PDB name needs to be different between C and C++ compiled files.
91 pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb" 104 pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb"
92 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil e /c {{source}} /Fo{{output}} /Fd$pdbname" 105 command = "$env_wrapper$cl /nologo /showIncludes /FC @$rspfile /c {{source }} /Fo{{output}} /Fd$pdbname"
93 depsformat = "msvc" 106 depsformat = "msvc"
94 description = "CXX {{output}}" 107 description = "CXX {{output}}"
95 outputs = [ 108 outputs = [
96 "$object_subdir/{{source_name_part}}.obj", 109 "$object_subdir/{{source_name_part}}.obj",
97 ] 110 ]
98 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" 111 rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags }} {{cflags_cc}}"
99 } 112 }
100 113
101 tool("rc") { 114 tool("rc") {
102 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{ include_dirs}} /fo{{output}} {{source}}" 115 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{ include_dirs}} /fo{{output}} {{source}}"
103 outputs = [ 116 outputs = [
104 "$object_subdir/{{source_name_part}}.res", 117 "$object_subdir/{{source_name_part}}.res",
105 ] 118 ]
106 description = "RC {{output}}" 119 description = "RC {{output}}"
107 } 120 }
108 121
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 "is_clang", 245 "is_clang",
233 "is_component_build", 246 "is_component_build",
234 ]) 247 ])
235 248
236 # This value needs to be passed through unchanged. 249 # This value needs to be passed through unchanged.
237 host_toolchain = host_toolchain 250 host_toolchain = host_toolchain
238 } 251 }
239 } 252 }
240 } 253 }
241 254
255 if (is_clang) {
256 sys_include_prefix = "-isystem="
257 } else {
258 # MSVC doesn't have the concept of system headers.
259 sys_include_prefix = "/I"
260 }
261
242 if (host_os == "win") { 262 if (host_os == "win") {
243 clang_cl = "clang-cl.exe" 263 clang_cl = "clang-cl.exe"
244 } else { 264 } else {
245 clang_cl = "clang-cl" 265 clang_cl = "clang-cl"
246 } 266 }
247 267
248 # 32-bit toolchains. Only define these when the target architecture is 32-bit 268 # 32-bit toolchains. Only define these when the target architecture is 32-bit
249 # since we don't do any 32-bit cross compiles when targeting 64-bit (the 269 # since we don't do any 32-bit cross compiles when targeting 64-bit (the
250 # build does generate some 64-bit stuff from 32-bit target builds). 270 # build does generate some 64-bit stuff from 32-bit target builds).
251 if (target_cpu == "x86") { 271 if (target_cpu == "x86") {
252 x86_toolchain_data = exec_script("setup_toolchain.py", 272 x86_toolchain_data = exec_script("setup_toolchain.py",
253 [ 273 [
254 visual_studio_path, 274 visual_studio_path,
255 gyp_win_tool_path, 275 gyp_win_tool_path,
256 windows_sdk_path, 276 windows_sdk_path,
257 visual_studio_runtime_dirs, 277 visual_studio_runtime_dirs,
258 "x86", 278 "x86",
279 "${sys_include_prefix}",
259 ], 280 ],
260 "scope") 281 "scope")
261 282
262 msvc_toolchain("x86") { 283 msvc_toolchain("x86") {
263 environment = "environment.x86" 284 environment = "environment.x86"
264 toolchain_cpu = "x86" 285 toolchain_cpu = "x86"
265 cl = "${goma_prefix}\"${x86_toolchain_data.vc_bin_dir}/cl.exe\"" 286 cl = "${goma_prefix}\"${x86_toolchain_data.vc_bin_dir}/cl.exe\""
266 is_clang = false 287 is_clang = false
267 } 288 }
268 289
269 msvc_toolchain("clang_x86") { 290 msvc_toolchain("clang_x86") {
270 environment = "environment.x86" 291 environment = "environment.x86"
271 toolchain_cpu = "x86" 292 toolchain_cpu = "x86"
272 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", 293 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
273 root_build_dir) 294 root_build_dir)
274 cl = "${goma_prefix}$prefix/${clang_cl}" 295 cl = "${goma_prefix}$prefix/${clang_cl}"
275 toolchain_os = "win" 296 toolchain_os = "win"
276 is_clang = true 297 is_clang = true
298 sys_include_flags = "${x86_toolchain_data.include_flags}"
277 } 299 }
278 } 300 }
279 301
280 # 64-bit toolchains. 302 # 64-bit toolchains.
281 x64_toolchain_data = exec_script("setup_toolchain.py", 303 x64_toolchain_data = exec_script("setup_toolchain.py",
282 [ 304 [
283 visual_studio_path, 305 visual_studio_path,
284 gyp_win_tool_path, 306 gyp_win_tool_path,
285 windows_sdk_path, 307 windows_sdk_path,
286 visual_studio_runtime_dirs, 308 visual_studio_runtime_dirs,
287 "x64", 309 "x64",
310 "${sys_include_prefix}",
288 ], 311 ],
289 "scope") 312 "scope")
290 313
291 template("win_x64_toolchains") { 314 template("win_x64_toolchains") {
292 # TODO(mcgrathr): These assignments are only required because of 315 # TODO(mcgrathr): These assignments are only required because of
293 # crbug.com/395883. Drop them if that ever gets fixed in GN. 316 # crbug.com/395883. Drop them if that ever gets fixed in GN.
294 concurrent_links = invoker.concurrent_links 317 concurrent_links = invoker.concurrent_links
295 goma_prefix = invoker.goma_prefix 318 goma_prefix = invoker.goma_prefix
296 x64_toolchain_data = invoker.x64_toolchain_data 319 x64_toolchain_data = invoker.x64_toolchain_data
297 clang_cl = invoker.clang_cl 320 clang_cl = invoker.clang_cl
298 321
299 msvc_toolchain(target_name) { 322 msvc_toolchain(target_name) {
300 environment = "environment.x64" 323 environment = "environment.x64"
301 toolchain_cpu = "x64" 324 toolchain_cpu = "x64"
302 cl = "${goma_prefix}\"${x64_toolchain_data.vc_bin_dir}/cl.exe\"" 325 cl = "${goma_prefix}\"${x64_toolchain_data.vc_bin_dir}/cl.exe\""
303 is_clang = false 326 is_clang = false
304 327
305 forward_variables_from(invoker, [ "is_component_build" ]) 328 forward_variables_from(invoker, [ "is_component_build" ])
306 } 329 }
307 330
308 msvc_toolchain("clang_" + target_name) { 331 msvc_toolchain("clang_" + target_name) {
309 environment = "environment.x64" 332 environment = "environment.x64"
310 toolchain_cpu = "x64" 333 toolchain_cpu = "x64"
311 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", 334 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
312 root_build_dir) 335 root_build_dir)
313 cl = "${goma_prefix}$prefix/${clang_cl}" 336 cl = "${goma_prefix}$prefix/${clang_cl}"
314 toolchain_os = "win" 337 toolchain_os = "win"
315 is_clang = true 338 is_clang = true
339 sys_include_flags = "${x64_toolchain_data.include_flags}"
316 340
317 forward_variables_from(invoker, [ "is_component_build" ]) 341 forward_variables_from(invoker, [ "is_component_build" ])
318 } 342 }
319 } 343 }
320 344
321 win_x64_toolchains("x64") { 345 win_x64_toolchains("x64") {
322 # TODO(mcgrathr): These assignments are only required because of 346 # TODO(mcgrathr): These assignments are only required because of
323 # crbug.com/395883. Drop them if that ever gets fixed in GN. 347 # crbug.com/395883. Drop them if that ever gets fixed in GN.
324 concurrent_links = concurrent_links 348 concurrent_links = concurrent_links
325 goma_prefix = goma_prefix 349 goma_prefix = goma_prefix
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 384
361 msvc_toolchain("winrt_x64") { 385 msvc_toolchain("winrt_x64") {
362 environment = "environment.winrt_x64" 386 environment = "environment.winrt_x64"
363 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" 387 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\""
364 is_clang = false 388 is_clang = false
365 389
366 toolchain_cpu = "x64" 390 toolchain_cpu = "x64"
367 toolchain_os = current_os 391 toolchain_os = current_os
368 } 392 }
369 } 393 }
OLDNEW
« no previous file with comments | « no previous file | build/toolchain/win/setup_toolchain.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698