Index: build/toolchain/win/BUILD.gn |
diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn |
index 1934e9b19ad43287d8435364e318d8dd0b4b3d8f..cf664b7349f7791834bdffd90ee37ad433c609ad 100644 |
--- a/build/toolchain/win/BUILD.gn |
+++ b/build/toolchain/win/BUILD.gn |
@@ -62,6 +62,18 @@ template("msvc_toolchain") { |
cl = invoker.cl |
+ # If possible, pass system includes as flags to the compiler. When that's |
+ # not possible, load a full environment file (containing %INCLUDE% and |
+ # %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.
|
+ # in a list of include directories isn't enough. |
+ 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
|
+ env_wrapper = "" |
+ sys_include_flags = "${invoker.sys_include_flags} " # Note trailing space. |
+ } else { |
+ env_wrapper = "ninja -t msvc -e $env -- " # Note trailing space. |
+ sys_include_flags = "" |
+ } |
+ |
toolchain(target_name) { |
# Make these apply to all tools below. |
lib_switch = "" |
@@ -74,13 +86,13 @@ template("msvc_toolchain") { |
rspfile = "{{output}}.rsp" |
precompiled_header_type = "msvc" |
pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" |
- command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname" |
+ command = "$env_wrapper$cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname" |
depsformat = "msvc" |
description = "CC {{output}}" |
outputs = [ |
"$object_subdir/{{source_name_part}}.obj", |
] |
- rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
+ rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
} |
tool("cxx") { |
@@ -89,13 +101,13 @@ template("msvc_toolchain") { |
# The PDB name needs to be different between C and C++ compiled files. |
pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb" |
- command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname" |
+ command = "$env_wrapper$cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname" |
depsformat = "msvc" |
description = "CXX {{output}}" |
outputs = [ |
"$object_subdir/{{source_name_part}}.obj", |
] |
- rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" |
+ rspfile_content = "$sys_include_flags{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" |
} |
tool("rc") { |
@@ -239,6 +251,13 @@ template("msvc_toolchain") { |
} |
} |
+if (is_clang) { |
+ sys_include_prefix = "-isystem=" |
+} else { |
+ # MSVC doesn't have the concept of system headers. |
+ sys_include_prefix = "/I" |
+} |
+ |
if (host_os == "win") { |
clang_cl = "clang-cl.exe" |
} else { |
@@ -256,6 +275,7 @@ if (target_cpu == "x86") { |
windows_sdk_path, |
visual_studio_runtime_dirs, |
"x86", |
+ "${sys_include_prefix}", |
], |
"scope") |
@@ -274,6 +294,7 @@ if (target_cpu == "x86") { |
cl = "${goma_prefix}$prefix/${clang_cl}" |
toolchain_os = "win" |
is_clang = true |
+ sys_include_flags = "${x86_toolchain_data.include_flags}" |
} |
} |
@@ -285,6 +306,7 @@ x64_toolchain_data = exec_script("setup_toolchain.py", |
windows_sdk_path, |
visual_studio_runtime_dirs, |
"x64", |
+ "${sys_include_prefix}", |
], |
"scope") |
@@ -313,6 +335,7 @@ template("win_x64_toolchains") { |
cl = "${goma_prefix}$prefix/${clang_cl}" |
toolchain_os = "win" |
is_clang = true |
+ sys_include_flags = "${x64_toolchain_data.include_flags}" |
forward_variables_from(invoker, [ "is_component_build" ]) |
} |