mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 1 | # Copyright 2016 Google Inc. |
| 2 | # |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | declare_args() { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 7 | ar = "ar" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 8 | cc = "cc" |
| 9 | cxx = "c++" |
mtklein | 8079ba6 | 2016-08-16 09:31:16 -0700 | [diff] [blame] | 10 | |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 11 | if (is_android) { |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 12 | if (host_os == "win") { |
Mike Klein | 67702f6 | 2016-12-09 10:32:28 -0500 | [diff] [blame] | 13 | ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar.exe" |
| 14 | cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang.exe" |
| 15 | cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++.exe" |
| 16 | } else { |
| 17 | ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar" |
| 18 | cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang" |
| 19 | cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++" |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 20 | } |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 21 | } |
| 22 | |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 23 | msvc = 2015 |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 24 | |
Kevin Lubick | 2677a9a | 2017-03-28 15:45:41 -0400 | [diff] [blame] | 25 | extra_asmflags = [] |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 26 | extra_cflags = [] |
| 27 | extra_cflags_c = [] |
| 28 | extra_cflags_cc = [] |
| 29 | extra_ldflags = [] |
mtklein | cab0bb7 | 2016-08-26 13:43:19 -0700 | [diff] [blame] | 30 | |
mtklein | 60b7ab7 | 2016-09-20 12:09:12 -0700 | [diff] [blame] | 31 | cc_wrapper = "" |
Herb Derby | 76073c1 | 2016-12-08 19:00:40 -0500 | [diff] [blame] | 32 | malloc = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 33 | } |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 34 | declare_args() { |
| 35 | if (msvc == 2015) { |
| 36 | windk = "C:/Program Files (x86)/Microsoft Visual Studio 14.0" |
| 37 | } else { |
| 38 | windk = "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional" |
| 39 | } |
| 40 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 41 | |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 42 | if (host_os == "win") { |
| 43 | python = "python.bat" |
| 44 | stamp = "cmd.exe /c echo >" |
| 45 | } else { |
| 46 | python = "python" |
| 47 | stamp = "touch" |
| 48 | } |
| 49 | |
Mike Klein | 87c36f2 | 2016-11-13 10:29:25 -0500 | [diff] [blame] | 50 | is_clang = is_android || is_ios || is_mac || (cc == "clang" && cxx == "clang++") |
| 51 | if (!is_clang && !is_win) { |
Mike Klein | 461d328 | 2016-10-11 13:51:55 -0400 | [diff] [blame] | 52 | is_clang = exec_script("is_clang.py", |
| 53 | [ |
| 54 | cc, |
| 55 | cxx, |
| 56 | ], |
| 57 | "value") |
| 58 | } |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 59 | |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 60 | if (is_ios) { |
Matthew Leibowitz | 3150ec6 | 2017-03-14 16:22:32 -0400 | [diff] [blame] | 61 | if (is_tvos) { |
| 62 | sdk = "appletvos" |
| 63 | if (target_cpu == "x86" || target_cpu == "x64") { |
| 64 | sdk = "appletvsimulator" |
| 65 | } |
| 66 | } else { |
| 67 | sdk = "iphoneos" |
| 68 | if (target_cpu == "x86" || target_cpu == "x64") { |
| 69 | sdk = "iphonesimulator" |
| 70 | } |
Mike Klein | 7a5e0f3 | 2017-03-13 09:25:33 -0700 | [diff] [blame] | 71 | } |
| 72 | ios_sysroot = exec_script("find_ios_sysroot.py", [ sdk ], "trim string") |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 73 | } |
| 74 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 75 | config("default") { |
| 76 | asmflags = [] |
| 77 | cflags = [] |
| 78 | cflags_c = [] |
| 79 | cflags_cc = [] |
| 80 | defines = [] |
| 81 | ldflags = [] |
Herb Derby | 76073c1 | 2016-12-08 19:00:40 -0500 | [diff] [blame] | 82 | libs = [] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 83 | |
| 84 | if (is_win) { |
| 85 | cflags += [ |
| 86 | "/FS", # Preserve previous PDB behavior. |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 87 | "/bigobj", # Some of our files are bigger than the regular limits. |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 88 | "/WX", # Treat warnings as errors. |
Ben Wagner | e6b274e | 2017-01-03 17:09:59 -0500 | [diff] [blame] | 89 | "/utf-8", # Set Source and Executable character sets to UTF-8. |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 90 | ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 91 | defines += [ |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 92 | "_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf(). |
| 93 | "_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL. |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 94 | "WIN32_LEAN_AND_MEAN", |
| 95 | "NOMINMAX", |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 96 | ] |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 97 | include_dirs = [ |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 98 | #2017 |
| 99 | "$windk/VC/Tools/MSVC/14.10.25017/include", |
| 100 | |
| 101 | #2015 |
Mike Klein | d301683 | 2016-10-12 15:52:44 -0400 | [diff] [blame] | 102 | "$windk/VC/include", |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 103 | |
Mike Klein | d301683 | 2016-10-12 15:52:44 -0400 | [diff] [blame] | 104 | # For local builds. |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 105 | # 2017 |
| 106 | "$windk/../../../Windows Kits/10/Include/10.0.14393.0/shared", |
| 107 | "$windk/../../../Windows Kits/10/Include/10.0.14393.0/ucrt", |
| 108 | "$windk/../../../Windows Kits/10/Include/10.0.14393.0/um", |
| 109 | "$windk/../../../Windows Kits/10/Include/10.0.14393.0/winrt", |
| 110 | |
| 111 | # 2015 |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 112 | "$windk/../Windows Kits/8.1/Include/shared", |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 113 | "$windk/../Windows Kits/10/Include/10.0.10150.0/ucrt", |
Mike Klein | 3eb7121 | 2016-10-11 17:08:53 -0400 | [diff] [blame] | 114 | "$windk/../Windows Kits/8.1/Include/um", |
Brian Osman | 21d742d | 2017-01-10 13:31:33 -0500 | [diff] [blame] | 115 | "$windk/../Windows Kits/8.1/Include/winrt", |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 116 | |
Mike Klein | d301683 | 2016-10-12 15:52:44 -0400 | [diff] [blame] | 117 | # For builds using win_toolchain asset. |
Brian Osman | 3f28933 | 2017-01-10 10:38:23 -0500 | [diff] [blame] | 118 | "$windk/win_sdk/Include/10.0.14393.0/shared", |
| 119 | "$windk/win_sdk/Include/10.0.14393.0/ucrt", |
| 120 | "$windk/win_sdk/Include/10.0.14393.0/um", |
Brian Osman | 21d742d | 2017-01-10 13:31:33 -0500 | [diff] [blame] | 121 | "$windk/win_sdk/Include/10.0.14393.0/winrt", |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 122 | ] |
Mike Klein | 3eb7121 | 2016-10-11 17:08:53 -0400 | [diff] [blame] | 123 | lib_dirs = [ |
Mike Klein | d301683 | 2016-10-12 15:52:44 -0400 | [diff] [blame] | 124 | # For local builds. |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 125 | # 2017 |
| 126 | "$windk/../../../Windows Kits/10/Lib/10.0.14393.0/ucrt/$target_cpu", |
| 127 | "$windk/../../../Windows Kits/10/Lib/10.0.14393.0/um/$target_cpu", |
| 128 | |
| 129 | #2015 |
Mike Klein | 0bc5a76 | 2016-10-12 22:42:55 -0400 | [diff] [blame] | 130 | "$windk/../Windows Kits/10/Lib/10.0.10150.0/ucrt/$target_cpu", |
| 131 | "$windk/../Windows Kits/8.1/Lib/winv6.3/um/$target_cpu", |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 132 | |
Mike Klein | d301683 | 2016-10-12 15:52:44 -0400 | [diff] [blame] | 133 | # For builds using win_toolchain asset. |
Brian Osman | 3f28933 | 2017-01-10 10:38:23 -0500 | [diff] [blame] | 134 | "$windk/win_sdk/Lib/10.0.14393.0/ucrt/$target_cpu", |
| 135 | "$windk/win_sdk/Lib/10.0.14393.0/um/$target_cpu", |
Mike Klein | 3eb7121 | 2016-10-11 17:08:53 -0400 | [diff] [blame] | 136 | ] |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 137 | |
| 138 | #2017 |
| 139 | lib_dirs += [ "$windk/VC/Tools/MSVC/14.10.25017/lib/$target_cpu" ] |
| 140 | |
| 141 | #2015 |
Mike Klein | 0bc5a76 | 2016-10-12 22:42:55 -0400 | [diff] [blame] | 142 | if (target_cpu == "x86") { |
| 143 | lib_dirs += [ "$windk/VC/lib" ] |
| 144 | } else { |
| 145 | lib_dirs += [ "$windk/VC/lib/amd64" ] |
| 146 | } |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 147 | } else { |
| 148 | cflags += [ |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 149 | "-fstrict-aliasing", |
| 150 | "-fPIC", |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 151 | "-Werror", |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 152 | ] |
Mike Klein | 28f5b77 | 2017-04-06 23:04:42 -0400 | [diff] [blame] | 153 | cflags_cc += [ "-std=c++11" ] |
Mike Klein | eec23d1 | 2017-03-26 20:11:48 -0400 | [diff] [blame] | 154 | |
| 155 | # The main idea is to slim the exported API, but these flags also improve link time on Mac. |
| 156 | # These would make stack traces worse on Linux, so we don't just set them willy-nilly. |
Mike Klein | 8cb6648 | 2017-03-28 14:16:22 -0400 | [diff] [blame] | 157 | if (is_component_build || is_ios || is_mac) { |
Mike Klein | eec23d1 | 2017-03-26 20:11:48 -0400 | [diff] [blame] | 158 | cflags += [ "-fvisibility=hidden" ] |
| 159 | cflags_cc += [ "-fvisibility-inlines-hidden" ] |
| 160 | } |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 161 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 162 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 163 | if (current_cpu == "arm") { |
| 164 | cflags += [ |
| 165 | "-march=armv7-a", |
| 166 | "-mfpu=neon", |
| 167 | "-mthumb", |
| 168 | ] |
| 169 | } else if (current_cpu == "mipsel") { |
| 170 | cflags += [ |
Mike Klein | e632003 | 2017-03-04 05:39:54 -0500 | [diff] [blame] | 171 | "-no-integrated-as", # Clang <4.0 doesn't understand 'usw' mnemonic. |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 172 | "-march=mips32r2", |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 173 | ] |
Mike Klein | 5d8cf29 | 2016-10-12 19:36:09 -0400 | [diff] [blame] | 174 | } else if (current_cpu == "x86" && !is_win) { |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 175 | asmflags += [ "-m32" ] |
| 176 | cflags += [ |
| 177 | "-m32", |
| 178 | "-msse2", |
| 179 | "-mfpmath=sse", |
| 180 | ] |
| 181 | ldflags += [ "-m32" ] |
| 182 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 183 | |
Herb Derby | 76073c1 | 2016-12-08 19:00:40 -0500 | [diff] [blame] | 184 | if (malloc != "" && !is_win) { |
| 185 | cflags += [ |
| 186 | "-fno-builtin-malloc", |
| 187 | "-fno-builtin-calloc", |
| 188 | "-fno-builtin-realloc", |
| 189 | "-fno-builtin-free", |
| 190 | ] |
| 191 | libs += [ malloc ] |
| 192 | } |
| 193 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 194 | if (is_android) { |
| 195 | asmflags += [ |
| 196 | "--target=$ndk_target", |
| 197 | "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", |
| 198 | ] |
| 199 | cflags += [ |
| 200 | "--sysroot=$ndk/platforms/$ndk_platform", |
| 201 | "--target=$ndk_target", |
| 202 | "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", |
| 203 | ] |
| 204 | cflags_cc += [ |
| 205 | "-isystem$ndk/sources/android/support/include", |
Mike Klein | b7ce80b | 2016-12-14 13:17:53 -0500 | [diff] [blame] | 206 | "-isystem$ndk/sources/cxx-stl/gnu-libstdc++/4.9/include", |
| 207 | "-isystem$ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ndk_stdlib/include", |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 208 | ] |
| 209 | ldflags += [ |
| 210 | "--sysroot=$ndk/platforms/$ndk_platform", |
| 211 | "--target=$ndk_target", |
| 212 | "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 213 | ] |
| 214 | lib_dirs = [ |
Mike Klein | b7ce80b | 2016-12-14 13:17:53 -0500 | [diff] [blame] | 215 | "$ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ndk_stdlib", |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 216 | "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x", |
| 217 | ] |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 218 | |
Mike Klein | 4fdc543 | 2016-10-11 11:21:36 -0400 | [diff] [blame] | 219 | if (current_cpu == "mips64el") { |
| 220 | # The r13 NDK omits /usr/lib from the MIPS64 sysroots, but Clang searches |
| 221 | # for /usr/lib64 as $PATH_TO_USR_LIB/../lib64. If there's no /usr/lib, |
| 222 | # it can't find /usr/lib64. We must point Clang at /usr/lib64 manually. |
| 223 | lib_dirs += [ "$ndk/platforms/$ndk_platform/usr/lib64" ] |
Mike Klein | 978cceb | 2016-12-08 10:29:27 -0500 | [diff] [blame] | 224 | ldflags += [ "-B$ndk/platforms/$ndk_platform/usr/lib64" ] |
Mike Klein | 4fdc543 | 2016-10-11 11:21:36 -0400 | [diff] [blame] | 225 | } |
| 226 | |
Mike Klein | b7ce80b | 2016-12-14 13:17:53 -0500 | [diff] [blame] | 227 | libs += [ "gnustl_static" ] |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 228 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 229 | |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 230 | if (is_ios) { |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 231 | _target = target_cpu |
| 232 | if (target_cpu == "arm") { |
| 233 | _target = "armv7" |
Mike Klein | 7a5e0f3 | 2017-03-13 09:25:33 -0700 | [diff] [blame] | 234 | } else if (target_cpu == "x86") { |
| 235 | _target = "i386" |
| 236 | } else if (target_cpu == "x64") { |
| 237 | _target = "x86_64" |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 238 | } |
Mike Klein | 4fe2b15 | 2017-02-17 15:36:01 -0500 | [diff] [blame] | 239 | asmflags += [ |
| 240 | "-isysroot", |
| 241 | ios_sysroot, |
| 242 | "-arch", |
| 243 | _target, |
| 244 | ] |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 245 | cflags += [ |
Mike Klein | 6749af4 | 2016-11-07 15:38:48 -0500 | [diff] [blame] | 246 | "-isysroot", |
| 247 | ios_sysroot, |
| 248 | "-arch", |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 249 | _target, |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 250 | ] |
| 251 | cflags_cc += [ "-stdlib=libc++" ] |
| 252 | ldflags += [ |
Mike Klein | 6749af4 | 2016-11-07 15:38:48 -0500 | [diff] [blame] | 253 | "-isysroot", |
| 254 | ios_sysroot, |
| 255 | "-arch", |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 256 | _target, |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 257 | "-stdlib=libc++", |
| 258 | ] |
Herb Derby | 76073c1 | 2016-12-08 19:00:40 -0500 | [diff] [blame] | 259 | libs += [ "objc" ] |
Mike Klein | 7d30288 | 2016-11-03 14:06:31 -0400 | [diff] [blame] | 260 | } |
| 261 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 262 | if (is_linux) { |
Herb Derby | 76073c1 | 2016-12-08 19:00:40 -0500 | [diff] [blame] | 263 | libs += [ "pthread" ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (sanitize != "") { |
| 267 | # You can either pass the sanitizers directly, e.g. "address,undefined", |
| 268 | # or pass one of the couple common aliases used by the bots. |
| 269 | sanitizers = sanitize |
| 270 | if (sanitize == "ASAN") { |
| 271 | sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr" |
| 272 | } else if (sanitize == "TSAN") { |
| 273 | sanitizers = "thread" |
| 274 | } else if (sanitize == "MSAN") { |
| 275 | sanitizers = "memory" |
| 276 | } |
| 277 | |
| 278 | cflags += [ |
| 279 | "-fsanitize=$sanitizers", |
| 280 | "-fno-sanitize-recover=$sanitizers", |
| 281 | "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"), |
| 282 | ] |
| 283 | ldflags += [ "-fsanitize=$sanitizers" ] |
| 284 | if (sanitizers == "memory") { |
| 285 | cflags += [ "-fsanitize-memory-track-origins" ] |
| 286 | cflags_cc += [ "-stdlib=libc++" ] |
| 287 | ldflags += [ "-stdlib=libc++" ] |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
Mike Klein | 6e55fef | 2016-10-26 11:41:47 -0400 | [diff] [blame] | 292 | config("no_exceptions") { |
| 293 | # Exceptions are disabled by default on Windows. (Use /EHsc to enable them.) |
| 294 | if (!is_win) { |
| 295 | cflags_cc = [ "-fno-exceptions" ] |
| 296 | } |
| 297 | } |
| 298 | |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 299 | config("warnings") { |
| 300 | cflags = [] |
| 301 | cflags_cc = [] |
Mike Klein | 43c2526 | 2016-10-20 10:17:47 -0400 | [diff] [blame] | 302 | cflags_objc = [] |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 303 | if (is_win) { |
| 304 | cflags += [ |
| 305 | "/W3", # Turn on lots of warnings. |
| 306 | |
| 307 | # Disable a bunch of warnings: |
| 308 | "/wd4244", # conversion from 'float' to 'int', possible loss of data |
| 309 | "/wd4267", # conversion from 'size_t' to 'int', possible loss of data |
| 310 | "/wd4800", # forcing value to bool 'true' or 'false' (performance warning) |
| 311 | |
| 312 | # Probably only triggers when /EHsc is enabled. |
| 313 | "/wd4291", # no matching operator delete found; |
| 314 | # memory will not be freed if initialization throws an exception |
| 315 | ] |
| 316 | } else { |
| 317 | cflags += [ |
| 318 | "-Wall", |
| 319 | "-Wextra", |
| 320 | "-Winit-self", |
| 321 | "-Wpointer-arith", |
| 322 | "-Wsign-compare", |
| 323 | "-Wvla", |
| 324 | |
| 325 | "-Wno-deprecated-declarations", |
Mike Klein | db402ca | 2016-12-13 12:46:05 -0500 | [diff] [blame] | 326 | "-Wno-maybe-uninitialized", |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 327 | ] |
| 328 | cflags_cc += [ "-Wnon-virtual-dtor" ] |
| 329 | |
| 330 | if (is_clang) { |
| 331 | cflags += [ |
| 332 | "-Weverything", |
| 333 | "-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings. |
| 334 | ] |
| 335 | |
Mike Klein | b48fd3c | 2017-01-23 11:58:53 -0500 | [diff] [blame] | 336 | if ((target_cpu == "x86" && is_android) || |
| 337 | (target_cpu == "arm" && is_ios)) { |
| 338 | # Clang seems to think new/malloc will only be 4-byte aligned on x86 Android and 32-bit iOS. |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 339 | # We're pretty sure it's actually 8-byte alignment. |
| 340 | cflags += [ "-Wno-over-aligned" ] |
| 341 | } |
| 342 | |
| 343 | cflags += [ |
| 344 | "-Wno-cast-align", |
| 345 | "-Wno-conditional-uninitialized", |
| 346 | "-Wno-conversion", |
| 347 | "-Wno-disabled-macro-expansion", |
| 348 | "-Wno-documentation", |
| 349 | "-Wno-documentation-unknown-command", |
| 350 | "-Wno-double-promotion", |
| 351 | "-Wno-exit-time-destructors", # TODO: OK outside libskia |
| 352 | "-Wno-float-conversion", |
| 353 | "-Wno-float-equal", |
| 354 | "-Wno-format-nonliteral", |
| 355 | "-Wno-global-constructors", # TODO: OK outside libskia |
| 356 | "-Wno-gnu-zero-variadic-macro-arguments", |
| 357 | "-Wno-missing-prototypes", |
| 358 | "-Wno-missing-variable-declarations", |
| 359 | "-Wno-pedantic", |
| 360 | "-Wno-reserved-id-macro", |
| 361 | "-Wno-shadow", |
| 362 | "-Wno-shift-sign-overflow", |
| 363 | "-Wno-sign-conversion", |
Matt Sarett | d3ed402 | 2017-01-04 17:13:44 -0500 | [diff] [blame] | 364 | "-Wno-signed-enum-bitfield", |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 365 | "-Wno-switch-enum", |
| 366 | "-Wno-undef", |
| 367 | "-Wno-unreachable-code", |
| 368 | "-Wno-unreachable-code-break", |
| 369 | "-Wno-unreachable-code-return", |
| 370 | "-Wno-unused-macros", |
| 371 | "-Wno-unused-member-function", |
| 372 | ] |
| 373 | cflags_cc += [ |
| 374 | "-Wno-abstract-vbase-init", |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 375 | "-Wno-weak-vtables", |
| 376 | ] |
| 377 | |
| 378 | # We are unlikely to want to fix these. |
| 379 | cflags += [ |
| 380 | "-Wno-covered-switch-default", |
| 381 | "-Wno-deprecated", |
| 382 | "-Wno-implicit-fallthrough", |
| 383 | "-Wno-missing-noreturn", |
| 384 | "-Wno-old-style-cast", |
| 385 | "-Wno-padded", |
| 386 | ] |
| 387 | cflags_cc += [ |
| 388 | "-Wno-c++98-compat", |
| 389 | "-Wno-c++98-compat-pedantic", |
| 390 | "-Wno-undefined-func-template", |
| 391 | ] |
Mike Klein | 43c2526 | 2016-10-20 10:17:47 -0400 | [diff] [blame] | 392 | cflags_objc += [ |
| 393 | "-Wno-direct-ivar-access", |
| 394 | "-Wno-objc-interface-ivars", |
| 395 | ] |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | } |
Mike Klein | 50500ad | 2016-11-16 12:13:44 -0500 | [diff] [blame] | 399 | config("warnings_except_public_headers") { |
| 400 | if (!is_win) { |
| 401 | cflags = [ "-Wno-unused-parameter" ] |
| 402 | } |
| 403 | } |
Mike Klein | c7165c2 | 2016-10-12 23:58:06 -0400 | [diff] [blame] | 404 | |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 405 | config("extra_flags") { |
Kevin Lubick | 2677a9a | 2017-03-28 15:45:41 -0400 | [diff] [blame] | 406 | asmflags = extra_asmflags |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 407 | cflags = extra_cflags |
| 408 | cflags_c = extra_cflags_c |
| 409 | cflags_cc = extra_cflags_cc |
| 410 | ldflags = extra_ldflags |
| 411 | } |
| 412 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 413 | config("debug_symbols") { |
| 414 | # It's annoying to wait for full debug symbols to push over |
| 415 | # to Android devices. -gline-tables-only is a lot slimmer. |
| 416 | if (is_android) { |
| 417 | cflags = [ "-gline-tables-only" ] |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 418 | } else if (is_win) { |
| 419 | cflags = [ "/Zi" ] |
Mike Klein | 5286d6c | 2016-10-13 13:19:25 -0400 | [diff] [blame] | 420 | ldflags = [ "/DEBUG" ] |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 421 | } else { |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 422 | cflags = [ "-g" ] |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | config("no_rtti") { |
| 427 | if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 428 | if (is_win) { |
| 429 | cflags_cc = [ "/GR-" ] |
| 430 | } else { |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 431 | cflags_cc = [ "-fno-rtti" ] |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | config("release") { |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 437 | if (is_win) { |
Mike Klein | 916ca1d | 2016-10-20 13:34:18 -0400 | [diff] [blame] | 438 | cflags = [ |
| 439 | "/O2", |
| 440 | "/Zc:inline", |
Mike Klein | 8ffb260 | 2016-10-20 15:45:02 -0400 | [diff] [blame] | 441 | "/GS-", |
Mike Klein | 916ca1d | 2016-10-20 13:34:18 -0400 | [diff] [blame] | 442 | ] |
Mike Klein | 90a381f | 2016-10-20 13:52:38 -0400 | [diff] [blame] | 443 | ldflags = [ |
| 444 | "/OPT:ICF", |
| 445 | "/OPT:REF", |
| 446 | ] |
Mike Klein | cc300a1 | 2016-10-12 16:25:27 -0400 | [diff] [blame] | 447 | } else { |
Mike Klein | 0bcfeac | 2016-10-19 22:24:10 -0400 | [diff] [blame] | 448 | cflags = [ |
| 449 | "-O3", |
Mike Klein | bd9be4d | 2017-02-10 07:59:39 -0500 | [diff] [blame] | 450 | "-fdata-sections", |
| 451 | "-ffunction-sections", |
Mike Klein | 0bcfeac | 2016-10-19 22:24:10 -0400 | [diff] [blame] | 452 | ] |
Mike Klein | bd9be4d | 2017-02-10 07:59:39 -0500 | [diff] [blame] | 453 | if (is_mac || is_ios) { |
| 454 | ldflags = [ "-dead_strip" ] |
| 455 | } else { |
| 456 | ldflags = [ "-Wl,--gc-sections" ] |
| 457 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 458 | } |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 459 | defines = [ "NDEBUG" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | config("executable") { |
Mike Klein | c5875fb | 2016-12-06 10:46:02 -0500 | [diff] [blame] | 463 | if (is_android) { |
| 464 | ldflags = [ "-pie" ] |
| 465 | } else if (is_mac) { |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 466 | ldflags = [ "-Wl,-rpath,@loader_path/." ] |
| 467 | } else if (is_linux) { |
mtklein | a846c72 | 2016-09-15 10:44:15 -0700 | [diff] [blame] | 468 | ldflags = [ |
| 469 | "-rdynamic", |
| 470 | "-Wl,-rpath,\$ORIGIN", |
| 471 | ] |
Mike Klein | 4b6b503 | 2016-11-06 11:54:19 -0500 | [diff] [blame] | 472 | } else if (is_win) { |
| 473 | ldflags = [ |
| 474 | "/SUBSYSTEM:CONSOLE", # Quiet "no subsystem specified; CONSOLE assumed". |
| 475 | "/INCREMENTAL:NO", # Quiet warnings about failing to incrementally link by never trying to. |
| 476 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 477 | } |
| 478 | } |
| 479 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 480 | toolchain("msvc") { |
Mike Klein | 3eb7121 | 2016-10-11 17:08:53 -0400 | [diff] [blame] | 481 | lib_dir_switch = "/LIBPATH:" |
| 482 | |
Ben Wagner | 4e8472c | 2017-03-20 16:53:05 -0400 | [diff] [blame] | 483 | if (msvc == 2015) { |
| 484 | bin = "$windk/VC/bin/amd64" |
| 485 | env_setup = "" |
| 486 | if (target_cpu == "x86") { |
| 487 | bin += "_x86" |
| 488 | env_setup = "cmd /c $windk/win_sdk/bin/SetEnv.cmd /x86 && " |
| 489 | } |
| 490 | } else { |
| 491 | bin = "$windk/VC/Tools/MSVC/14.10.25017/bin/HostX64/$target_cpu" |
| 492 | env_setup = "" |
| 493 | if (target_cpu == "x86") { |
| 494 | print("Be sure to run") |
| 495 | print("$windk/VC/Auxiliary/Build/vcvarsall.bat amd64_x86") |
| 496 | print("to set up your environment before running ninja.") |
| 497 | } |
Mike Klein | 0bc5a76 | 2016-10-12 22:42:55 -0400 | [diff] [blame] | 498 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 499 | |
Mike Klein | ed1b902 | 2017-02-21 12:13:44 -0500 | [diff] [blame] | 500 | tool("asm") { |
Mike Klein | 5f80485 | 2017-03-29 19:29:13 -0400 | [diff] [blame] | 501 | _ml = "ml" |
| 502 | if (target_cpu == "x64") { |
| 503 | _ml += "64" |
| 504 | } |
| 505 | command = "$env_setup$bin/$_ml.exe /nologo /c /Fo {{output}} {{source}}" |
Mike Klein | ed1b902 | 2017-02-21 12:13:44 -0500 | [diff] [blame] | 506 | outputs = [ |
| 507 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
| 508 | ] |
| 509 | description = "assemble {{source}}" |
| 510 | } |
| 511 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 512 | tool("cc") { |
| 513 | rspfile = "{{output}}.rsp" |
| 514 | precompiled_header_type = "msvc" |
| 515 | pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" |
| 516 | |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 517 | # Label names may have spaces so pdbname must be quoted. |
Mike Klein | 0bc5a76 | 2016-10-12 22:42:55 -0400 | [diff] [blame] | 518 | command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 519 | depsformat = "msvc" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 520 | outputs = [ |
| 521 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 522 | ] |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 523 | rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
Mike Klein | c756e86 | 2016-10-13 14:31:01 -0400 | [diff] [blame] | 524 | description = "compile {{source}}" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | tool("cxx") { |
| 528 | rspfile = "{{output}}.rsp" |
| 529 | precompiled_header_type = "msvc" |
| 530 | pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" |
| 531 | |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 532 | # Label names may have spaces so pdbname must be quoted. |
Mike Klein | 0bc5a76 | 2016-10-12 22:42:55 -0400 | [diff] [blame] | 533 | command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 534 | depsformat = "msvc" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 535 | outputs = [ |
| 536 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
| 537 | ] |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 538 | rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" |
Mike Klein | c756e86 | 2016-10-13 14:31:01 -0400 | [diff] [blame] | 539 | description = "compile {{source}}" |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 540 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 541 | |
| 542 | tool("alink") { |
| 543 | rspfile = "{{output}}.rsp" |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 544 | |
Mike Klein | c756e86 | 2016-10-13 14:31:01 -0400 | [diff] [blame] | 545 | command = "$env_setup$bin/lib.exe /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 546 | outputs = [ |
| 547 | # Ignore {{output_extension}} and always use .lib, there's no reason to |
| 548 | # allow targets to override this extension on Windows. |
| 549 | "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 550 | ] |
| 551 | default_output_extension = ".lib" |
| 552 | default_output_dir = "{{target_out_dir}}" |
| 553 | |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 554 | # inputs_newline works around a fixed per-line buffer size in the linker. |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 555 | rspfile_content = "{{inputs_newline}}" |
Mike Klein | c756e86 | 2016-10-13 14:31:01 -0400 | [diff] [blame] | 556 | description = "link {{output}}" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Mike Klein | 1a8d675 | 2016-10-17 11:51:11 -0400 | [diff] [blame] | 559 | tool("solink") { |
| 560 | dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}" |
| 561 | libname = "${dllname}.lib" |
| 562 | pdbname = "${dllname}.pdb" |
| 563 | rspfile = "${dllname}.rsp" |
| 564 | |
| 565 | command = "$env_setup$bin/link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile" |
| 566 | outputs = [ |
| 567 | dllname, |
| 568 | libname, |
| 569 | pdbname, |
| 570 | ] |
| 571 | default_output_extension = ".dll" |
| 572 | default_output_dir = "{{root_out_dir}}" |
| 573 | |
| 574 | link_output = libname |
| 575 | depend_output = libname |
| 576 | runtime_outputs = [ |
| 577 | dllname, |
| 578 | pdbname, |
| 579 | ] |
| 580 | |
| 581 | # I don't quite understand this. Aping Chrome's toolchain/win/BUILD.gn. |
| 582 | restat = true |
| 583 | |
| 584 | # inputs_newline works around a fixed per-line buffer size in the linker. |
| 585 | rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" |
| 586 | description = "link {{output}}" |
| 587 | } |
| 588 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 589 | tool("link") { |
| 590 | exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 591 | pdbname = "$exename.pdb" |
| 592 | rspfile = "$exename.rsp" |
| 593 | |
Mike Klein | 0bc5a76 | 2016-10-12 22:42:55 -0400 | [diff] [blame] | 594 | command = |
| 595 | "$env_setup$bin/link.exe /nologo /OUT:$exename /PDB:$pdbname @$rspfile" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 596 | |
| 597 | default_output_extension = ".exe" |
| 598 | default_output_dir = "{{root_out_dir}}" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 599 | outputs = [ |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 600 | exename, |
| 601 | ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 602 | |
Mike Klein | 0f61faa | 2016-10-11 16:26:57 -0400 | [diff] [blame] | 603 | # inputs_newline works around a fixed per-line buffer size in the linker. |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 604 | rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" |
Mike Klein | c756e86 | 2016-10-13 14:31:01 -0400 | [diff] [blame] | 605 | description = "link {{output}}" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 606 | } |
| 607 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 608 | tool("stamp") { |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 609 | command = "$stamp {{output}}" |
Mike Klein | c756e86 | 2016-10-13 14:31:01 -0400 | [diff] [blame] | 610 | description = "stamp {{output}}" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 611 | } |
Mike Klein | 1a8d675 | 2016-10-17 11:51:11 -0400 | [diff] [blame] | 612 | |
| 613 | tool("copy") { |
| 614 | cp_py = rebase_path("cp.py") |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 615 | command = "$python $cp_py {{source}} {{output}}" |
Mike Klein | 1a8d675 | 2016-10-17 11:51:11 -0400 | [diff] [blame] | 616 | description = "copy {{source}} {{output}}" |
| 617 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 618 | } |
| 619 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 620 | toolchain("gcc_like") { |
| 621 | lib_switch = "-l" |
| 622 | lib_dir_switch = "-L" |
| 623 | |
| 624 | tool("cc") { |
| 625 | depfile = "{{output}}.d" |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 626 | command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 627 | depsformat = "gcc" |
| 628 | outputs = [ |
| 629 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 630 | ] |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 631 | description = "compile {{source}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | tool("cxx") { |
| 635 | depfile = "{{output}}.d" |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 636 | command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 637 | depsformat = "gcc" |
| 638 | outputs = [ |
| 639 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 640 | ] |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 641 | description = "compile {{source}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 642 | } |
| 643 | |
Mike Klein | 43c2526 | 2016-10-20 10:17:47 -0400 | [diff] [blame] | 644 | tool("objc") { |
| 645 | depfile = "{{output}}.d" |
| 646 | command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}" |
| 647 | depsformat = "gcc" |
| 648 | outputs = [ |
| 649 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 650 | ] |
| 651 | description = "compile {{source}}" |
| 652 | } |
| 653 | |
| 654 | tool("objcxx") { |
| 655 | depfile = "{{output}}.d" |
| 656 | command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objc}} -c {{source}} -o {{output}}" |
| 657 | depsformat = "gcc" |
| 658 | outputs = [ |
| 659 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 660 | ] |
| 661 | description = "compile {{source}}" |
| 662 | } |
| 663 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 664 | tool("asm") { |
| 665 | depfile = "{{output}}.d" |
mtklein | 60b7ab7 | 2016-09-20 12:09:12 -0700 | [diff] [blame] | 666 | command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 667 | depsformat = "gcc" |
| 668 | outputs = [ |
| 669 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 670 | ] |
Mike Klein | 39312c8 | 2017-04-26 10:33:39 -0400 | [diff] [blame] | 671 | description = "assemble {{source}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | tool("alink") { |
Mike Klein | 44b36a2 | 2016-11-06 11:20:09 -0500 | [diff] [blame] | 675 | rspfile = "{{output}}.rsp" |
| 676 | rspfile_content = "{{inputs}}" |
| 677 | ar_py = rebase_path("ar.py") |
| 678 | command = "$python $ar_py $ar {{output}} $rspfile" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 679 | outputs = [ |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 680 | "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 681 | ] |
| 682 | default_output_extension = ".a" |
| 683 | output_prefix = "lib" |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 684 | description = "link {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | tool("solink") { |
| 688 | soname = "{{target_output_name}}{{output_extension}}" |
| 689 | |
| 690 | rpath = "-Wl,-soname,$soname" |
| 691 | if (is_mac) { |
| 692 | rpath = "-Wl,-install_name,@rpath/$soname" |
| 693 | } |
| 694 | |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 695 | command = "$cc_wrapper $cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 696 | outputs = [ |
| 697 | "{{root_out_dir}}/$soname", |
| 698 | ] |
| 699 | output_prefix = "lib" |
| 700 | default_output_extension = ".so" |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 701 | description = "link {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | tool("link") { |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame] | 705 | command = "$cc_wrapper $cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 706 | outputs = [ |
| 707 | "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 708 | ] |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 709 | description = "link {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | tool("stamp") { |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 713 | command = "$stamp {{output}}" |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 714 | description = "stamp {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | tool("copy") { |
Mike Klein | 1a8d675 | 2016-10-17 11:51:11 -0400 | [diff] [blame] | 718 | cp_py = rebase_path("cp.py") |
Mike Klein | 82364ba | 2016-10-24 16:49:15 -0400 | [diff] [blame] | 719 | command = "$python $cp_py {{source}} {{output}}" |
Mike Klein | 24267ff | 2016-10-17 10:41:41 -0400 | [diff] [blame] | 720 | description = "copy {{source}} {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 721 | } |
| 722 | } |