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