win: Decide how to include system dirs at toolchain time instead of globally.

Before this patch, we used the global is_clang setting to decide if
we include system libraries via /I or -imsvc in the clang toolchains.
Now, always use -imsvc in the clang toolchains.

The motivation is that we (maybe) want to build libyuv with a clang
toolchain even when is_clang is globally set to false.

BUG=692600

Review-Url: https://codereview.chromium.org/2728233002
Cr-Original-Commit-Position: refs/heads/master@{#454704}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: cbdbc2fd19dcde3cf06296bb9bad8f41978214b5
diff --git a/win/BUILD.gn b/win/BUILD.gn
index 8efa40c..dd1017f 100644
--- a/win/BUILD.gn
+++ b/win/BUILD.gn
@@ -312,13 +312,6 @@
   }
 }
 
-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 {
@@ -335,7 +328,6 @@
                                      windows_sdk_path,
                                      visual_studio_runtime_dirs,
                                      "x86",
-                                     "${sys_include_prefix}",
                                    ],
                                    "scope")
 
@@ -352,7 +344,7 @@
     environment = "environment.x86"
     prefix = rebase_path("$clang_base_path/bin", root_build_dir)
     cl = "${goma_prefix}$prefix/${clang_cl}"
-    sys_include_flags = "${x86_toolchain_data.include_flags}"
+    sys_include_flags = "${x86_toolchain_data.include_flags_imsvc}"
 
     toolchain_args = {
       current_cpu = "x86"
@@ -368,7 +360,6 @@
                                    windows_sdk_path,
                                    visual_studio_runtime_dirs,
                                    "x64",
-                                   "${sys_include_prefix}",
                                  ],
                                  "scope")
 
@@ -390,7 +381,7 @@
     environment = "environment.x64"
     prefix = rebase_path("$clang_base_path/bin", root_build_dir)
     cl = "${goma_prefix}$prefix/${clang_cl}"
-    sys_include_flags = "${x64_toolchain_data.include_flags}"
+    sys_include_flags = "${x64_toolchain_data.include_flags_imsvc}"
 
     toolchain_args = {
       if (defined(invoker.toolchain_args)) {
diff --git a/win/setup_toolchain.py b/win/setup_toolchain.py
index 43a7e09..ec60564 100644
--- a/win/setup_toolchain.py
+++ b/win/setup_toolchain.py
@@ -152,7 +152,7 @@
 
 
 def main():
-  if len(sys.argv) != 6:
+  if len(sys.argv) != 5:
     print('Usage setup_toolchain.py '
           '<visual studio path> <win sdk path> '
           '<runtime dirs> <target_cpu> <include prefix>')
@@ -160,7 +160,6 @@
   win_sdk_path = sys.argv[2]
   runtime_dirs = sys.argv[3]
   target_cpu = sys.argv[4]
-  include_prefix = sys.argv[5]
 
   cpus = ('x86', 'x64')
   assert target_cpu in cpus
@@ -182,8 +181,9 @@
           break
       # The separator for INCLUDE here must match the one used in
       # _LoadToolchainEnv() above.
-      include = [include_prefix + p for p in env['INCLUDE'].split(';') if p]
-      include = ' '.join(['"' + i.replace('"', r'\"') + '"' for i in include])
+      include = [p.replace('"', r'\"') for p in env['INCLUDE'].split(';') if p]
+      include_I = ' '.join(['"/I' + i + '"' for i in include])
+      include_imsvc = ' '.join(['"-imsvc' + i + '"' for i in include])
 
     env_block = _FormatAsEnvironmentBlock(env)
     with open('environment.' + cpu, 'wb') as f:
@@ -200,8 +200,10 @@
 
   assert vc_bin_dir
   print 'vc_bin_dir = ' + gn_helpers.ToGNString(vc_bin_dir)
-  assert include
-  print 'include_flags = ' + gn_helpers.ToGNString(include)
+  assert include_I
+  print 'include_flags_I = ' + gn_helpers.ToGNString(include_I)
+  assert include_imsvc
+  print 'include_flags_imsvc = ' + gn_helpers.ToGNString(include_imsvc)
 
 if __name__ == '__main__':
   main()