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 # If vc_bin_dir is not specified on the command line (and it normally |
| 10 # isn't), we will dynamically determine the right value to use at runtime. |
| 11 vc_bin_dir = "" |
| 12 } |
| 13 |
5 import("//build/config/win/visual_studio_version.gni") | 14 import("//build/config/win/visual_studio_version.gni") |
6 import("//build/toolchain/goma.gni") | 15 import("//build/toolchain/goma.gni") |
7 | 16 |
8 # Should only be running on Windows. | 17 # Should only be running on Windows. |
9 assert(is_win) | 18 assert(is_win) |
10 | 19 |
11 # Setup the Visual Studio state. | 20 # Setup the Visual Studio state. |
12 # | 21 # |
13 # Its arguments are the VS path and the compiler wrapper tool. It will write | 22 # 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 | 23 # "environment.x86" and "environment.x64" to the build directory and return a |
15 # list to us. | 24 # list to us. |
16 gyp_win_tool_path = | 25 gyp_win_tool_path = |
17 rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir) | 26 rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir) |
18 exec_script("setup_toolchain.py", | 27 |
19 [ | 28 toolchain_data = exec_script("setup_toolchain.py", |
20 visual_studio_path, | 29 [ |
21 gyp_win_tool_path, | 30 visual_studio_path, |
22 windows_sdk_path, | 31 gyp_win_tool_path, |
23 visual_studio_runtime_dirs, | 32 windows_sdk_path, |
24 ]) | 33 visual_studio_runtime_dirs, |
| 34 cpu_arch, |
| 35 ], |
| 36 "scope") |
| 37 |
| 38 if (vc_bin_dir == "") { |
| 39 vc_bin_dir = toolchain_data.vc_bin_dir |
| 40 } |
25 | 41 |
26 # This value will be inherited in the toolchain below. | 42 # This value will be inherited in the toolchain below. |
27 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") | 43 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") |
28 | 44 |
29 # Parameters: | 45 # Parameters: |
30 # cpu_arch: cpu_arch to pass as a build arg | 46 # cpu_arch: cpu_arch to pass as a build arg |
31 # environment: File name of environment file. | 47 # environment: File name of environment file. |
32 template("msvc_toolchain") { | 48 template("msvc_toolchain") { |
33 if (defined(invoker.concurrent_links)) { | 49 if (defined(invoker.concurrent_links)) { |
34 concurrent_links = invoker.concurrent_links | 50 concurrent_links = invoker.concurrent_links |
35 } | 51 } |
36 | 52 |
37 env = invoker.environment | 53 env = invoker.environment |
38 | 54 |
39 if (is_debug) { | 55 if (is_debug) { |
40 configuration = "Debug" | 56 configuration = "Debug" |
41 } else { | 57 } else { |
42 configuration = "Release" | 58 configuration = "Release" |
43 } | 59 } |
44 exec_script("../../vs_toolchain.py", | 60 exec_script("../../vs_toolchain.py", |
45 [ | 61 [ |
46 "copy_dlls", | 62 "copy_dlls", |
47 rebase_path(root_build_dir), | 63 rebase_path(root_build_dir), |
48 configuration, | 64 configuration, |
49 invoker.cpu_arch, | 65 invoker.cpu_arch, |
50 ]) | 66 ]) |
51 | 67 |
| 68 if (use_goma) { |
| 69 goma_prefix = "$goma_dir/gomacc.exe " |
| 70 } else { |
| 71 goma_prefix = "" |
| 72 } |
| 73 |
| 74 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" |
| 75 |
52 toolchain(target_name) { | 76 toolchain(target_name) { |
53 # Make these apply to all tools below. | 77 # Make these apply to all tools below. |
54 lib_switch = "" | 78 lib_switch = "" |
55 lib_dir_switch = "/LIBPATH:" | 79 lib_dir_switch = "/LIBPATH:" |
56 | 80 |
57 tool("cc") { | 81 tool("cc") { |
58 rspfile = "{{output}}.rsp" | 82 rspfile = "{{output}}.rsp" |
59 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" | 83 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" |
60 command = | 84 command = |
61 "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /
c {{source}} /Fo{{output}} /Fd$pdbname" | 85 "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {
{source}} /Fo{{output}} /Fd$pdbname" |
62 depsformat = "msvc" | 86 depsformat = "msvc" |
63 description = "CC {{output}}" | 87 description = "CC {{output}}" |
64 outputs = | 88 outputs = |
65 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] | 89 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] |
66 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" | 90 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
67 } | 91 } |
68 | 92 |
69 tool("cxx") { | 93 tool("cxx") { |
70 rspfile = "{{output}}.rsp" | 94 rspfile = "{{output}}.rsp" |
71 | 95 |
72 # The PDB name needs to be different between C and C++ compiled files. | 96 # The PDB name needs to be different between C and C++ compiled files. |
73 pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" | 97 pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" |
74 command = | 98 command = |
75 "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /
c {{source}} /Fo{{output}} /Fd$pdbname" | 99 "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {
{source}} /Fo{{output}} /Fd$pdbname" |
76 depsformat = "msvc" | 100 depsformat = "msvc" |
77 description = "CXX {{output}}" | 101 description = "CXX {{output}}" |
78 outputs = | 102 outputs = |
79 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] | 103 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] |
80 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" | 104 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
81 } | 105 } |
82 | 106 |
83 tool("rc") { | 107 tool("rc") { |
84 command = | 108 command = |
85 "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{includ
e_dirs}} /fo{{output}} {{source}}" | 109 "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{includ
e_dirs}} /fo{{output}} {{source}}" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 cpu_arch = "x86" | 217 cpu_arch = "x86" |
194 } | 218 } |
195 } | 219 } |
196 | 220 |
197 if (cpu_arch == "x64") { | 221 if (cpu_arch == "x64") { |
198 msvc_toolchain("64") { | 222 msvc_toolchain("64") { |
199 environment = "environment.x64" | 223 environment = "environment.x64" |
200 cpu_arch = "x64" | 224 cpu_arch = "x64" |
201 } | 225 } |
202 } | 226 } |
OLD | NEW |