blob: 625ed73cd6a72a155328f3f11375f552525ee59d [file] [log] [blame]
mtklein7fbfbbe2016-07-21 12:25:45 -07001# 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
6declare_args() {
mtklein349cece2016-08-26 08:13:04 -07007 ar = "ar"
mtklein7fbfbbe2016-07-21 12:25:45 -07008 cc = "cc"
9 cxx = "c++"
mtklein8079ba62016-08-16 09:31:16 -070010
mtklein7d6fb2c2016-08-25 14:50:44 -070011 if (is_android) {
mtklein349cece2016-08-26 08:13:04 -070012 ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
mtklein7d6fb2c2016-08-25 14:50:44 -070013 cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
14 cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
15 }
16
Mike Klein0f61faa2016-10-11 16:26:57 -040017 windk = "C:/Program Files (x86)/Microsoft Visual Studio 14.0"
herbb6318bf2016-09-16 13:29:57 -070018
Mike Klein121563e2016-10-04 17:09:13 -040019 extra_cflags = []
20 extra_cflags_c = []
21 extra_cflags_cc = []
22 extra_ldflags = []
mtkleincab0bb72016-08-26 13:43:19 -070023
mtklein60b7ab72016-09-20 12:09:12 -070024 cc_wrapper = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070025}
26
Mike Klein461d3282016-10-11 13:51:55 -040027if (!is_win) {
28 is_clang = exec_script("is_clang.py",
29 [
30 cc,
31 cxx,
32 ],
33 "value")
34}
mtkleinf347c512016-09-26 08:40:12 -070035
mtkleinb9be9792016-09-16 14:44:18 -070036config("default") {
37 asmflags = []
38 cflags = []
39 cflags_c = []
40 cflags_cc = []
41 defines = []
42 ldflags = []
43
44 if (is_win) {
45 cflags += [
46 "/FS", # Preserve previous PDB behavior.
herbb6318bf2016-09-16 13:29:57 -070047 "/bigobj", # Some of our files are bigger than the regular limits.
Mike Kleinc7165c22016-10-12 23:58:06 -040048 "/WX", # Treat warnings as errors.
herbb6318bf2016-09-16 13:29:57 -070049 ]
mtkleinb9be9792016-09-16 14:44:18 -070050 defines += [
Mike Kleinc7165c22016-10-12 23:58:06 -040051 "_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf().
52 "_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL.
mtkleinb9be9792016-09-16 14:44:18 -070053 "WIN32_LEAN_AND_MEAN",
54 "NOMINMAX",
herbb6318bf2016-09-16 13:29:57 -070055 ]
Mike Klein0f61faa2016-10-11 16:26:57 -040056 include_dirs = [
Mike Kleind3016832016-10-12 15:52:44 -040057 "$windk/VC/include",
Mike Kleincc300a12016-10-12 16:25:27 -040058
Mike Kleind3016832016-10-12 15:52:44 -040059 # For local builds.
Mike Klein0f61faa2016-10-11 16:26:57 -040060 "$windk/../Windows Kits/10/Include/10.0.10150.0/ucrt",
Mike Klein0f61faa2016-10-11 16:26:57 -040061 "$windk/../Windows Kits/8.1/Include/shared",
Mike Klein3eb71212016-10-11 17:08:53 -040062 "$windk/../Windows Kits/8.1/Include/um",
Mike Kleincc300a12016-10-12 16:25:27 -040063
Mike Kleind3016832016-10-12 15:52:44 -040064 # For builds using win_toolchain asset.
65 "$windk/win_sdk/Include/10.0.10586.0/shared",
66 "$windk/win_sdk/Include/10.0.10586.0/ucrt",
67 "$windk/win_sdk/Include/10.0.10586.0/um",
Mike Klein0f61faa2016-10-11 16:26:57 -040068 ]
Mike Klein3eb71212016-10-11 17:08:53 -040069 lib_dirs = [
Mike Kleind3016832016-10-12 15:52:44 -040070 # For local builds.
Mike Klein0bc5a762016-10-12 22:42:55 -040071 "$windk/../Windows Kits/10/Lib/10.0.10150.0/ucrt/$target_cpu",
72 "$windk/../Windows Kits/8.1/Lib/winv6.3/um/$target_cpu",
Mike Kleincc300a12016-10-12 16:25:27 -040073
Mike Kleind3016832016-10-12 15:52:44 -040074 # For builds using win_toolchain asset.
Mike Klein0bc5a762016-10-12 22:42:55 -040075 "$windk/win_sdk/Lib/10.0.10586.0/ucrt/$target_cpu",
76 "$windk/win_sdk/Lib/10.0.10586.0/um/$target_cpu",
Mike Klein3eb71212016-10-11 17:08:53 -040077 ]
Mike Klein0bc5a762016-10-12 22:42:55 -040078 if (target_cpu == "x86") {
79 lib_dirs += [ "$windk/VC/lib" ]
80 } else {
81 lib_dirs += [ "$windk/VC/lib/amd64" ]
82 }
mtkleinb9be9792016-09-16 14:44:18 -070083 } else {
84 cflags += [
herbb6318bf2016-09-16 13:29:57 -070085 "-O1",
86 "-fstrict-aliasing",
87 "-fPIC",
88 "-fvisibility=hidden",
herbb6318bf2016-09-16 13:29:57 -070089 "-Werror",
mtklein2b3c2a32016-09-08 08:39:34 -070090 ]
mtkleinb9be9792016-09-16 14:44:18 -070091 cflags_cc += [
herbb6318bf2016-09-16 13:29:57 -070092 "-std=c++11",
93 "-fno-exceptions",
94 "-fno-threadsafe-statics",
95 "-fvisibility-inlines-hidden",
herbb6318bf2016-09-16 13:29:57 -070096 ]
mtkleinb9be9792016-09-16 14:44:18 -070097 }
herbb6318bf2016-09-16 13:29:57 -070098
mtkleinb9be9792016-09-16 14:44:18 -070099 if (current_cpu == "arm") {
100 cflags += [
101 "-march=armv7-a",
102 "-mfpu=neon",
103 "-mthumb",
104 ]
105 } else if (current_cpu == "mipsel") {
106 cflags += [
107 "-march=mips32r2",
108 "-mdspr2",
109 ]
Mike Klein5d8cf292016-10-12 19:36:09 -0400110 } else if (current_cpu == "x86" && !is_win) {
mtkleinb9be9792016-09-16 14:44:18 -0700111 asmflags += [ "-m32" ]
112 cflags += [
113 "-m32",
114 "-msse2",
115 "-mfpmath=sse",
116 ]
117 ldflags += [ "-m32" ]
118 }
herbb6318bf2016-09-16 13:29:57 -0700119
mtkleinb9be9792016-09-16 14:44:18 -0700120 if (is_android) {
121 asmflags += [
122 "--target=$ndk_target",
123 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
124 ]
125 cflags += [
126 "--sysroot=$ndk/platforms/$ndk_platform",
127 "--target=$ndk_target",
128 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
129 ]
130 cflags_cc += [
131 "-isystem$ndk/sources/android/support/include",
Mike Klein4fdc5432016-10-11 11:21:36 -0400132 "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include", # Through r12b.
133 "-isystem$ndk/sources/cxx-stl/llvm-libc++/include", # Since r13.
mtkleinb9be9792016-09-16 14:44:18 -0700134 ]
135 ldflags += [
136 "--sysroot=$ndk/platforms/$ndk_platform",
137 "--target=$ndk_target",
138 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
139 "-pie",
140 ]
141 lib_dirs = [
142 "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
143 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
144 ]
herbb6318bf2016-09-16 13:29:57 -0700145
Mike Klein4fdc5432016-10-11 11:21:36 -0400146 if (current_cpu == "mips64el") {
147 # The r13 NDK omits /usr/lib from the MIPS64 sysroots, but Clang searches
148 # for /usr/lib64 as $PATH_TO_USR_LIB/../lib64. If there's no /usr/lib,
149 # it can't find /usr/lib64. We must point Clang at /usr/lib64 manually.
150 lib_dirs += [ "$ndk/platforms/$ndk_platform/usr/lib64" ]
151 ldflags += [
152 # Clang will try to link these two files, but not find them. Again, do it manually.
153 "-nostartfiles",
154 "$ndk/platforms/$ndk_platform/usr/lib64/crtbegin_dynamic.o",
155 "$ndk/platforms/$ndk_platform/usr/lib64/crtend_android.o",
156 ]
157 }
158
mtkleinb9be9792016-09-16 14:44:18 -0700159 libs = [
160 # Order matters here! Keep these three in exactly this order.
161 "c++_static",
162 "c++abi",
163 "android_support",
164 ]
165 if (target_cpu == "arm") {
166 libs += [ "unwind" ]
mtklein2b3c2a32016-09-08 08:39:34 -0700167 }
168 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700169
mtkleinb9be9792016-09-16 14:44:18 -0700170 if (is_linux) {
171 libs = [ "pthread" ]
172 }
173
174 if (sanitize != "") {
175 # You can either pass the sanitizers directly, e.g. "address,undefined",
176 # or pass one of the couple common aliases used by the bots.
177 sanitizers = sanitize
178 if (sanitize == "ASAN") {
179 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"
180 } else if (sanitize == "TSAN") {
181 sanitizers = "thread"
182 } else if (sanitize == "MSAN") {
183 sanitizers = "memory"
184 }
185
186 cflags += [
187 "-fsanitize=$sanitizers",
188 "-fno-sanitize-recover=$sanitizers",
189 "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
190 ]
191 ldflags += [ "-fsanitize=$sanitizers" ]
192 if (sanitizers == "memory") {
193 cflags += [ "-fsanitize-memory-track-origins" ]
194 cflags_cc += [ "-stdlib=libc++" ]
195 ldflags += [ "-stdlib=libc++" ]
196 }
197 }
198}
199
Mike Kleinc7165c22016-10-12 23:58:06 -0400200config("warnings") {
201 cflags = []
202 cflags_cc = []
203 if (is_win) {
204 cflags += [
205 "/W3", # Turn on lots of warnings.
206
207 # Disable a bunch of warnings:
208 "/wd4244", # conversion from 'float' to 'int', possible loss of data
209 "/wd4267", # conversion from 'size_t' to 'int', possible loss of data
210 "/wd4800", # forcing value to bool 'true' or 'false' (performance warning)
211
212 # Probably only triggers when /EHsc is enabled.
213 "/wd4291", # no matching operator delete found;
214 # memory will not be freed if initialization throws an exception
215 ]
216 } else {
217 cflags += [
218 "-Wall",
219 "-Wextra",
220 "-Winit-self",
221 "-Wpointer-arith",
222 "-Wsign-compare",
223 "-Wvla",
224
225 "-Wno-deprecated-declarations",
226 "-Wno-unused-parameter",
227 ]
228 cflags_cc += [ "-Wnon-virtual-dtor" ]
229
230 if (is_clang) {
231 cflags += [
232 "-Weverything",
233 "-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings.
234 ]
235
236 if (is_android && target_cpu == "x86") {
237 # Clang seems to think new/malloc will only be 4-byte aligned on x86 Android.
238 # We're pretty sure it's actually 8-byte alignment.
239 cflags += [ "-Wno-over-aligned" ]
240 }
241
242 cflags += [
243 "-Wno-cast-align",
244 "-Wno-conditional-uninitialized",
245 "-Wno-conversion",
246 "-Wno-disabled-macro-expansion",
247 "-Wno-documentation",
248 "-Wno-documentation-unknown-command",
249 "-Wno-double-promotion",
250 "-Wno-exit-time-destructors", # TODO: OK outside libskia
251 "-Wno-float-conversion",
252 "-Wno-float-equal",
253 "-Wno-format-nonliteral",
254 "-Wno-global-constructors", # TODO: OK outside libskia
255 "-Wno-gnu-zero-variadic-macro-arguments",
256 "-Wno-missing-prototypes",
257 "-Wno-missing-variable-declarations",
258 "-Wno-pedantic",
259 "-Wno-reserved-id-macro",
260 "-Wno-shadow",
261 "-Wno-shift-sign-overflow",
262 "-Wno-sign-conversion",
263 "-Wno-switch-enum",
264 "-Wno-undef",
265 "-Wno-unreachable-code",
266 "-Wno-unreachable-code-break",
267 "-Wno-unreachable-code-return",
268 "-Wno-unused-macros",
269 "-Wno-unused-member-function",
270 ]
271 cflags_cc += [
272 "-Wno-abstract-vbase-init",
273 "-Wno-range-loop-analysis",
274 "-Wno-weak-vtables",
275 ]
276
277 # We are unlikely to want to fix these.
278 cflags += [
279 "-Wno-covered-switch-default",
280 "-Wno-deprecated",
281 "-Wno-implicit-fallthrough",
282 "-Wno-missing-noreturn",
283 "-Wno-old-style-cast",
284 "-Wno-padded",
285 ]
286 cflags_cc += [
287 "-Wno-c++98-compat",
288 "-Wno-c++98-compat-pedantic",
289 "-Wno-undefined-func-template",
290 ]
291 }
292 }
293}
294
Mike Klein121563e2016-10-04 17:09:13 -0400295config("extra_flags") {
296 cflags = extra_cflags
297 cflags_c = extra_cflags_c
298 cflags_cc = extra_cflags_cc
299 ldflags = extra_ldflags
300}
301
mtkleinb9be9792016-09-16 14:44:18 -0700302config("debug_symbols") {
303 # It's annoying to wait for full debug symbols to push over
304 # to Android devices. -gline-tables-only is a lot slimmer.
305 if (is_android) {
306 cflags = [ "-gline-tables-only" ]
Mike Kleincc300a12016-10-12 16:25:27 -0400307 } else if (is_win) {
308 cflags = [ "/Zi" ]
309 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700310 cflags = [ "-g" ]
311 }
312}
313
314config("no_rtti") {
315 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
Mike Kleincc300a12016-10-12 16:25:27 -0400316 if (is_win) {
317 cflags_cc = [ "/GR-" ]
318 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700319 cflags_cc = [ "-fno-rtti" ]
320 }
321 }
322}
323
324config("release") {
Mike Kleincc300a12016-10-12 16:25:27 -0400325 if (is_win) {
326 cflags = [ "/O2" ]
327 } else {
herbb6318bf2016-09-16 13:29:57 -0700328 cflags = [ "-O3" ]
herbb6318bf2016-09-16 13:29:57 -0700329 }
mtkleinb9be9792016-09-16 14:44:18 -0700330 defines = [ "NDEBUG" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700331}
332
333config("executable") {
334 if (is_mac) {
335 ldflags = [ "-Wl,-rpath,@loader_path/." ]
336 } else if (is_linux) {
mtkleina846c722016-09-15 10:44:15 -0700337 ldflags = [
338 "-rdynamic",
339 "-Wl,-rpath,\$ORIGIN",
340 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700341 }
342}
343
herbb6318bf2016-09-16 13:29:57 -0700344toolchain("msvc") {
Mike Klein3eb71212016-10-11 17:08:53 -0400345 lib_dir_switch = "/LIBPATH:"
346
Mike Klein0bc5a762016-10-12 22:42:55 -0400347 bin = "$windk/VC/bin/amd64"
348 env_setup = ""
349 if (target_cpu == "x86") {
350 bin += "_x86"
351 env_setup = "cmd /c $windk/win_sdk/bin/SetEnv.cmd /x86 && "
352 }
herbb6318bf2016-09-16 13:29:57 -0700353
354 tool("cc") {
355 rspfile = "{{output}}.rsp"
356 precompiled_header_type = "msvc"
357 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
358
Mike Klein0f61faa2016-10-11 16:26:57 -0400359 # Label names may have spaces so pdbname must be quoted.
Mike Klein0bc5a762016-10-12 22:42:55 -0400360 command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
herbb6318bf2016-09-16 13:29:57 -0700361 depsformat = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700362 outputs = [
363 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
herbb6318bf2016-09-16 13:29:57 -0700364 ]
Mike Klein0f61faa2016-10-11 16:26:57 -0400365 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
herbb6318bf2016-09-16 13:29:57 -0700366 }
367
368 tool("cxx") {
369 rspfile = "{{output}}.rsp"
370 precompiled_header_type = "msvc"
371 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
372
Mike Klein0f61faa2016-10-11 16:26:57 -0400373 # Label names may have spaces so pdbname must be quoted.
Mike Klein0bc5a762016-10-12 22:42:55 -0400374 command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
herbb6318bf2016-09-16 13:29:57 -0700375 depsformat = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700376 outputs = [
377 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
378 ]
Mike Klein0f61faa2016-10-11 16:26:57 -0400379 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}"
mtkleinb9be9792016-09-16 14:44:18 -0700380 }
herbb6318bf2016-09-16 13:29:57 -0700381
382 tool("alink") {
383 rspfile = "{{output}}.rsp"
mtkleinb9be9792016-09-16 14:44:18 -0700384
Mike Klein0bc5a762016-10-12 22:42:55 -0400385 command =
386 "$env_setup$bin/lib.exe /nologo {{arflags}} /OUT:{{output}} @$rspfile"
herbb6318bf2016-09-16 13:29:57 -0700387 outputs = [
388 # Ignore {{output_extension}} and always use .lib, there's no reason to
389 # allow targets to override this extension on Windows.
390 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
391 ]
392 default_output_extension = ".lib"
393 default_output_dir = "{{target_out_dir}}"
394
Mike Klein0f61faa2016-10-11 16:26:57 -0400395 # inputs_newline works around a fixed per-line buffer size in the linker.
herbb6318bf2016-09-16 13:29:57 -0700396 rspfile_content = "{{inputs_newline}}"
397 }
398
399 tool("link") {
400 exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
401 pdbname = "$exename.pdb"
402 rspfile = "$exename.rsp"
403
Mike Klein0bc5a762016-10-12 22:42:55 -0400404 command =
405 "$env_setup$bin/link.exe /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
herbb6318bf2016-09-16 13:29:57 -0700406
407 default_output_extension = ".exe"
408 default_output_dir = "{{root_out_dir}}"
herbb6318bf2016-09-16 13:29:57 -0700409 outputs = [
herbb6318bf2016-09-16 13:29:57 -0700410 exename,
411 ]
mtkleinb9be9792016-09-16 14:44:18 -0700412
Mike Klein0f61faa2016-10-11 16:26:57 -0400413 # inputs_newline works around a fixed per-line buffer size in the linker.
herbb6318bf2016-09-16 13:29:57 -0700414 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
415 }
416
herbb6318bf2016-09-16 13:29:57 -0700417 tool("stamp") {
Mike Kleind3016832016-10-12 15:52:44 -0400418 command = "cmd.exe /c echo > {{output}}"
herbb6318bf2016-09-16 13:29:57 -0700419 }
420}
421
mtklein7fbfbbe2016-07-21 12:25:45 -0700422toolchain("gcc_like") {
423 lib_switch = "-l"
424 lib_dir_switch = "-L"
425
426 tool("cc") {
427 depfile = "{{output}}.d"
Mike Klein121563e2016-10-04 17:09:13 -0400428 command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700429 depsformat = "gcc"
430 outputs = [
431 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
432 ]
Mike Klein121563e2016-10-04 17:09:13 -0400433 description = "$cc_wrapper $cc ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700434 }
435
436 tool("cxx") {
437 depfile = "{{output}}.d"
Mike Klein121563e2016-10-04 17:09:13 -0400438 command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700439 depsformat = "gcc"
440 outputs = [
441 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
442 ]
Mike Klein121563e2016-10-04 17:09:13 -0400443 description = "$cc_wrapper $cxx ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700444 }
445
446 tool("asm") {
447 depfile = "{{output}}.d"
mtklein60b7ab72016-09-20 12:09:12 -0700448 command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700449 depsformat = "gcc"
450 outputs = [
451 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
452 ]
mtklein60b7ab72016-09-20 12:09:12 -0700453 description = "$cc_wrapper $cc ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700454 }
455
456 tool("alink") {
mtklein349cece2016-08-26 08:13:04 -0700457 command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700458 outputs = [
mtklein5db44aa2016-07-29 09:10:31 -0700459 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
mtklein7fbfbbe2016-07-21 12:25:45 -0700460 ]
461 default_output_extension = ".a"
462 output_prefix = "lib"
mtklein349cece2016-08-26 08:13:04 -0700463 description = "$ar {{output}} ..."
mtklein7fbfbbe2016-07-21 12:25:45 -0700464 }
465
466 tool("solink") {
467 soname = "{{target_output_name}}{{output_extension}}"
468
469 rpath = "-Wl,-soname,$soname"
470 if (is_mac) {
471 rpath = "-Wl,-install_name,@rpath/$soname"
472 }
473
Mike Klein121563e2016-10-04 17:09:13 -0400474 command = "$cc_wrapper $cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700475 outputs = [
476 "{{root_out_dir}}/$soname",
477 ]
478 output_prefix = "lib"
479 default_output_extension = ".so"
Mike Klein121563e2016-10-04 17:09:13 -0400480 description = "$cc_wrapper $cxx -shared ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700481 }
482
483 tool("link") {
Mike Klein121563e2016-10-04 17:09:13 -0400484 command = "$cc_wrapper $cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700485 outputs = [
486 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
487 ]
Mike Klein121563e2016-10-04 17:09:13 -0400488 description = "$cc_wrapper $cxx ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700489 }
490
491 tool("stamp") {
492 command = "touch {{output}}"
493 }
494
495 tool("copy") {
496 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
497 }
498}