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