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

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: formatting Created 4 years, 8 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 # lld-link includes a replacement for lib.exe that can produce thin 74 # lld-link includes a replacement for lib.exe that can produce thin
75 # archives and understands bitcode (for lto builds). 75 # archives and understands bitcode (for lto builds).
76 lib = "$prefix/$lld_link /lib /llvmlibthin" 76 lib = "$prefix/$lld_link /lib /llvmlibthin"
77 link = "$prefix/$lld_link" 77 link = "$prefix/$lld_link"
78 } else { 78 } else {
79 lib = "lib.exe" 79 lib = "lib.exe"
80 link = "link.exe" 80 link = "link.exe"
81 } 81 }
82 82
83 # If possible, pass system includes as flags to the compiler. When that's
84 # not possible, load a full environment file (containing %INCLUDE% and
85 # %PATH%) -- e.g. 32-bit MSVS builds require %PATH% to be set and just passing
86 # in a list of include directories isn't enough.
87 if (defined(invoker.sys_include_flags)) {
88 env_wrapper = ""
89 sys_include_flags = "${invoker.sys_include_flags} " # Note trailing space.
90 } else {
91 # clang-cl doesn't need this env hoop, so omit it there.
92 assert(!invoker.is_clang)
93 env_wrapper = "ninja -t msvc -e $env -- " # Note trailing space.
94 sys_include_flags = ""
95 }
96
83 toolchain(target_name) { 97 toolchain(target_name) {
84 # Make these apply to all tools below. 98 # Make these apply to all tools below.
85 lib_switch = "" 99 lib_switch = ""
86 lib_dir_switch = "/LIBPATH:" 100 lib_dir_switch = "/LIBPATH:"
87 101
88 # Object files go in this directory. 102 # Object files go in this directory.
89 object_subdir = "{{target_out_dir}}/{{label_name}}" 103 object_subdir = "{{target_out_dir}}/{{label_name}}"
90 104
91 tool("cc") { 105 tool("cc") {
92 rspfile = "{{output}}.rsp" 106 rspfile = "{{output}}.rsp"
93 precompiled_header_type = "msvc" 107 precompiled_header_type = "msvc"
94 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" 108 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
95 109
96 # Label names may have spaces in them so the pdbname must be quoted. The 110 # Label names may have spaces in them so the pdbname must be quoted. The
97 # source and output don't need to be quoted because GN knows they're a 111 # source and output don't need to be quoted because GN knows they're a
98 # full file name and will quote automatically when necessary. 112 # full file name and will quote automatically when necessary.
99 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil e /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" 113 command = "$env_wrapper$cl /nologo /showIncludes /FC @$rspfile /c {{source }} /Fo{{output}} /Fd\"$pdbname\""
100 depsformat = "msvc" 114 depsformat = "msvc"
101 description = "CC {{output}}" 115 description = "CC {{output}}"
102 outputs = [ 116 outputs = [
103 "$object_subdir/{{source_name_part}}.obj", 117 "$object_subdir/{{source_name_part}}.obj",
104 ] 118 ]
105 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" 119 rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags }} {{cflags_c}}"
106 } 120 }
107 121
108 tool("cxx") { 122 tool("cxx") {
109 rspfile = "{{output}}.rsp" 123 rspfile = "{{output}}.rsp"
110 precompiled_header_type = "msvc" 124 precompiled_header_type = "msvc"
111 125
112 # The PDB name needs to be different between C and C++ compiled files. 126 # The PDB name needs to be different between C and C++ compiled files.
113 pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb" 127 pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb"
114 128
115 # See comment in CC tool about quoting. 129 # See comment in CC tool about quoting.
116 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil e /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" 130 command = "$env_wrapper$cl /nologo /showIncludes /FC @$rspfile /c {{source }} /Fo{{output}} /Fd\"$pdbname\""
117 depsformat = "msvc" 131 depsformat = "msvc"
118 description = "CXX {{output}}" 132 description = "CXX {{output}}"
119 outputs = [ 133 outputs = [
120 "$object_subdir/{{source_name_part}}.obj", 134 "$object_subdir/{{source_name_part}}.obj",
121 ] 135 ]
122 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" 136 rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags }} {{cflags_cc}}"
123 } 137 }
124 138
125 tool("rc") { 139 tool("rc") {
126 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{ include_dirs}} /fo{{output}} {{source}}" 140 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{ include_dirs}} /fo{{output}} {{source}}"
127 outputs = [ 141 outputs = [
128 "$object_subdir/{{source_name_part}}.res", 142 "$object_subdir/{{source_name_part}}.res",
129 ] 143 ]
130 description = "RC {{output}}" 144 description = "RC {{output}}"
131 } 145 }
132 146
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 "is_clang", 262 "is_clang",
249 "is_component_build", 263 "is_component_build",
250 ]) 264 ])
251 265
252 # This value needs to be passed through unchanged. 266 # This value needs to be passed through unchanged.
253 host_toolchain = host_toolchain 267 host_toolchain = host_toolchain
254 } 268 }
255 } 269 }
256 } 270 }
257 271
272 if (is_clang) {
273 sys_include_prefix = "-imsvc"
274 } else {
275 # MSVC doesn't have the concept of system headers.
276 sys_include_prefix = "/I"
277 }
278
258 if (host_os == "win") { 279 if (host_os == "win") {
259 clang_cl = "clang-cl.exe" 280 clang_cl = "clang-cl.exe"
260 } else { 281 } else {
261 clang_cl = "clang-cl" 282 clang_cl = "clang-cl"
262 } 283 }
263 284
264 # 32-bit toolchains. Only define these when the target architecture is 32-bit 285 # 32-bit toolchains. Only define these when the target architecture is 32-bit
265 # since we don't do any 32-bit cross compiles when targeting 64-bit (the 286 # since we don't do any 32-bit cross compiles when targeting 64-bit (the
266 # build does generate some 64-bit stuff from 32-bit target builds). 287 # build does generate some 64-bit stuff from 32-bit target builds).
267 if (target_cpu == "x86") { 288 if (target_cpu == "x86") {
268 x86_toolchain_data = exec_script("setup_toolchain.py", 289 x86_toolchain_data = exec_script("setup_toolchain.py",
269 [ 290 [
270 visual_studio_path, 291 visual_studio_path,
271 gyp_win_tool_path, 292 gyp_win_tool_path,
272 windows_sdk_path, 293 windows_sdk_path,
273 visual_studio_runtime_dirs, 294 visual_studio_runtime_dirs,
274 "x86", 295 "x86",
296 "${sys_include_prefix}",
275 ], 297 ],
276 "scope") 298 "scope")
277 299
278 msvc_toolchain("x86") { 300 msvc_toolchain("x86") {
279 environment = "environment.x86" 301 environment = "environment.x86"
280 toolchain_cpu = "x86" 302 toolchain_cpu = "x86"
281 cl = "${goma_prefix}\"${x86_toolchain_data.vc_bin_dir}/cl.exe\"" 303 cl = "${goma_prefix}\"${x86_toolchain_data.vc_bin_dir}/cl.exe\""
282 is_clang = false 304 is_clang = false
283 } 305 }
284 306
285 msvc_toolchain("clang_x86") { 307 msvc_toolchain("clang_x86") {
286 environment = "environment.x86" 308 environment = "environment.x86"
287 toolchain_cpu = "x86" 309 toolchain_cpu = "x86"
288 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", 310 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
289 root_build_dir) 311 root_build_dir)
290 cl = "${goma_prefix}$prefix/${clang_cl}" 312 cl = "${goma_prefix}$prefix/${clang_cl}"
291 toolchain_os = "win" 313 toolchain_os = "win"
292 is_clang = true 314 is_clang = true
315 sys_include_flags = "${x86_toolchain_data.include_flags}"
293 } 316 }
294 } 317 }
295 318
296 # 64-bit toolchains. 319 # 64-bit toolchains.
297 x64_toolchain_data = exec_script("setup_toolchain.py", 320 x64_toolchain_data = exec_script("setup_toolchain.py",
298 [ 321 [
299 visual_studio_path, 322 visual_studio_path,
300 gyp_win_tool_path, 323 gyp_win_tool_path,
301 windows_sdk_path, 324 windows_sdk_path,
302 visual_studio_runtime_dirs, 325 visual_studio_runtime_dirs,
303 "x64", 326 "x64",
327 "${sys_include_prefix}",
304 ], 328 ],
305 "scope") 329 "scope")
306 330
307 template("win_x64_toolchains") { 331 template("win_x64_toolchains") {
308 # TODO(mcgrathr): These assignments are only required because of 332 # TODO(mcgrathr): These assignments are only required because of
309 # crbug.com/395883. Drop them if that ever gets fixed in GN. 333 # crbug.com/395883. Drop them if that ever gets fixed in GN.
310 concurrent_links = invoker.concurrent_links 334 concurrent_links = invoker.concurrent_links
311 goma_prefix = invoker.goma_prefix 335 goma_prefix = invoker.goma_prefix
312 x64_toolchain_data = invoker.x64_toolchain_data 336 x64_toolchain_data = invoker.x64_toolchain_data
313 clang_cl = invoker.clang_cl 337 clang_cl = invoker.clang_cl
314 338
315 msvc_toolchain(target_name) { 339 msvc_toolchain(target_name) {
316 environment = "environment.x64" 340 environment = "environment.x64"
317 toolchain_cpu = "x64" 341 toolchain_cpu = "x64"
318 cl = "${goma_prefix}\"${x64_toolchain_data.vc_bin_dir}/cl.exe\"" 342 cl = "${goma_prefix}\"${x64_toolchain_data.vc_bin_dir}/cl.exe\""
319 is_clang = false 343 is_clang = false
320 344
321 forward_variables_from(invoker, [ "is_component_build" ]) 345 forward_variables_from(invoker, [ "is_component_build" ])
322 } 346 }
323 347
324 msvc_toolchain("clang_" + target_name) { 348 msvc_toolchain("clang_" + target_name) {
325 environment = "environment.x64" 349 environment = "environment.x64"
326 toolchain_cpu = "x64" 350 toolchain_cpu = "x64"
327 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", 351 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
328 root_build_dir) 352 root_build_dir)
329 cl = "${goma_prefix}$prefix/${clang_cl}" 353 cl = "${goma_prefix}$prefix/${clang_cl}"
330 toolchain_os = "win" 354 toolchain_os = "win"
331 is_clang = true 355 is_clang = true
356 sys_include_flags = "${x64_toolchain_data.include_flags}"
332 357
333 forward_variables_from(invoker, [ "is_component_build" ]) 358 forward_variables_from(invoker, [ "is_component_build" ])
334 } 359 }
335 } 360 }
336 361
337 win_x64_toolchains("x64") { 362 win_x64_toolchains("x64") {
338 # TODO(mcgrathr): These assignments are only required because of 363 # TODO(mcgrathr): These assignments are only required because of
339 # crbug.com/395883. Drop them if that ever gets fixed in GN. 364 # crbug.com/395883. Drop them if that ever gets fixed in GN.
340 concurrent_links = concurrent_links 365 concurrent_links = concurrent_links
341 goma_prefix = goma_prefix 366 goma_prefix = goma_prefix
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 401
377 msvc_toolchain("winrt_x64") { 402 msvc_toolchain("winrt_x64") {
378 environment = "environment.winrt_x64" 403 environment = "environment.winrt_x64"
379 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" 404 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\""
380 is_clang = false 405 is_clang = false
381 406
382 toolchain_cpu = "x64" 407 toolchain_cpu = "x64"
383 toolchain_os = current_os 408 toolchain_os = current_os
384 } 409 }
385 } 410 }
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