| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 declare_args() { |
| 6 # Path to the directory containing the VC binaries for the right |
| 7 # combination of host and target architectures. Currently only the |
| 8 # 64-bit host toolchain is supported, with either 32-bit or 64-bit targets. |
| 9 vc_bin_dir = "" |
| 10 } |
| 11 |
| 5 import("//build/config/win/visual_studio_version.gni") | 12 import("//build/config/win/visual_studio_version.gni") |
| 6 import("//build/toolchain/goma.gni") | 13 import("//build/toolchain/goma.gni") |
| 7 | 14 |
| 8 # Should only be running on Windows. | 15 # Should only be running on Windows. |
| 9 assert(is_win) | 16 assert(is_win) |
| 10 | 17 |
| 11 # Setup the Visual Studio state. | 18 # Setup the Visual Studio state. |
| 12 # | 19 # |
| 13 # Its arguments are the VS path and the compiler wrapper tool. It will write | 20 # Its arguments are the VS path and the compiler wrapper tool. It will write |
| 14 # "environment.x86" and "environment.x64" to the build directory and return a | 21 # "environment.x86" and "environment.x64" to the build directory and return a |
| 15 # list to us. | 22 # list to us. |
| 16 gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", | 23 gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", |
| 17 root_build_dir) | 24 root_build_dir) |
| 18 exec_script("setup_toolchain.py", | 25 |
| 19 [ | 26 toolchain_data = exec_script("setup_toolchain.py", |
| 20 visual_studio_path, | 27 [visual_studio_path, |
| 21 gyp_win_tool_path, | 28 gyp_win_tool_path, |
| 22 windows_sdk_path, | 29 windows_sdk_path, |
| 23 visual_studio_runtime_dirs | 30 visual_studio_runtime_dirs, |
| 24 ]) | 31 cpu_arch], |
| 32 "scope") |
| 33 |
| 34 if (vc_bin_dir == "") { |
| 35 vc_bin_dir = toolchain_data.vc_bin_dir |
| 36 } |
| 25 | 37 |
| 26 # This value will be inherited in the toolchain below. | 38 # This value will be inherited in the toolchain below. |
| 27 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") | 39 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") |
| 28 | 40 |
| 29 # Parameters: | 41 # Parameters: |
| 30 # cpu_arch: cpu_arch to pass as a build arg | 42 # cpu_arch: cpu_arch to pass as a build arg |
| 31 # environment: File name of environment file. | 43 # environment: File name of environment file. |
| 32 template("msvc_toolchain") { | 44 template("msvc_toolchain") { |
| 33 if (defined(invoker.concurrent_links)) { | 45 if (defined(invoker.concurrent_links)) { |
| 34 concurrent_links = invoker.concurrent_links | 46 concurrent_links = invoker.concurrent_links |
| 35 } | 47 } |
| 36 | 48 |
| 37 env = invoker.environment | 49 env = invoker.environment |
| 38 | 50 |
| 39 if (is_debug) { | 51 if (is_debug) { |
| 40 configuration = "Debug" | 52 configuration = "Debug" |
| 41 } else { | 53 } else { |
| 42 configuration = "Release" | 54 configuration = "Release" |
| 43 } | 55 } |
| 44 exec_script("../../vs_toolchain.py", ["copy_dlls", | 56 exec_script("../../vs_toolchain.py", ["copy_dlls", |
| 45 rebase_path(root_build_dir), | 57 rebase_path(root_build_dir), |
| 46 configuration, | 58 configuration, |
| 47 invoker.cpu_arch]) | 59 invoker.cpu_arch]) |
| 48 | 60 |
| 61 if (use_goma) { |
| 62 goma_prefix = "$goma_dir/gomacc.exe " |
| 63 } else { |
| 64 goma_prefix = "" |
| 65 } |
| 66 |
| 67 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" |
| 68 |
| 49 toolchain(target_name) { | 69 toolchain(target_name) { |
| 50 # Make these apply to all tools below. | 70 # Make these apply to all tools below. |
| 51 lib_switch = "" | 71 lib_switch = "" |
| 52 lib_dir_switch="/LIBPATH:" | 72 lib_dir_switch="/LIBPATH:" |
| 53 | 73 |
| 54 tool("cc") { | 74 tool("cc") { |
| 55 rspfile = "{{output}}.rsp" | 75 rspfile = "{{output}}.rsp" |
| 56 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" | 76 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" |
| 57 command = "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rsp
file /c {{source}} /Fo{{output}} /Fd$pdbname" | 77 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil
e /c {{source}} /Fo{{output}} /Fd$pdbname" |
| 58 depsformat = "msvc" | 78 depsformat = "msvc" |
| 59 description = "CC {{output}}" | 79 description = "CC {{output}}" |
| 60 outputs = [ | 80 outputs = [ |
| 61 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", | 81 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
| 62 ] | 82 ] |
| 63 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" | 83 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
| 64 } | 84 } |
| 65 | 85 |
| 66 tool("cxx") { | 86 tool("cxx") { |
| 67 rspfile = "{{output}}.rsp" | 87 rspfile = "{{output}}.rsp" |
| 68 # The PDB name needs to be different between C and C++ compiled files. | 88 # The PDB name needs to be different between C and C++ compiled files. |
| 69 pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" | 89 pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" |
| 70 command = "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rsp
file /c {{source}} /Fo{{output}} /Fd$pdbname" | 90 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil
e /c {{source}} /Fo{{output}} /Fd$pdbname" |
| 71 depsformat = "msvc" | 91 depsformat = "msvc" |
| 72 description = "CXX {{output}}" | 92 description = "CXX {{output}}" |
| 73 outputs = [ | 93 outputs = [ |
| 74 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", | 94 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
| 75 ] | 95 ] |
| 76 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" | 96 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
| 77 } | 97 } |
| 78 | 98 |
| 79 tool("rc") { | 99 tool("rc") { |
| 80 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{
include_dirs}} /fo{{output}} {{source}}" | 100 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{
include_dirs}} /fo{{output}} {{source}}" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 cpu_arch = "x86" | 202 cpu_arch = "x86" |
| 183 } | 203 } |
| 184 } | 204 } |
| 185 | 205 |
| 186 if (cpu_arch == "x64") { | 206 if (cpu_arch == "x64") { |
| 187 msvc_toolchain("64") { | 207 msvc_toolchain("64") { |
| 188 environment = "environment.x64" | 208 environment = "environment.x64" |
| 189 cpu_arch = "x64" | 209 cpu_arch = "x64" |
| 190 } | 210 } |
| 191 } | 211 } |
| OLD | NEW |