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

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: foo 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..ca92bc5ba4f529387b6e0d2d8600d48f9ba291da 100644
--- a/build/toolchain/win/BUILD.gn
+++ b/build/toolchain/win/BUILD.gn
@@ -62,6 +62,19 @@ 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 = ""
+ sys_include_flags = "${invoker.sys_include_flags} " # Note trailing space.
+ } else {
+ assert(!is_clang) # clang-cl doesn't need this env hoop, so omit it there.
scottmg 2016/02/26 03:32:03 Should this be invoker.is_clang?
Nico 2016/02/26 15:16:26 Oh, good catch, thanks, done! That's what I get fo
+ 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 +87,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 +102,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 +252,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 +276,7 @@ if (target_cpu == "x86") {
windows_sdk_path,
visual_studio_runtime_dirs,
"x86",
+ "${sys_include_prefix}",
],
"scope")
@@ -274,6 +295,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 +307,7 @@ x64_toolchain_data = exec_script("setup_toolchain.py",
windows_sdk_path,
visual_studio_runtime_dirs,
"x64",
+ "${sys_include_prefix}",
],
"scope")
@@ -313,6 +336,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