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

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