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 # Should only be running on Windows. 6 assert(is_win) 7 8 # Setup the Visual Studio state. 9 # 10 # Its argument is the location to write the environment files. 11 # It will write "environment.x86" and "environment.x64" to this directory, 12 # and return a list to us. 13 # 14 # The list contains the include path as its only element. (I'm expecting to 15 # add more so it's currently a list inside a list.) 16 #exec_script("get_msvc_config.py", 17 # [relative_root_output_dir], 18 # "value") 19 20 # This will save the environment block and and copy the gyp-win-tool to the 21 # build directory. We pass in the source file of the win tool. 22 gyp_win_tool_source = 23 rebase_path("//tools/gyp/pylib/gyp/win_tool.py", ".", root_build_dir) 24 exec_script("setup_toolchain.py", [ gyp_win_tool_source ], "value") 25 26 stamp_command = "$python_path gyp-win-tool stamp \$out" 27 copy_command = "$python_path gyp-win-tool recursive-mirror \$in \$out" 28 29 # 32-bit toolchain ------------------------------------------------------------- 30 31 toolchain("32") { 32 # Make these apply to all tools below. 33 lib_prefix = "" 34 lib_dir_prefix="/LIBPATH:" 35 36 cc_command = "ninja -t msvc -e environment.x86 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out /Fd\$pdbname" 37 tool("cc") { 38 command = cc_command 39 description = "CC \$out" 40 rspfile = "\$out.rsp" 41 rspfile_content = "\$defines \$includes \$cflags \$cflags_c" 42 deps = "msvc" 43 } 44 tool("cxx") { 45 command = cc_command # Same as above 46 description = "CXX \$out" 47 rspfile = "\$out.rsp" 48 rspfile_content = "\$defines \$includes \$cflags \$cflags_cc" 49 deps = "msvc" 50 } 51 tool("rc") { 52 command = "$python_path gyp-win-tool rc-wrapper environment.x86 rc.exe \$defines \$includes \$rcflags /fo\$out \$in" 53 description = "RC \$in" 54 } 55 tool("asm") { 56 command = "$python_path gyp-win-tool asm-wrapper environment.x86 ml.exe \$defines \$includes /c /Fo \$out \$in" 57 description = "ASM \$in" 58 } 59 tool("alink") { 60 command = "$python_path gyp-win-tool link-wrapper environment.x86 lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp" 61 description = "LIB \$out" 62 rspfile = "\$out.rsp" 63 rspfile_content = "\$in_newline \$libflags" 64 } 65 tool("solink") { 66 command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 cmd /c if exist \$dll.manifest del \$dll.manifest && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest" 67 description = "LINK(DLL) \$dll" 68 restat = "1" 69 rspfile = "\$dll.rsp" 70 rspfile_content = "\$libs \$in_newline \$ldflags" 71 } 72 tool("link") { 73 command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x86 link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x86 cmd /c if exist \$out.manifest del \$out.manifest && $python_path gyp-win-tool manifest-wrapper environment.x86 mt.exe -nologo -manifest \$manifests -out:\$out.manifest" 74 description = "LINK \$out" 75 rspfile = "\$out.rsp" 76 rspfile_content = "\$in_newline \$libs \$ldflags" 77 } 78 tool("stamp") { 79 command = stamp_command 80 description = "STAMP \$out" 81 } 82 tool("copy") { 83 command = copy_command 84 description = "COPY \$in \$out" 85 } 86 } 87 88 # 64-bit toolchain ------------------------------------------------------------- 89 90 toolchain("64") { 91 # Make these apply to all tools below. 92 lib_prefix = "" 93 lib_dir_prefix="/LIBPATH:" 94 95 cc_command = "ninja -t msvc -e environment.x64 -- cl.exe /nologo /showIncludes /FC @\$out.rsp /c \$in /Fo\$out /Fd\$pdbname" 96 tool("cc") { 97 command = cc_command 98 description = "CC \$out" 99 rspfile = "\$out.rsp" 100 rspfile_content = "\$defines \$includes \$cflags \$cflags_c" 101 deps = "msvc" 102 } 103 tool("cxx") { 104 command = cc_command # Same as above 105 description = "CXX \$out" 106 rspfile = "\$out.rsp" 107 rspfile_content = "\$defines \$includes \$cflags \$cflags_cc" 108 deps = "msvc" 109 } 110 tool("rc") { 111 command = "$python_path gyp-win-tool rc-wrapper environment.x64 rc.exe \$defines \$includes \$rcflags /fo\$out \$in" 112 description = "RC \$in" 113 } 114 tool("asm") { 115 command = "$python_path gyp-win-tool asm-wrapper environment.x64 ml.exe \$defines \$includes /c /Fo \$out \$in" 116 description = "ASM \$in" 117 } 118 tool("alink") { 119 command = "$python_path gyp-win-tool link-wrapper environment.x64 lib.exe /nologo /ignore:4221 /OUT:\$out @\$out.rsp" 120 description = "LIB \$out" 121 rspfile = "\$out.rsp" 122 rspfile_content = "\$in_newline \$libflags" 123 } 124 tool("solink") { 125 command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x64 link.exe /nologo \$implibflag /DLL /OUT:\$dll /PDB:\$dll.pdb @\$dll.rsp && $python_path gyp-win-tool manifest-wrapper environment.x64 cmd /c if exist \$dll.manifest del \$dll.manifest && $python_path gyp-win-tool manifest-wrapper environment.x64 mt.exe -nologo -manifest \$manifests -out:\$dll.manifest" 126 description = "LINK(DLL) \$dll" 127 restat = "1" 128 rspfile = "\$dll.rsp" 129 rspfile_content = "\$libs \$in_newline \$ldflags" 130 } 131 tool("link") { 132 command = "cmd /c $python_path gyp-win-tool link-wrapper environment.x64 link.exe /nologo /OUT:\$out /PDB:\$out.pdb @\$out.rsp && $python_path gyp-win-tool manifest-wrapper environment.x64 cmd /c if exist \$out.manifest del \$out.manifest && $python_path gyp-win-tool manifest-wrapper environment.x64 mt.exe -nologo -manifest \$manifests -out:\$out.manifest" 133 description = "LINK \$out" 134 rspfile = "\$out.rsp" 135 rspfile_content = "\$in_newline \$libs \$ldflags" 136 } 137 tool("stamp") { 138 command = stamp_command 139 description = "STAMP \$out" 140 } 141 tool("copy") { 142 command = copy_command 143 description = "COPY \$in \$out" 144 } 145 146 # When invoking this toolchain not as the default one, these args will be 147 # passed to the build. They are ignored when this is the default toolchain. 148 toolchain_args() { 149 cpu_arch = "x64" 150 # Normally the build config resets the CPU architecture to 32-bits. Setting 151 # this flag overrides that behavior. 152 force_win64 = true 153 } 154 } 155