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