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

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: formatting Created 4 years, 8 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 e2458e2624eb8e29a04629a3e18aece35f966d33..3d1b6abd4080723efd96c7a5af37d81fd168f8fa 100644
--- a/build/toolchain/win/BUILD.gn
+++ b/build/toolchain/win/BUILD.gn
@@ -80,6 +80,20 @@ template("msvc_toolchain") {
link = "link.exe"
}
+ # 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 {
+ # 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 = ""
@@ -96,13 +110,13 @@ template("msvc_toolchain") {
# Label names may have spaces in them so the pdbname must be quoted. The
# source and output don't need to be quoted because GN knows they're a
# full file name and will quote automatically when necessary.
- 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") {
@@ -113,13 +127,13 @@ template("msvc_toolchain") {
pdbname = "{{target_out_dir}}/{{label_name}}_cc.pdb"
# See comment in CC tool about quoting.
- 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") {
@@ -255,6 +269,13 @@ template("msvc_toolchain") {
}
}
+if (is_clang) {
+ sys_include_prefix = "-imsvc"
+} else {
+ # MSVC doesn't have the concept of system headers.
+ sys_include_prefix = "/I"
+}
+
if (host_os == "win") {
clang_cl = "clang-cl.exe"
} else {
@@ -272,6 +293,7 @@ if (target_cpu == "x86") {
windows_sdk_path,
visual_studio_runtime_dirs,
"x86",
+ "${sys_include_prefix}",
],
"scope")
@@ -290,6 +312,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}"
}
}
@@ -301,6 +324,7 @@ x64_toolchain_data = exec_script("setup_toolchain.py",
windows_sdk_path,
visual_studio_runtime_dirs,
"x64",
+ "${sys_include_prefix}",
],
"scope")
@@ -329,6 +353,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