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

Unified 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: poc 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/toolchain/win/setup_toolchain.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/toolchain/win/BUILD.gn
diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn
index 1934e9b19ad43287d8435364e318d8dd0b4b3d8f..f46a0a396c0703e8a064d6a85fa7ec8fd43ae7eb 100644
--- a/build/toolchain/win/BUILD.gn
+++ b/build/toolchain/win/BUILD.gn
@@ -62,6 +62,24 @@ 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 MSVS builds require %PATH% to be set and just passing
+ # in a list of include directories isn't enough.
+ if (defined(invoker.sys_include_flags)) {
+ env_wrapper = ""
+
+ # -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
+ # of in addition to eventual headers from an installed MSVC.
+ # Note trailing space.
+ sys_include_flags = "-isystem ..\..\third_party\llvm-build\Release+Asserts\lib\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
+ } else {
+ # clang-cl doesn't need this env hoop, so omit it there.
+ assert(!invoker.is_clang)
+ 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 +92,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 +107,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 +257,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 +281,7 @@ if (target_cpu == "x86") {
windows_sdk_path,
visual_studio_runtime_dirs,
"x86",
+ "${sys_include_prefix}",
],
"scope")
@@ -274,6 +300,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 +312,7 @@ x64_toolchain_data = exec_script("setup_toolchain.py",
windows_sdk_path,
visual_studio_runtime_dirs,
"x64",
+ "${sys_include_prefix}",
],
"scope")
@@ -313,6 +341,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" ])
}
« 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