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 import("//build/config/win/visual_studio_version.gni") | 5 import("//build/config/win/visual_studio_version.gni") |
6 import("//build/toolchain/goma.gni") | 6 import("//build/toolchain/goma.gni") |
7 | 7 |
8 # Should only be running on Windows. | 8 # Should only be running on Windows. |
9 assert(is_win) | 9 assert(is_win) |
10 | 10 |
11 # Setup the Visual Studio state. | 11 # Setup the Visual Studio state. |
12 # | 12 # |
13 # Its arguments are the VS path and the compiler wrapper tool. It will write | 13 # 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 | 14 # "environment.x86" and "environment.x64" to the build directory and return a |
15 # list to us. | 15 # list to us. |
16 gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", | 16 gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", |
17 root_build_dir) | 17 root_build_dir) |
18 exec_script("setup_toolchain.py", | 18 exec_script("setup_toolchain.py", |
19 [ visual_studio_path, gyp_win_tool_path, windows_sdk_path ]) | 19 [ visual_studio_path, gyp_win_tool_path, windows_sdk_path ]) |
20 | 20 |
21 # This value will be inherited in the toolchain below. | 21 # This value will be inherited in the toolchain below. |
22 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") | 22 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") |
23 | 23 |
24 # Parameters: | 24 # Parameters: |
25 # cpu_arch: cpu_arch to pass as a build arg | 25 # cpu_arch: cpu_arch to pass as a build arg |
26 # environment: File name of environment file. | 26 # environment: File name of environment file. |
27 # force_win64 (optional): value for this build arg. | |
28 template("msvc_toolchain") { | 27 template("msvc_toolchain") { |
29 if (defined(invoker.concurrent_links)) { | 28 if (defined(invoker.concurrent_links)) { |
30 concurrent_links = invoker.concurrent_links | 29 concurrent_links = invoker.concurrent_links |
31 } | 30 } |
32 | 31 |
33 env = invoker.environment | 32 env = invoker.environment |
34 | 33 |
| 34 if (is_debug) { |
| 35 configuration = "Debug" |
| 36 } else { |
| 37 configuration = "Release" |
| 38 } |
| 39 exec_script("../../vs_toolchain.py", ["copy_dlls", |
| 40 rebase_path(root_build_dir), |
| 41 configuration, |
| 42 invoker.cpu_arch]) |
| 43 |
35 toolchain(target_name) { | 44 toolchain(target_name) { |
36 # Make these apply to all tools below. | 45 # Make these apply to all tools below. |
37 lib_switch = "" | 46 lib_switch = "" |
38 lib_dir_switch="/LIBPATH:" | 47 lib_dir_switch="/LIBPATH:" |
39 | 48 |
40 tool("cc") { | 49 tool("cc") { |
41 rspfile = "{{output}}.rsp" | 50 rspfile = "{{output}}.rsp" |
42 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" | 51 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" |
43 command = "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rsp
file /c {{source}} /Fo{{output}} /Fd$pdbname" | 52 command = "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rsp
file /c {{source}} /Fo{{output}} /Fd$pdbname" |
44 depsformat = "msvc" | 53 depsformat = "msvc" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 156 |
148 tool("copy") { | 157 tool("copy") { |
149 command = "$python_path gyp-win-tool recursive-mirror {{source}} {{output
}}" | 158 command = "$python_path gyp-win-tool recursive-mirror {{source}} {{output
}}" |
150 description = "COPY {{source}} {{output}}" | 159 description = "COPY {{source}} {{output}}" |
151 } | 160 } |
152 | 161 |
153 # When invoking this toolchain not as the default one, these args will be | 162 # When invoking this toolchain not as the default one, these args will be |
154 # passed to the build. They are ignored when this is the default toolchain. | 163 # passed to the build. They are ignored when this is the default toolchain. |
155 toolchain_args() { | 164 toolchain_args() { |
156 cpu_arch = invoker.cpu_arch | 165 cpu_arch = invoker.cpu_arch |
157 | |
158 # Normally the build config resets the CPU architecture to 32-bits. Settin
g | |
159 # this flag overrides that behavior. | |
160 if (defined(invoker.force_win64)) { | |
161 force_win64 = invoker.force_win64 | |
162 } | |
163 } | 166 } |
164 } | 167 } |
165 } | 168 } |
166 | 169 |
167 msvc_toolchain("32") { | 170 # TODO(dpranke): Declare both toolchains all of the time when we |
168 environment = "environment.x86" | 171 # get it sorted out how we want to support them both in a single build. |
169 cpu_arch = "x64" | 172 # Right now only one of these can be enabled at a time because the |
| 173 # runtime libraries get copied to root_build_dir and would collide. |
| 174 if (cpu_arch == "x86") { |
| 175 msvc_toolchain("32") { |
| 176 environment = "environment.x86" |
| 177 cpu_arch = "x86" |
| 178 } |
170 } | 179 } |
171 | 180 |
172 msvc_toolchain("64") { | 181 if (cpu_arch == "x64") { |
173 environment = "environment.x64" | 182 msvc_toolchain("64") { |
174 cpu_arch = "x64" | 183 environment = "environment.x64" |
175 force_win64 = true | 184 cpu_arch = "x64" |
| 185 } |
176 } | 186 } |
OLD | NEW |