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 = |
17 root_build_dir) | 17 rebase_path("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir) |
18 exec_script("setup_toolchain.py", | 18 exec_script("setup_toolchain.py", |
19 [ | 19 [ |
20 visual_studio_path, | 20 visual_studio_path, |
21 gyp_win_tool_path, | 21 gyp_win_tool_path, |
22 windows_sdk_path, | 22 windows_sdk_path, |
23 visual_studio_runtime_dirs | 23 visual_studio_runtime_dirs, |
24 ]) | 24 ]) |
25 | 25 |
26 # This value will be inherited in the toolchain below. | 26 # This value will be inherited in the toolchain below. |
27 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") | 27 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") |
28 | 28 |
29 # Parameters: | 29 # Parameters: |
30 # cpu_arch: cpu_arch to pass as a build arg | 30 # cpu_arch: cpu_arch to pass as a build arg |
31 # environment: File name of environment file. | 31 # environment: File name of environment file. |
32 template("msvc_toolchain") { | 32 template("msvc_toolchain") { |
33 if (defined(invoker.concurrent_links)) { | 33 if (defined(invoker.concurrent_links)) { |
34 concurrent_links = invoker.concurrent_links | 34 concurrent_links = invoker.concurrent_links |
35 } | 35 } |
36 | 36 |
37 env = invoker.environment | 37 env = invoker.environment |
38 | 38 |
39 if (is_debug) { | 39 if (is_debug) { |
40 configuration = "Debug" | 40 configuration = "Debug" |
41 } else { | 41 } else { |
42 configuration = "Release" | 42 configuration = "Release" |
43 } | 43 } |
44 exec_script("../../vs_toolchain.py", ["copy_dlls", | 44 exec_script("../../vs_toolchain.py", |
45 rebase_path(root_build_dir), | 45 [ |
46 configuration, | 46 "copy_dlls", |
47 invoker.cpu_arch]) | 47 rebase_path(root_build_dir), |
| 48 configuration, |
| 49 invoker.cpu_arch, |
| 50 ]) |
48 | 51 |
49 toolchain(target_name) { | 52 toolchain(target_name) { |
50 # Make these apply to all tools below. | 53 # Make these apply to all tools below. |
51 lib_switch = "" | 54 lib_switch = "" |
52 lib_dir_switch="/LIBPATH:" | 55 lib_dir_switch = "/LIBPATH:" |
53 | 56 |
54 tool("cc") { | 57 tool("cc") { |
55 rspfile = "{{output}}.rsp" | 58 rspfile = "{{output}}.rsp" |
56 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" | 59 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" | 60 command = |
| 61 "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /
c {{source}} /Fo{{output}} /Fd$pdbname" |
58 depsformat = "msvc" | 62 depsformat = "msvc" |
59 description = "CC {{output}}" | 63 description = "CC {{output}}" |
60 outputs = [ | 64 outputs = |
61 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", | 65 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] |
62 ] | |
63 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" | 66 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
64 } | 67 } |
65 | 68 |
66 tool("cxx") { | 69 tool("cxx") { |
67 rspfile = "{{output}}.rsp" | 70 rspfile = "{{output}}.rsp" |
| 71 |
68 # The PDB name needs to be different between C and C++ compiled files. | 72 # The PDB name needs to be different between C and C++ compiled files. |
69 pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" | 73 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" | 74 command = |
| 75 "ninja -t msvc -e $env -- cl.exe /nologo /showIncludes /FC @$rspfile /
c {{source}} /Fo{{output}} /Fd$pdbname" |
71 depsformat = "msvc" | 76 depsformat = "msvc" |
72 description = "CXX {{output}}" | 77 description = "CXX {{output}}" |
73 outputs = [ | 78 outputs = |
74 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", | 79 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] |
75 ] | |
76 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" | 80 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
77 } | 81 } |
78 | 82 |
79 tool("rc") { | 83 tool("rc") { |
80 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{
include_dirs}} /fo{{output}} {{source}}" | 84 command = |
81 outputs = [ | 85 "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{includ
e_dirs}} /fo{{output}} {{source}}" |
82 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.res", | 86 outputs = |
83 ] | 87 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.res"
] |
84 description = "RC {{output}}" | 88 description = "RC {{output}}" |
85 } | 89 } |
86 | 90 |
87 tool("asm") { | 91 tool("asm") { |
88 # TODO(brettw): "/safeseh" assembler argument is hardcoded here. Extract | 92 # TODO(brettw): "/safeseh" assembler argument is hardcoded here. Extract |
89 # assembler flags to a variable like cflags. crbug.com/418613 | 93 # assembler flags to a variable like cflags. crbug.com/418613 |
90 command = "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {
{include_dirs}} /safeseh /c /Fo {{output}} {{source}}" | 94 command = |
| 95 "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {{inclu
de_dirs}} /safeseh /c /Fo {{output}} {{source}}" |
91 description = "ASM {{output}}" | 96 description = "ASM {{output}}" |
92 outputs = [ | 97 outputs = |
93 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", | 98 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj"
] |
94 ] | |
95 } | 99 } |
96 | 100 |
97 tool("alink") { | 101 tool("alink") { |
98 rspfile = "{{output}}.rsp" | 102 rspfile = "{{output}}.rsp" |
99 command = "$python_path gyp-win-tool link-wrapper $env False lib.exe /nolo
go /ignore:4221 /OUT:{{output}} @$rspfile" | 103 command = |
| 104 "$python_path gyp-win-tool link-wrapper $env False lib.exe /nologo /ig
nore:4221 /OUT:{{output}} @$rspfile" |
100 description = "LIB {{output}}" | 105 description = "LIB {{output}}" |
101 outputs = [ | 106 outputs = [ |
102 # Ignore {{output_extension}} and always use .lib, there's no reason to | 107 # Ignore {{output_extension}} and always use .lib, there's no reason to |
103 # allow targets to override this extension on Windows. | 108 # allow targets to override this extension on Windows. |
104 "{{target_out_dir}}/{{target_output_name}}.lib", | 109 "{{target_out_dir}}/{{target_output_name}}.lib", |
105 ] | 110 ] |
106 default_output_extension = ".lib" | 111 default_output_extension = ".lib" |
| 112 |
107 # The use of inputs_newline is to work around a fixed per-line buffer | 113 # The use of inputs_newline is to work around a fixed per-line buffer |
108 # size in the linker. | 114 # size in the linker. |
109 rspfile_content = "{{inputs_newline}}" | 115 rspfile_content = "{{inputs_newline}}" |
110 } | 116 } |
111 | 117 |
112 tool("solink") { | 118 tool("solink") { |
113 dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" #
e.g. foo.dll | 119 dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" #
e.g. foo.dll |
114 libname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib
" # e.g. foo.dll.lib | 120 libname = |
| 121 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib" # e
.g. foo.dll.lib |
115 rspfile = "${dllname}.rsp" | 122 rspfile = "${dllname}.rsp" |
116 | 123 |
117 link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe
/nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile" | 124 link_command = |
| 125 "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /I
MPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile" |
118 | 126 |
119 # TODO(brettw) support manifests | 127 # TODO(brettw) support manifests |
120 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:${dllname}.manifest" | 128 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:${dllname}.manifest" |
121 #command = "cmd /c $link_command && $manifest_command" | 129 #command = "cmd /c $link_command && $manifest_command" |
122 command = link_command | 130 command = link_command |
123 | 131 |
124 default_output_extension = ".dll" | 132 default_output_extension = ".dll" |
125 description = "LINK(DLL) {{output}}" | 133 description = "LINK(DLL) {{output}}" |
126 outputs = [ | 134 outputs = [ |
127 dllname, | 135 dllname, |
128 libname, | 136 libname, |
129 ] | 137 ] |
130 link_output = libname | 138 link_output = libname |
131 depend_output = libname | 139 depend_output = libname |
| 140 |
132 # The use of inputs_newline is to work around a fixed per-line buffer | 141 # The use of inputs_newline is to work around a fixed per-line buffer |
133 # size in the linker. | 142 # size in the linker. |
134 rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" | 143 rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" |
135 } | 144 } |
136 | 145 |
137 tool("link") { | 146 tool("link") { |
138 rspfile = "{{output}}.rsp" | 147 rspfile = "{{output}}.rsp" |
139 | 148 |
140 link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe
/nologo /OUT:{{output}} /PDB:{{output}}.pdb @$rspfile" | 149 link_command = |
| 150 "$python_path gyp-win-tool link-wrapper $env False link.exe /nologo /O
UT:{{output}} /PDB:{{output}}.pdb @$rspfile" |
141 | 151 |
142 # TODO(brettw) support manifests | 152 # TODO(brettw) support manifests |
143 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:{{output}}.manifest" | 153 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:{{output}}.manifest" |
144 #command = "cmd /c $link_command && $manifest_command" | 154 #command = "cmd /c $link_command && $manifest_command" |
145 command = link_command | 155 command = link_command |
146 | 156 |
147 default_output_extension = ".exe" | 157 default_output_extension = ".exe" |
148 description = "LINK {{output}}" | 158 description = "LINK {{output}}" |
149 outputs = [ | 159 outputs = |
150 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", | 160 [ "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" ] |
151 ] | 161 |
152 # 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 |
153 # size in the linker. | 163 # size in the linker. |
154 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" | 164 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" |
155 } | 165 } |
156 | 166 |
157 tool("stamp") { | 167 tool("stamp") { |
158 command = "$python_path gyp-win-tool stamp {{output}}" | 168 command = "$python_path gyp-win-tool stamp {{output}}" |
159 description = "STAMP {{output}}" | 169 description = "STAMP {{output}}" |
160 } | 170 } |
161 | 171 |
162 tool("copy") { | 172 tool("copy") { |
163 command = "$python_path gyp-win-tool recursive-mirror {{source}} {{output
}}" | 173 command = |
| 174 "$python_path gyp-win-tool recursive-mirror {{source}} {{output}}" |
164 description = "COPY {{source}} {{output}}" | 175 description = "COPY {{source}} {{output}}" |
165 } | 176 } |
166 | 177 |
167 # When invoking this toolchain not as the default one, these args will be | 178 # When invoking this toolchain not as the default one, these args will be |
168 # passed to the build. They are ignored when this is the default toolchain. | 179 # passed to the build. They are ignored when this is the default toolchain. |
169 toolchain_args() { | 180 toolchain_args() { |
170 cpu_arch = invoker.cpu_arch | 181 cpu_arch = invoker.cpu_arch |
171 } | 182 } |
172 } | 183 } |
173 } | 184 } |
174 | 185 |
175 # TODO(dpranke): Declare both toolchains all of the time when we | 186 # TODO(dpranke): Declare both toolchains all of the time when we |
176 # get it sorted out how we want to support them both in a single build. | 187 # get it sorted out how we want to support them both in a single build. |
177 # Right now only one of these can be enabled at a time because the | 188 # Right now only one of these can be enabled at a time because the |
178 # runtime libraries get copied to root_build_dir and would collide. | 189 # runtime libraries get copied to root_build_dir and would collide. |
179 if (cpu_arch == "x86") { | 190 if (cpu_arch == "x86") { |
180 msvc_toolchain("32") { | 191 msvc_toolchain("32") { |
181 environment = "environment.x86" | 192 environment = "environment.x86" |
182 cpu_arch = "x86" | 193 cpu_arch = "x86" |
183 } | 194 } |
184 } | 195 } |
185 | 196 |
186 if (cpu_arch == "x64") { | 197 if (cpu_arch == "x64") { |
187 msvc_toolchain("64") { | 198 msvc_toolchain("64") { |
188 environment = "environment.x64" | 199 environment = "environment.x64" |
189 cpu_arch = "x64" | 200 cpu_arch = "x64" |
190 } | 201 } |
191 } | 202 } |
OLD | NEW |