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() { | 5 declare_args() { |
6 # Path to the directory containing the VC binaries for the right | 6 # Path to the directory containing the VC binaries for the right |
7 # combination of host and target architectures. Currently only the | 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. | 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 | 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. | 10 # isn't), we will dynamically determine the right value to use at runtime. |
11 vc_bin_dir = "" | 11 vc_bin_dir = "" |
12 } | 12 } |
13 | 13 |
14 import("//build/config/win/visual_studio_version.gni") | 14 import("//build/config/win/visual_studio_version.gni") |
15 import("//build/toolchain/goma.gni") | 15 import("//build/toolchain/goma.gni") |
16 | 16 |
17 # Should only be running on Windows. | 17 # Should only be running on Windows. |
18 assert(is_win) | 18 assert(is_win) |
19 | 19 |
| 20 # This tool will is used as a wrapper for various commands below. |
| 21 tool_wrapper_path = rebase_path("tool_wrapper.py", root_build_dir) |
| 22 |
20 # Setup the Visual Studio state. | 23 # Setup the Visual Studio state. |
21 # | |
22 # Its arguments are the VS path and the compiler wrapper tool. It will write | |
23 # "environment.x86" and "environment.x64" to the build directory and return a | |
24 # list to us. | |
25 gyp_win_tool_path = | |
26 rebase_path("//third_party/gyp/pylib/gyp/win_tool.py", root_build_dir) | |
27 | |
28 toolchain_data = exec_script("setup_toolchain.py", | 24 toolchain_data = exec_script("setup_toolchain.py", |
29 [ | 25 [ |
30 visual_studio_path, | 26 visual_studio_path, |
31 gyp_win_tool_path, | 27 windows_sdk_path, |
32 windows_sdk_path, | 28 visual_studio_runtime_dirs, |
33 visual_studio_runtime_dirs, | 29 current_cpu, |
34 current_cpu, | 30 ], |
35 ], | 31 "scope") |
36 "scope") | |
37 | 32 |
38 if (vc_bin_dir == "") { | 33 if (vc_bin_dir == "") { |
39 vc_bin_dir = toolchain_data.vc_bin_dir | 34 vc_bin_dir = toolchain_data.vc_bin_dir |
40 } | 35 } |
41 | 36 |
42 if (use_goma) { | 37 if (use_goma) { |
43 goma_prefix = "$goma_dir/gomacc.exe " | 38 goma_prefix = "$goma_dir/gomacc.exe " |
44 } else { | 39 } else { |
45 goma_prefix = "" | 40 goma_prefix = "" |
46 } | 41 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil
e /c {{source}} /Fo{{output}} /Fd$pdbname" | 92 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil
e /c {{source}} /Fo{{output}} /Fd$pdbname" |
98 depsformat = "msvc" | 93 depsformat = "msvc" |
99 description = "CXX {{output}}" | 94 description = "CXX {{output}}" |
100 outputs = [ | 95 outputs = [ |
101 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", | 96 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", |
102 ] | 97 ] |
103 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" | 98 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" |
104 } | 99 } |
105 | 100 |
106 tool("rc") { | 101 tool("rc") { |
107 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{
include_dirs}} /fo{{output}} {{source}}" | 102 command = "$python_path $tool_wrapper_path rc-wrapper $env rc.exe {{define
s}} {{include_dirs}} /fo{{output}} {{source}}" |
108 outputs = [ | 103 outputs = [ |
109 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.res", | 104 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.res", |
110 ] | 105 ] |
111 description = "RC {{output}}" | 106 description = "RC {{output}}" |
112 } | 107 } |
113 | 108 |
114 tool("asm") { | 109 tool("asm") { |
115 if (invoker.current_cpu == "x64") { | 110 if (invoker.current_cpu == "x64") { |
116 ml = "ml64.exe" | 111 ml = "ml64.exe" |
117 x64 = "-D_ML64_X64" | 112 x64 = "-D_ML64_X64" |
118 } else { | 113 } else { |
119 ml = "ml.exe" | 114 ml = "ml.exe" |
120 x64 = "" | 115 x64 = "" |
121 } | 116 } |
122 command = "$python_path gyp-win-tool asm-wrapper $env $ml $x64 {{defines}}
{{include_dirs}} {{asmflags}} /c /Fo {{output}} {{source}}" | 117 command = "$python_path $tool_wrapper_path asm-wrapper $env $ml $x64 {{def
ines}} {{include_dirs}} {{asmflags}} /c /Fo {{output}} {{source}}" |
123 description = "ASM {{output}}" | 118 description = "ASM {{output}}" |
124 outputs = [ | 119 outputs = [ |
125 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", | 120 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", |
126 ] | 121 ] |
127 } | 122 } |
128 | 123 |
129 tool("alink") { | 124 tool("alink") { |
130 rspfile = "{{output}}.rsp" | 125 rspfile = "{{output}}.rsp" |
131 command = "$python_path gyp-win-tool link-wrapper $env False lib.exe /nolo
go /ignore:4221 /OUT:{{output}} @$rspfile" | 126 command = "$python_path $tool_wrapper_path link-wrapper $env False lib.exe
/nologo /ignore:4221 /OUT:{{output}} @$rspfile" |
132 description = "LIB {{output}}" | 127 description = "LIB {{output}}" |
133 outputs = [ | 128 outputs = [ |
134 # Ignore {{output_extension}} and always use .lib, there's no reason to | 129 # Ignore {{output_extension}} and always use .lib, there's no reason to |
135 # allow targets to override this extension on Windows. | 130 # allow targets to override this extension on Windows. |
136 "{{target_out_dir}}/{{target_output_name}}.lib", | 131 "{{target_out_dir}}/{{target_output_name}}.lib", |
137 ] | 132 ] |
138 default_output_extension = ".lib" | 133 default_output_extension = ".lib" |
139 | 134 |
140 # The use of inputs_newline is to work around a fixed per-line buffer | 135 # The use of inputs_newline is to work around a fixed per-line buffer |
141 # size in the linker. | 136 # size in the linker. |
142 rspfile_content = "{{inputs_newline}}" | 137 rspfile_content = "{{inputs_newline}}" |
143 } | 138 } |
144 | 139 |
145 tool("solink") { | 140 tool("solink") { |
146 dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" #
e.g. foo.dll | 141 dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" #
e.g. foo.dll |
147 libname = | 142 libname = |
148 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib" # e
.g. foo.dll.lib | 143 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib" # e
.g. foo.dll.lib |
149 rspfile = "${dllname}.rsp" | 144 rspfile = "${dllname}.rsp" |
150 | 145 |
151 link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe
/nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile" | 146 link_command = "$python_path $tool_wrapper_path link-wrapper $env False li
nk.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile
" |
152 | 147 |
153 # TODO(brettw) support manifests | 148 # TODO(brettw) support manifests |
154 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:${dllname}.manifest" | 149 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:${dllname}.manifest" |
155 #command = "cmd /c $link_command && $manifest_command" | 150 #command = "cmd /c $link_command && $manifest_command" |
156 command = link_command | 151 command = link_command |
157 | 152 |
158 default_output_extension = ".dll" | 153 default_output_extension = ".dll" |
159 description = "LINK(DLL) {{output}}" | 154 description = "LINK(DLL) {{output}}" |
160 outputs = [ | 155 outputs = [ |
161 dllname, | 156 dllname, |
162 libname, | 157 libname, |
163 ] | 158 ] |
164 link_output = libname | 159 link_output = libname |
165 depend_output = libname | 160 depend_output = libname |
166 | 161 |
167 # The use of inputs_newline is to work around a fixed per-line buffer | 162 # The use of inputs_newline is to work around a fixed per-line buffer |
168 # size in the linker. | 163 # size in the linker. |
169 rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" | 164 rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" |
170 } | 165 } |
171 | 166 |
172 tool("link") { | 167 tool("link") { |
173 binary_output = | 168 binary_output = |
174 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 169 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
175 rspfile = "$binary_output.rsp" | 170 rspfile = "$binary_output.rsp" |
176 | 171 |
177 link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe
/nologo /OUT:$binary_output /PDB:$binary_output.pdb @$rspfile" | 172 link_command = "$python_path $tool_wrapper_path link-wrapper $env False li
nk.exe /nologo /OUT:$binary_output /PDB:$binary_output.pdb @$rspfile" |
178 | 173 |
179 # TODO(brettw) support manifests | 174 # TODO(brettw) support manifests |
180 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:{{output}}.manifest" | 175 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:{{output}}.manifest" |
181 #command = "cmd /c $link_command && $manifest_command" | 176 #command = "cmd /c $link_command && $manifest_command" |
182 command = link_command | 177 command = link_command |
183 | 178 |
184 default_output_extension = ".exe" | 179 default_output_extension = ".exe" |
185 description = "LINK $binary_output" | 180 description = "LINK $binary_output" |
186 outputs = [ | 181 outputs = [ |
187 binary_output, | 182 binary_output, |
188 "{{root_out_dir}}/{{target_output_name}}.lib", | 183 "{{root_out_dir}}/{{target_output_name}}.lib", |
189 ] | 184 ] |
190 | 185 |
191 # The use of inputs_newline is to work around a fixed per-line buffer | 186 # The use of inputs_newline is to work around a fixed per-line buffer |
192 # size in the linker. | 187 # size in the linker. |
193 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" | 188 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" |
194 } | 189 } |
195 | 190 |
196 tool("stamp") { | 191 tool("stamp") { |
197 command = "$python_path gyp-win-tool stamp {{output}}" | 192 command = "$python_path $tool_wrapper_path stamp {{output}}" |
198 description = "STAMP {{output}}" | 193 description = "STAMP {{output}}" |
199 } | 194 } |
200 | 195 |
201 tool("copy") { | 196 tool("copy") { |
202 command = | 197 command = |
203 "$python_path gyp-win-tool recursive-mirror {{source}} {{output}}" | 198 "$python_path $tool_wrapper_path recursive-mirror {{source}} {{output}
}" |
204 description = "COPY {{source}} {{output}}" | 199 description = "COPY {{source}} {{output}}" |
205 } | 200 } |
206 | 201 |
207 # When invoking this toolchain not as the default one, these args will be | 202 # When invoking this toolchain not as the default one, these args will be |
208 # passed to the build. They are ignored when this is the default toolchain. | 203 # passed to the build. They are ignored when this is the default toolchain. |
209 toolchain_args = { | 204 toolchain_args = { |
210 current_cpu = invoker.current_cpu | 205 current_cpu = invoker.current_cpu |
211 if (defined(invoker.is_clang)) { | 206 if (defined(invoker.is_clang)) { |
212 is_clang = invoker.is_clang | 207 is_clang = invoker.is_clang |
213 } | 208 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } | 240 } |
246 msvc_toolchain("clang_x64") { | 241 msvc_toolchain("clang_x64") { |
247 environment = "environment.x64" | 242 environment = "environment.x64" |
248 current_cpu = "x64" | 243 current_cpu = "x64" |
249 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", | 244 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
250 root_build_dir) | 245 root_build_dir) |
251 cl = "${goma_prefix}$prefix/clang-cl.exe" | 246 cl = "${goma_prefix}$prefix/clang-cl.exe" |
252 is_clang = true | 247 is_clang = true |
253 } | 248 } |
254 } | 249 } |
OLD | NEW |