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) { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 12 | ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar" |
mtklein | 7d6fb2c | 2016-08-25 14:50:44 -0700 | [diff] [blame] | 13 | cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang" |
| 14 | cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++" |
| 15 | } |
| 16 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 17 | windk = "" |
| 18 | |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 19 | extra_cflags = [] |
| 20 | extra_cflags_c = [] |
| 21 | extra_cflags_cc = [] |
| 22 | extra_ldflags = [] |
mtklein | cab0bb7 | 2016-08-26 13:43:19 -0700 | [diff] [blame] | 23 | |
mtklein | 60b7ab7 | 2016-09-20 12:09:12 -0700 | [diff] [blame] | 24 | cc_wrapper = "" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 25 | } |
| 26 | |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 27 | is_clang = exec_script("is_clang.py", |
| 28 | [ |
| 29 | cc, |
| 30 | cxx, |
| 31 | ], |
| 32 | "value") |
| 33 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 34 | config("default") { |
| 35 | asmflags = [] |
| 36 | cflags = [] |
| 37 | cflags_c = [] |
| 38 | cflags_cc = [] |
| 39 | defines = [] |
| 40 | ldflags = [] |
| 41 | |
| 42 | if (is_win) { |
| 43 | cflags += [ |
| 44 | "/FS", # Preserve previous PDB behavior. |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 45 | "/bigobj", # Some of our files are bigger than the regular limits. |
| 46 | ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 47 | cflags_c += [ "/TC" ] |
| 48 | cflags_cc += [ "/TP" ] |
| 49 | defines += [ |
| 50 | "_HAS_EXCEPTIONS=0", |
| 51 | "WIN32_LEAN_AND_MEAN", |
| 52 | "NOMINMAX", |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 53 | ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 54 | } else { |
| 55 | cflags += [ |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 56 | "-O1", |
| 57 | "-fstrict-aliasing", |
| 58 | "-fPIC", |
| 59 | "-fvisibility=hidden", |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 60 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 61 | "-Werror", |
| 62 | "-Wall", |
| 63 | "-Wextra", |
| 64 | "-Winit-self", |
| 65 | "-Wpointer-arith", |
| 66 | "-Wsign-compare", |
| 67 | "-Wvla", |
| 68 | |
| 69 | "-Wno-deprecated-declarations", |
| 70 | "-Wno-unused-parameter", |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 71 | ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 72 | cflags_cc += [ |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 73 | "-std=c++11", |
| 74 | "-fno-exceptions", |
| 75 | "-fno-threadsafe-statics", |
| 76 | "-fvisibility-inlines-hidden", |
| 77 | |
| 78 | "-Wnon-virtual-dtor", |
| 79 | ] |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 80 | if (is_clang) { |
| 81 | cflags += [ |
| 82 | "-Weverything", |
| 83 | "-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings. |
| 84 | ] |
| 85 | |
Mike Klein | 7bfc08b | 2016-09-27 07:41:45 -0400 | [diff] [blame] | 86 | if (is_android && target_cpu == "x86") { |
| 87 | # Clang seems to think new/malloc will only be 4-byte aligned on x86 Android. |
| 88 | # We're pretty sure it's actually 8-byte alignment. |
| 89 | cflags += [ "-Wno-over-aligned" ] |
| 90 | } |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 91 | |
| 92 | cflags += [ |
| 93 | "-Wno-cast-align", |
Mike Klein | 2cc7f8d | 2016-09-26 15:49:04 -0400 | [diff] [blame] | 94 | "-Wno-conditional-uninitialized", |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 95 | "-Wno-conversion", |
| 96 | "-Wno-disabled-macro-expansion", |
| 97 | "-Wno-documentation", |
| 98 | "-Wno-documentation-unknown-command", |
| 99 | "-Wno-double-promotion", |
| 100 | "-Wno-exit-time-destructors", # TODO: OK outside libskia |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 101 | "-Wno-float-conversion", |
| 102 | "-Wno-float-equal", |
Mike Klein | 2cc7f8d | 2016-09-26 15:49:04 -0400 | [diff] [blame] | 103 | "-Wno-format-nonliteral", |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 104 | "-Wno-global-constructors", # TODO: OK outside libskia |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 105 | "-Wno-gnu-zero-variadic-macro-arguments", |
| 106 | "-Wno-missing-prototypes", |
| 107 | "-Wno-missing-variable-declarations", |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 108 | "-Wno-pedantic", |
| 109 | "-Wno-reserved-id-macro", |
Mike Klein | 2cc7f8d | 2016-09-26 15:49:04 -0400 | [diff] [blame] | 110 | "-Wno-shadow", |
| 111 | "-Wno-shift-sign-overflow", |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 112 | "-Wno-sign-conversion", |
| 113 | "-Wno-switch-enum", |
| 114 | "-Wno-undef", |
| 115 | "-Wno-unreachable-code", |
| 116 | "-Wno-unreachable-code-break", |
| 117 | "-Wno-unreachable-code-return", |
| 118 | "-Wno-unused-macros", |
| 119 | "-Wno-unused-member-function", |
| 120 | ] |
| 121 | cflags_cc += [ |
| 122 | "-Wno-abstract-vbase-init", |
| 123 | "-Wno-range-loop-analysis", |
| 124 | "-Wno-weak-vtables", |
| 125 | ] |
| 126 | |
| 127 | # We are unlikely to want to fix these. |
| 128 | cflags += [ |
Mike Klein | 2cc7f8d | 2016-09-26 15:49:04 -0400 | [diff] [blame] | 129 | "-Wno-covered-switch-default", |
| 130 | "-Wno-deprecated", |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 131 | "-Wno-implicit-fallthrough", |
| 132 | "-Wno-missing-noreturn", |
| 133 | "-Wno-old-style-cast", |
| 134 | "-Wno-padded", |
| 135 | ] |
| 136 | cflags_cc += [ |
| 137 | "-Wno-c++98-compat", |
| 138 | "-Wno-c++98-compat-pedantic", |
Mike Klein | 2cc7f8d | 2016-09-26 15:49:04 -0400 | [diff] [blame] | 139 | "-Wno-undefined-func-template", |
mtklein | f347c51 | 2016-09-26 08:40:12 -0700 | [diff] [blame] | 140 | ] |
| 141 | } |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 142 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 143 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 144 | if (current_cpu == "arm") { |
| 145 | cflags += [ |
| 146 | "-march=armv7-a", |
| 147 | "-mfpu=neon", |
| 148 | "-mthumb", |
| 149 | ] |
| 150 | } else if (current_cpu == "mipsel") { |
| 151 | cflags += [ |
| 152 | "-march=mips32r2", |
| 153 | "-mdspr2", |
| 154 | ] |
| 155 | } else if (current_cpu == "x86") { |
| 156 | asmflags += [ "-m32" ] |
| 157 | cflags += [ |
| 158 | "-m32", |
| 159 | "-msse2", |
| 160 | "-mfpmath=sse", |
| 161 | ] |
| 162 | ldflags += [ "-m32" ] |
| 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 (is_android) { |
| 166 | asmflags += [ |
| 167 | "--target=$ndk_target", |
| 168 | "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", |
| 169 | ] |
| 170 | cflags += [ |
| 171 | "--sysroot=$ndk/platforms/$ndk_platform", |
| 172 | "--target=$ndk_target", |
| 173 | "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", |
| 174 | ] |
| 175 | cflags_cc += [ |
| 176 | "-isystem$ndk/sources/android/support/include", |
| 177 | "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include", |
| 178 | ] |
| 179 | ldflags += [ |
| 180 | "--sysroot=$ndk/platforms/$ndk_platform", |
| 181 | "--target=$ndk_target", |
| 182 | "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", |
| 183 | "-pie", |
| 184 | ] |
| 185 | lib_dirs = [ |
| 186 | "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib", |
| 187 | "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x", |
| 188 | ] |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 189 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 190 | libs = [ |
| 191 | # Order matters here! Keep these three in exactly this order. |
| 192 | "c++_static", |
| 193 | "c++abi", |
| 194 | "android_support", |
| 195 | ] |
| 196 | if (target_cpu == "arm") { |
| 197 | libs += [ "unwind" ] |
mtklein | 2b3c2a3 | 2016-09-08 08:39:34 -0700 | [diff] [blame] | 198 | } |
| 199 | } |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 200 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 201 | if (is_linux) { |
| 202 | libs = [ "pthread" ] |
| 203 | } |
| 204 | |
| 205 | if (sanitize != "") { |
| 206 | # You can either pass the sanitizers directly, e.g. "address,undefined", |
| 207 | # or pass one of the couple common aliases used by the bots. |
| 208 | sanitizers = sanitize |
| 209 | if (sanitize == "ASAN") { |
| 210 | 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" |
| 211 | } else if (sanitize == "TSAN") { |
| 212 | sanitizers = "thread" |
| 213 | } else if (sanitize == "MSAN") { |
| 214 | sanitizers = "memory" |
| 215 | } |
| 216 | |
| 217 | cflags += [ |
| 218 | "-fsanitize=$sanitizers", |
| 219 | "-fno-sanitize-recover=$sanitizers", |
| 220 | "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"), |
| 221 | ] |
| 222 | ldflags += [ "-fsanitize=$sanitizers" ] |
| 223 | if (sanitizers == "memory") { |
| 224 | cflags += [ "-fsanitize-memory-track-origins" ] |
| 225 | cflags_cc += [ "-stdlib=libc++" ] |
| 226 | ldflags += [ "-stdlib=libc++" ] |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 231 | config("extra_flags") { |
| 232 | cflags = extra_cflags |
| 233 | cflags_c = extra_cflags_c |
| 234 | cflags_cc = extra_cflags_cc |
| 235 | ldflags = extra_ldflags |
| 236 | } |
| 237 | |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 238 | config("debug_symbols") { |
| 239 | # It's annoying to wait for full debug symbols to push over |
| 240 | # to Android devices. -gline-tables-only is a lot slimmer. |
| 241 | if (is_android) { |
| 242 | cflags = [ "-gline-tables-only" ] |
| 243 | } else if (!is_win) { |
| 244 | cflags = [ "-g" ] |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | config("no_rtti") { |
| 249 | if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI |
| 250 | if (!is_win) { |
| 251 | cflags_cc = [ "-fno-rtti" ] |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | config("release") { |
| 257 | if (!is_win) { |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 258 | cflags = [ "-O3" ] |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 259 | } |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 260 | defines = [ "NDEBUG" ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | config("executable") { |
| 264 | if (is_mac) { |
| 265 | ldflags = [ "-Wl,-rpath,@loader_path/." ] |
| 266 | } else if (is_linux) { |
mtklein | a846c72 | 2016-09-15 10:44:15 -0700 | [diff] [blame] | 267 | ldflags = [ |
| 268 | "-rdynamic", |
| 269 | "-Wl,-rpath,\$ORIGIN", |
| 270 | ] |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 274 | toolchain("msvc") { |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 275 | vc = "$windk\VC\bin\amd64\cl.exe" |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 276 | vlink = "$windk\VC\bin\amd64\link.exe" |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 277 | vlib = "$windk\VC\bin\amd64\lib.exe" |
| 278 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 279 | # TODO: add a python function that generates the includes using <VSPATH>/win_sdk/bin/SetEnv.<cpu>.json |
| 280 | windk_include_dirs = "/I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\winrt /I$windk\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\ucrt /I$windk\win_sdk\bin\..\..\VC\include /I$windk\win_sdk\bin\..\..\VC\atlmfc\include " |
| 281 | |
| 282 | tool("cc") { |
| 283 | rspfile = "{{output}}.rsp" |
| 284 | precompiled_header_type = "msvc" |
| 285 | pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" |
| 286 | |
| 287 | # Label names may have spaces in them so the pdbname must be quoted. The |
| 288 | # source and output don't need to be quoted because GN knows they're a |
| 289 | # full file name and will quote automatically when necessary. |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 290 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 291 | command = "$vc /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" |
| 292 | depsformat = "msvc" |
| 293 | description = "CC {{output}}" |
| 294 | outputs = [ |
| 295 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
| 296 | # "$object_subdir/{{source_name_part}}.obj", |
| 297 | ] |
| 298 | rspfile_content = "$windk_include_dirs {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}" |
| 299 | } |
| 300 | |
| 301 | tool("cxx") { |
| 302 | rspfile = "{{output}}.rsp" |
| 303 | precompiled_header_type = "msvc" |
| 304 | pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb" |
| 305 | |
| 306 | # Label names may have spaces in them so the pdbname must be quoted. The |
| 307 | # source and output don't need to be quoted because GN knows they're a |
| 308 | # full file name and will quote automatically when necessary. |
| 309 | command = "$vc /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"" |
| 310 | depsformat = "msvc" |
| 311 | description = "C++ {{output}}" |
| 312 | outputs = [ |
| 313 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj", |
| 314 | ] |
| 315 | rspfile_content = "$windk_include_dirs {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}" |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 316 | } |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 317 | |
| 318 | tool("alink") { |
| 319 | rspfile = "{{output}}.rsp" |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 320 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 321 | # gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/win_tool.py") |
| 322 | command = "$vlib /nologo {{arflags}} /OUT:{{output}} @$rspfile" |
| 323 | description = "LIB {{output}}" |
| 324 | outputs = [ |
| 325 | # Ignore {{output_extension}} and always use .lib, there's no reason to |
| 326 | # allow targets to override this extension on Windows. |
| 327 | "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 328 | ] |
| 329 | default_output_extension = ".lib" |
| 330 | default_output_dir = "{{target_out_dir}}" |
| 331 | |
| 332 | # The use of inputs_newline is to work around a fixed per-line buffer |
| 333 | # size in the linker. |
| 334 | rspfile_content = "{{inputs_newline}}" |
| 335 | } |
| 336 | |
| 337 | tool("link") { |
| 338 | exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 339 | pdbname = "$exename.pdb" |
| 340 | rspfile = "$exename.rsp" |
| 341 | |
| 342 | # gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/win_tool.py") |
| 343 | command = "$vlink /nologo /OUT:$exename /PDB:$pdbname @$rspfile" |
| 344 | |
| 345 | default_output_extension = ".exe" |
| 346 | default_output_dir = "{{root_out_dir}}" |
| 347 | description = "LINK {{output}}" |
| 348 | outputs = [ |
| 349 | #"{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 350 | exename, |
| 351 | ] |
mtklein | b9be979 | 2016-09-16 14:44:18 -0700 | [diff] [blame] | 352 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 353 | #if (symbol_level != 0) { |
| 354 | # outputs += [ pdbname ] |
| 355 | #} |
| 356 | #runtime_outputs = outputs |
| 357 | |
| 358 | # The use of inputs_newline is to work around a fixed per-line buffer |
| 359 | # size in the linker. |
| 360 | rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}" |
| 361 | } |
| 362 | |
herb | b6318bf | 2016-09-16 13:29:57 -0700 | [diff] [blame] | 363 | tool("stamp") { |
| 364 | win_stamp_path = rebase_path("win_stamp.py") |
| 365 | command = "python $win_stamp_path {{output}}" |
| 366 | } |
| 367 | } |
| 368 | |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 369 | toolchain("gcc_like") { |
| 370 | lib_switch = "-l" |
| 371 | lib_dir_switch = "-L" |
| 372 | |
| 373 | tool("cc") { |
| 374 | depfile = "{{output}}.d" |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 375 | 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] | 376 | depsformat = "gcc" |
| 377 | outputs = [ |
| 378 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 379 | ] |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 380 | description = "$cc_wrapper $cc ... -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | tool("cxx") { |
| 384 | depfile = "{{output}}.d" |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 385 | 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] | 386 | depsformat = "gcc" |
| 387 | outputs = [ |
| 388 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 389 | ] |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 390 | description = "$cc_wrapper $cxx ... -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | tool("asm") { |
| 394 | depfile = "{{output}}.d" |
mtklein | 60b7ab7 | 2016-09-20 12:09:12 -0700 | [diff] [blame] | 395 | 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] | 396 | depsformat = "gcc" |
| 397 | outputs = [ |
| 398 | "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 399 | ] |
mtklein | 60b7ab7 | 2016-09-20 12:09:12 -0700 | [diff] [blame] | 400 | description = "$cc_wrapper $cc ... -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | tool("alink") { |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 404 | command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 405 | outputs = [ |
mtklein | 5db44aa | 2016-07-29 09:10:31 -0700 | [diff] [blame] | 406 | "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 407 | ] |
| 408 | default_output_extension = ".a" |
| 409 | output_prefix = "lib" |
mtklein | 349cece | 2016-08-26 08:13:04 -0700 | [diff] [blame] | 410 | description = "$ar {{output}} ..." |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | tool("solink") { |
| 414 | soname = "{{target_output_name}}{{output_extension}}" |
| 415 | |
| 416 | rpath = "-Wl,-soname,$soname" |
| 417 | if (is_mac) { |
| 418 | rpath = "-Wl,-install_name,@rpath/$soname" |
| 419 | } |
| 420 | |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 421 | command = "$cc_wrapper $cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 422 | outputs = [ |
| 423 | "{{root_out_dir}}/$soname", |
| 424 | ] |
| 425 | output_prefix = "lib" |
| 426 | default_output_extension = ".so" |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 427 | description = "$cc_wrapper $cxx -shared ... -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | tool("link") { |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 431 | command = "$cc_wrapper $cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 432 | outputs = [ |
| 433 | "{{root_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 434 | ] |
Mike Klein | 121563e | 2016-10-04 17:09:13 -0400 | [diff] [blame^] | 435 | description = "$cc_wrapper $cxx ... -o {{output}}" |
mtklein | 7fbfbbe | 2016-07-21 12:25:45 -0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | tool("stamp") { |
| 439 | command = "touch {{output}}" |
| 440 | } |
| 441 | |
| 442 | tool("copy") { |
| 443 | command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" |
| 444 | } |
| 445 | } |