| # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/win/visual_studio_version.gni") |
| import("//build/toolchain/goma.gni") |
| |
| # Should only be running on Windows. |
| assert(is_win) |
| |
| # Setup the Visual Studio state. |
| # |
| # Its arguments are the VS path and the compiler wrapper tool. It will write |
| # "environment.x86" and "environment.x64" to the build directory and return a |
| # list to us. |
| gyp_win_tool_path = rebase_path("//tools/gyp/pylib/gyp/win_tool.py", |
| root_build_dir) |
| exec_script("setup_toolchain.py", |
| [ visual_studio_path, gyp_win_tool_path, windows_sdk_path ]) |
| |
| stamp_command = "$python_path gyp-win-tool stamp \$out" |
| copy_command = "$python_path gyp-win-tool recursive-mirror \$in \$out" |
| |
| # MSVC can't share PDB files between compilers compiling C and C++ files, so |
| # we construct different names for each type. |
| c_pdb_suffix = " /Fd\${target_out_dir}/\${target_name}_c.pdb" |
| cc_pdb_suffix = " /Fd\${target_out_dir}/\${target_name}_cc.pdb" |
| |
| # 32-bit toolchain ------------------------------------------------------------- |
| |
| toolchain("32") { |
| # Make these apply to all tools below. |
| lib_prefix = "" |
| lib_dir_prefix="/LIBPATH:" |
| |
| cc_command = "ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out" |
| tool("cc") { |
| command = cc_command + c_pdb_suffix |
| description = "CC \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$defines \$includes \$cflags \$cflags_c" |
| depsformat = "msvc" |
| } |
| tool("cxx") { |
| command = cc_command + cc_pdb_suffix |
| description = "CXX \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$defines \$includes \$cflags \$cflags_cc" |
| depsformat = "msvc" |
| } |
| tool("rc") { |
| command = "$python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$defines \$includes \$rcflags /fo\$out \$in" |
| description = "RC \$in" |
| } |
| tool("asm") { |
| command = "$python_path gyp-win-tool asm-wrapper environment.x86 ml.exe \$defines \$includes /c /Fo \$out \$in" |
| description = "ASM \$in" |
| } |
| tool("alink") { |
| command = "$python_path gyp-win-tool link-wrapper environment.x86 False lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp" |
| description = "LIB \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$in_newline \$libflags" |
| } |
| tool("solink") { |
| command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 False link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest" |
| description = "LINK(DLL) \$dll" |
| restat = "1" |
| rspfile = "\$dll.rsp" |
| rspfile_content = "\$libs \$in_newline \$ldflags" |
| } |
| tool("link") { |
| command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 False link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$out.manifest" |
| description = "LINK \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$in_newline \$libs \$ldflags" |
| } |
| tool("stamp") { |
| command = stamp_command |
| description = "STAMP \$out" |
| } |
| tool("copy") { |
| command = copy_command |
| description = "COPY \$in \$out" |
| } |
| } |
| |
| # 64-bit toolchain ------------------------------------------------------------- |
| |
| toolchain("64") { |
| # Make these apply to all tools below. |
| lib_prefix = "" |
| lib_dir_prefix="/LIBPATH:" |
| |
| cc_command = "ninja -t msvc -e environment.x64 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out" |
| tool("cc") { |
| command = cc_command + c_pdb_suffix |
| description = "CC \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$defines \$includes \$cflags \$cflags_c" |
| depsformat = "msvc" |
| } |
| tool("cxx") { |
| command = cc_command + cc_pdb_suffix |
| description = "CXX \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$defines \$includes \$cflags \$cflags_cc" |
| depsformat = "msvc" |
| } |
| tool("rc") { |
| command = "$python_path gyp-win-tool rc-wrapper environment.x64 rc.exe \$defines \$includes \$rcflags /fo\$out \$in" |
| description = "RC \$in" |
| } |
| tool("asm") { |
| command = "$python_path gyp-win-tool asm-wrapper environment.x64 ml.exe \$defines \$includes /c /Fo \$out \$in" |
| description = "ASM \$in" |
| } |
| tool("alink") { |
| command = "$python_path gyp-win-tool link-wrapper environment.x64 False lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp" |
| description = "LIB \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$in_newline \$libflags" |
| } |
| tool("solink") { |
| command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x64 False link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x64 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest" |
| description = "LINK(DLL) \$dll" |
| restat = "1" |
| rspfile = "\$dll.rsp" |
| rspfile_content = "\$libs \$in_newline \$ldflags" |
| } |
| tool("link") { |
| command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x64 False link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x64 mt.exe -nologo -manifest \$manifests -out:\$out.manifest" |
| description = "LINK \$out" |
| rspfile = "\$out.rsp" |
| rspfile_content = "\$in_newline \$libs \$ldflags" |
| } |
| tool("stamp") { |
| command = stamp_command |
| description = "STAMP \$out" |
| } |
| tool("copy") { |
| command = copy_command |
| description = "COPY \$in \$out" |
| } |
| |
| # When invoking this toolchain not as the default one, these args will be |
| # passed to the build. They are ignored when this is the default toolchain. |
| toolchain_args() { |
| cpu_arch = "x64" |
| # Normally the build config resets the CPU architecture to 32-bits. Setting |
| # this flag overrides that behavior. |
| force_win64 = true |
| } |
| } |