blob: dfab7e28258cf78b4467bbb8662de78adcc8cc81 [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" ]
Mike Klein5286d6c2016-10-13 13:19:25 -0400309 ldflags = [ "/DEBUG" ]
Mike Kleincc300a12016-10-12 16:25:27 -0400310 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700311 cflags = [ "-g" ]
312 }
313}
314
315config("no_rtti") {
316 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
Mike Kleincc300a12016-10-12 16:25:27 -0400317 if (is_win) {
318 cflags_cc = [ "/GR-" ]
319 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700320 cflags_cc = [ "-fno-rtti" ]
321 }
322 }
323}
324
325config("release") {
Mike Kleincc300a12016-10-12 16:25:27 -0400326 if (is_win) {
327 cflags = [ "/O2" ]
328 } else {
herbb6318bf2016-09-16 13:29:57 -0700329 cflags = [ "-O3" ]
herbb6318bf2016-09-16 13:29:57 -0700330 }
mtkleinb9be9792016-09-16 14:44:18 -0700331 defines = [ "NDEBUG" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700332}
333
334config("executable") {
335 if (is_mac) {
336 ldflags = [ "-Wl,-rpath,@loader_path/." ]
337 } else if (is_linux) {
mtkleina846c722016-09-15 10:44:15 -0700338 ldflags = [
339 "-rdynamic",
340 "-Wl,-rpath,\$ORIGIN",
341 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700342 }
343}
344
herbb6318bf2016-09-16 13:29:57 -0700345toolchain("msvc") {
Mike Klein3eb71212016-10-11 17:08:53 -0400346 lib_dir_switch = "/LIBPATH:"
347
Mike Klein0bc5a762016-10-12 22:42:55 -0400348 bin = "$windk/VC/bin/amd64"
349 env_setup = ""
350 if (target_cpu == "x86") {
351 bin += "_x86"
352 env_setup = "cmd /c $windk/win_sdk/bin/SetEnv.cmd /x86 && "
353 }
herbb6318bf2016-09-16 13:29:57 -0700354
355 tool("cc") {
356 rspfile = "{{output}}.rsp"
357 precompiled_header_type = "msvc"
358 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
359
Mike Klein0f61faa2016-10-11 16:26:57 -0400360 # Label names may have spaces so pdbname must be quoted.
Mike Klein0bc5a762016-10-12 22:42:55 -0400361 command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
herbb6318bf2016-09-16 13:29:57 -0700362 depsformat = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700363 outputs = [
364 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
herbb6318bf2016-09-16 13:29:57 -0700365 ]
Mike Klein0f61faa2016-10-11 16:26:57 -0400366 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
Mike Kleinc756e862016-10-13 14:31:01 -0400367 description = "compile {{source}}"
herbb6318bf2016-09-16 13:29:57 -0700368 }
369
370 tool("cxx") {
371 rspfile = "{{output}}.rsp"
372 precompiled_header_type = "msvc"
373 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
374
Mike Klein0f61faa2016-10-11 16:26:57 -0400375 # Label names may have spaces so pdbname must be quoted.
Mike Klein0bc5a762016-10-12 22:42:55 -0400376 command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
herbb6318bf2016-09-16 13:29:57 -0700377 depsformat = "msvc"
herbb6318bf2016-09-16 13:29:57 -0700378 outputs = [
379 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
380 ]
Mike Klein0f61faa2016-10-11 16:26:57 -0400381 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}"
Mike Kleinc756e862016-10-13 14:31:01 -0400382 description = "compile {{source}}"
mtkleinb9be9792016-09-16 14:44:18 -0700383 }
herbb6318bf2016-09-16 13:29:57 -0700384
385 tool("alink") {
386 rspfile = "{{output}}.rsp"
mtkleinb9be9792016-09-16 14:44:18 -0700387
Mike Kleinc756e862016-10-13 14:31:01 -0400388 command = "$env_setup$bin/lib.exe /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile"
herbb6318bf2016-09-16 13:29:57 -0700389 outputs = [
390 # Ignore {{output_extension}} and always use .lib, there's no reason to
391 # allow targets to override this extension on Windows.
392 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
393 ]
394 default_output_extension = ".lib"
395 default_output_dir = "{{target_out_dir}}"
396
Mike Klein0f61faa2016-10-11 16:26:57 -0400397 # inputs_newline works around a fixed per-line buffer size in the linker.
herbb6318bf2016-09-16 13:29:57 -0700398 rspfile_content = "{{inputs_newline}}"
Mike Kleinc756e862016-10-13 14:31:01 -0400399 description = "link {{output}}"
herbb6318bf2016-09-16 13:29:57 -0700400 }
401
402 tool("link") {
403 exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
404 pdbname = "$exename.pdb"
405 rspfile = "$exename.rsp"
406
Mike Klein0bc5a762016-10-12 22:42:55 -0400407 command =
408 "$env_setup$bin/link.exe /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
herbb6318bf2016-09-16 13:29:57 -0700409
410 default_output_extension = ".exe"
411 default_output_dir = "{{root_out_dir}}"
herbb6318bf2016-09-16 13:29:57 -0700412 outputs = [
herbb6318bf2016-09-16 13:29:57 -0700413 exename,
414 ]
mtkleinb9be9792016-09-16 14:44:18 -0700415
Mike Klein0f61faa2016-10-11 16:26:57 -0400416 # inputs_newline works around a fixed per-line buffer size in the linker.
herbb6318bf2016-09-16 13:29:57 -0700417 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
Mike Kleinc756e862016-10-13 14:31:01 -0400418 description = "link {{output}}"
herbb6318bf2016-09-16 13:29:57 -0700419 }
420
herbb6318bf2016-09-16 13:29:57 -0700421 tool("stamp") {
Mike Kleind3016832016-10-12 15:52:44 -0400422 command = "cmd.exe /c echo > {{output}}"
Mike Kleinc756e862016-10-13 14:31:01 -0400423 description = "stamp {{output}}"
herbb6318bf2016-09-16 13:29:57 -0700424 }
425}
426
mtklein7fbfbbe2016-07-21 12:25:45 -0700427toolchain("gcc_like") {
428 lib_switch = "-l"
429 lib_dir_switch = "-L"
430
431 tool("cc") {
432 depfile = "{{output}}.d"
Mike Klein121563e2016-10-04 17:09:13 -0400433 command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700434 depsformat = "gcc"
435 outputs = [
436 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
437 ]
Mike Klein121563e2016-10-04 17:09:13 -0400438 description = "$cc_wrapper $cc ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700439 }
440
441 tool("cxx") {
442 depfile = "{{output}}.d"
Mike Klein121563e2016-10-04 17:09:13 -0400443 command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700444 depsformat = "gcc"
445 outputs = [
446 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
447 ]
Mike Klein121563e2016-10-04 17:09:13 -0400448 description = "$cc_wrapper $cxx ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700449 }
450
451 tool("asm") {
452 depfile = "{{output}}.d"
mtklein60b7ab72016-09-20 12:09:12 -0700453 command = "$cc_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700454 depsformat = "gcc"
455 outputs = [
456 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
457 ]
mtklein60b7ab72016-09-20 12:09:12 -0700458 description = "$cc_wrapper $cc ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700459 }
460
461 tool("alink") {
mtklein349cece2016-08-26 08:13:04 -0700462 command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700463 outputs = [
mtklein5db44aa2016-07-29 09:10:31 -0700464 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
mtklein7fbfbbe2016-07-21 12:25:45 -0700465 ]
466 default_output_extension = ".a"
467 output_prefix = "lib"
mtklein349cece2016-08-26 08:13:04 -0700468 description = "$ar {{output}} ..."
mtklein7fbfbbe2016-07-21 12:25:45 -0700469 }
470
471 tool("solink") {
472 soname = "{{target_output_name}}{{output_extension}}"
473
474 rpath = "-Wl,-soname,$soname"
475 if (is_mac) {
476 rpath = "-Wl,-install_name,@rpath/$soname"
477 }
478
Mike Klein121563e2016-10-04 17:09:13 -0400479 command = "$cc_wrapper $cxx -shared {{ldflags}} {{inputs}} {{solibs}} {{libs}} $rpath -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700480 outputs = [
481 "{{root_out_dir}}/$soname",
482 ]
483 output_prefix = "lib"
484 default_output_extension = ".so"
Mike Klein121563e2016-10-04 17:09:13 -0400485 description = "$cc_wrapper $cxx -shared ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700486 }
487
488 tool("link") {
Mike Klein121563e2016-10-04 17:09:13 -0400489 command = "$cc_wrapper $cxx {{ldflags}} {{inputs}} {{solibs}} {{libs}} -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700490 outputs = [
491 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
492 ]
Mike Klein121563e2016-10-04 17:09:13 -0400493 description = "$cc_wrapper $cxx ... -o {{output}}"
mtklein7fbfbbe2016-07-21 12:25:45 -0700494 }
495
496 tool("stamp") {
497 command = "touch {{output}}"
498 }
499
500 tool("copy") {
501 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
502 }
503}