OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 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 |
| 14 import("//build/config/win/visual_studio_version.gni") |
| 15 import("//build/toolchain/goma.gni") |
| 16 |
| 17 # Should only be running on Windows. |
| 18 assert(is_win) |
| 19 |
| 20 # 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("//tools/gyp/pylib/gyp/win_tool.py", root_build_dir) |
| 27 |
| 28 toolchain_data = exec_script("setup_toolchain.py", |
| 29 [ |
| 30 visual_studio_path, |
| 31 gyp_win_tool_path, |
| 32 windows_sdk_path, |
| 33 visual_studio_runtime_dirs, |
| 34 current_cpu, |
| 35 ], |
| 36 "scope") |
| 37 |
| 38 if (vc_bin_dir == "") { |
| 39 vc_bin_dir = toolchain_data.vc_bin_dir |
| 40 } |
| 41 |
| 42 if (use_goma) { |
| 43 goma_prefix = "$goma_dir/gomacc.exe " |
| 44 } else { |
| 45 goma_prefix = "" |
| 46 } |
| 47 |
| 48 # This value will be inherited in the toolchain below. |
| 49 concurrent_links = exec_script("../get_concurrent_links.py", [], "value") |
| 50 |
| 51 # Parameters: |
| 52 # current_cpu: current_cpu to pass as a build arg |
| 53 # environment: File name of environment file. |
| 54 template("msvc_toolchain") { |
| 55 if (defined(invoker.concurrent_links)) { |
| 56 concurrent_links = invoker.concurrent_links |
| 57 } |
| 58 |
| 59 env = invoker.environment |
| 60 |
| 61 if (is_debug) { |
| 62 configuration = "Debug" |
| 63 } else { |
| 64 configuration = "Release" |
| 65 } |
| 66 exec_script("../../vs_toolchain.py", |
| 67 [ |
| 68 "copy_dlls", |
| 69 rebase_path(root_build_dir), |
| 70 configuration, |
| 71 invoker.current_cpu, |
| 72 ]) |
| 73 |
| 74 cl = invoker.cl |
| 75 |
| 76 toolchain(target_name) { |
| 77 # Make these apply to all tools below. |
| 78 lib_switch = "" |
| 79 lib_dir_switch = "/LIBPATH:" |
| 80 |
| 81 tool("cc") { |
| 82 rspfile = "{{output}}.rsp" |
| 83 |
| 84 # TODO(brettw) enable this when GN support in the binary has been rolled. |
| 85 #precompiled_header_type = "msvc" |
| 86 pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb" |
| 87 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil
e /c {{source}} /Fo{{output}} /Fd$pdbname" |
| 88 depsformat = "msvc" |
| 89 description = "CC {{output}}" |
| 90 outputs = [ |
| 91 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", |
| 92 ] |
| 93 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
| 94 } |
| 95 |
| 96 tool("cxx") { |
| 97 rspfile = "{{output}}.rsp" |
| 98 |
| 99 # TODO(brettw) enable this when GN support in the binary has been rolled. |
| 100 #precompiled_header_type = "msvc" |
| 101 |
| 102 # The PDB name needs to be different between C and C++ compiled files. |
| 103 pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb" |
| 104 command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfil
e /c {{source}} /Fo{{output}} /Fd$pdbname" |
| 105 depsformat = "msvc" |
| 106 description = "CXX {{output}}" |
| 107 outputs = [ |
| 108 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", |
| 109 ] |
| 110 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" |
| 111 } |
| 112 |
| 113 tool("rc") { |
| 114 command = "$python_path gyp-win-tool rc-wrapper $env rc.exe {{defines}} {{
include_dirs}} /fo{{output}} {{source}}" |
| 115 outputs = [ |
| 116 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.res", |
| 117 ] |
| 118 description = "RC {{output}}" |
| 119 } |
| 120 |
| 121 tool("asm") { |
| 122 # TODO(brettw): "/safeseh" assembler argument is hardcoded here. Extract |
| 123 # assembler flags to a variable like cflags. crbug.com/418613 |
| 124 command = "$python_path gyp-win-tool asm-wrapper $env ml.exe {{defines}} {
{include_dirs}} /safeseh /c /Fo {{output}} {{source}}" |
| 125 description = "ASM {{output}}" |
| 126 outputs = [ |
| 127 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.obj", |
| 128 ] |
| 129 } |
| 130 |
| 131 tool("alink") { |
| 132 rspfile = "{{output}}.rsp" |
| 133 command = "$python_path gyp-win-tool link-wrapper $env False lib.exe /nolo
go /ignore:4221 /OUT:{{output}} @$rspfile" |
| 134 description = "LIB {{output}}" |
| 135 outputs = [ |
| 136 # Ignore {{output_extension}} and always use .lib, there's no reason to |
| 137 # allow targets to override this extension on Windows. |
| 138 "{{target_out_dir}}/{{target_output_name}}.lib", |
| 139 ] |
| 140 default_output_extension = ".lib" |
| 141 |
| 142 # The use of inputs_newline is to work around a fixed per-line buffer |
| 143 # size in the linker. |
| 144 rspfile_content = "{{inputs_newline}}" |
| 145 } |
| 146 |
| 147 tool("solink") { |
| 148 dllname = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" #
e.g. foo.dll |
| 149 libname = |
| 150 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib" # e
.g. foo.dll.lib |
| 151 rspfile = "${dllname}.rsp" |
| 152 |
| 153 link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe
/nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile" |
| 154 |
| 155 # TODO(brettw) support manifests |
| 156 #manifest_command = "$python_path gyp-win-tool manifest-wrapper $env mt.ex
e -nologo -manifest $manifests -out:${dllname}.manifest" |
| 157 #command = "cmd /c $link_command && $manifest_command" |
| 158 command = link_command |
| 159 |
| 160 default_output_extension = ".dll" |
| 161 description = "LINK(DLL) {{output}}" |
| 162 outputs = [ |
| 163 dllname, |
| 164 libname, |
| 165 ] |
| 166 link_output = libname |
| 167 depend_output = libname |
| 168 |
| 169 # The use of inputs_newline is to work around a fixed per-line buffer |
| 170 # size in the linker. |
| 171 rspfile_content = "{{libs}} {{solibs}} {{inputs_newline}} {{ldflags}}" |
| 172 } |
| 173 |
| 174 tool("link") { |
| 175 rspfile = "{{output}}.rsp" |
| 176 |
| 177 link_command = "$python_path gyp-win-tool link-wrapper $env False link.exe
/nologo /OUT:{{output}} /PDB:{{output}}.pdb @$rspfile" |
| 178 |
| 179 # TODO(brettw) support manifests |
| 180 #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" |
| 182 command = link_command |
| 183 |
| 184 default_output_extension = ".exe" |
| 185 description = "LINK {{output}}" |
| 186 outputs = [ |
| 187 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 188 ] |
| 189 |
| 190 # The use of inputs_newline is to work around a fixed per-line buffer |
| 191 # size in the linker. |
| 192 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" |
| 193 } |
| 194 |
| 195 tool("stamp") { |
| 196 command = "$python_path gyp-win-tool stamp {{output}}" |
| 197 description = "STAMP {{output}}" |
| 198 } |
| 199 |
| 200 tool("copy") { |
| 201 command = |
| 202 "$python_path gyp-win-tool recursive-mirror {{source}} {{output}}" |
| 203 description = "COPY {{source}} {{output}}" |
| 204 } |
| 205 |
| 206 # When invoking this toolchain not as the default one, these args will be |
| 207 # passed to the build. They are ignored when this is the default toolchain. |
| 208 toolchain_args() { |
| 209 current_cpu = invoker.current_cpu |
| 210 if (defined(invoker.is_clang)) { |
| 211 is_clang = invoker.is_clang |
| 212 } |
| 213 } |
| 214 } |
| 215 } |
| 216 |
| 217 # TODO(dpranke): Declare both toolchains all of the time when we |
| 218 # get it sorted out how we want to support them both in a single build. |
| 219 # Right now only one of these can be enabled at a time because the |
| 220 # runtime libraries get copied to root_build_dir and would collide. |
| 221 if (current_cpu == "x86") { |
| 222 msvc_toolchain("x86") { |
| 223 environment = "environment.x86" |
| 224 current_cpu = "x86" |
| 225 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" |
| 226 is_clang = false |
| 227 } |
| 228 msvc_toolchain("clang_x86") { |
| 229 environment = "environment.x86" |
| 230 current_cpu = "x86" |
| 231 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 232 root_build_dir) |
| 233 cl = "${goma_prefix}$prefix/clang-cl.exe" |
| 234 is_clang = true |
| 235 } |
| 236 } |
| 237 |
| 238 if (current_cpu == "x64") { |
| 239 msvc_toolchain("x64") { |
| 240 environment = "environment.x64" |
| 241 current_cpu = "x64" |
| 242 cl = "${goma_prefix}\"${vc_bin_dir}/cl.exe\"" |
| 243 is_clang = false |
| 244 } |
| 245 msvc_toolchain("clang_x64") { |
| 246 environment = "environment.x64" |
| 247 current_cpu = "x64" |
| 248 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 249 root_build_dir) |
| 250 cl = "${goma_prefix}$prefix/clang-cl.exe" |
| 251 is_clang = true |
| 252 } |
| 253 } |
OLD | NEW |