Merge branch 'v0.10'
[platform/upstream/nodejs.git] / deps / uv / uv.gyp
1 {
2   'variables': {
3     'uv_use_dtrace%': 'false',
4     # uv_parent_path is the relative path to libuv in the parent project
5     # this is only relevant when dtrace is enabled and libuv is a child project
6     # as it's necessary to correctly locate the object files for post
7     # processing.
8     # XXX gyp is quite sensitive about paths with double / they don't normalize
9     'uv_parent_path': '/',
10   },
11
12   'target_defaults': {
13     'conditions': [
14       ['OS != "win"', {
15         'defines': [
16           '_LARGEFILE_SOURCE',
17           '_FILE_OFFSET_BITS=64',
18         ],
19         'conditions': [
20           ['OS=="solaris"', {
21             'cflags': [ '-pthreads' ],
22           }],
23           ['OS not in "solaris android"', {
24             'cflags': [ '-pthread' ],
25           }],
26         ],
27       }],
28     ],
29   },
30
31   'targets': [
32     {
33       'target_name': 'libuv',
34       'type': '<(library)',
35       'include_dirs': [
36         'include',
37         'src/',
38       ],
39       'direct_dependent_settings': {
40         'include_dirs': [ 'include' ],
41         'conditions': [
42           ['OS != "win"', {
43             'defines': [
44               '_LARGEFILE_SOURCE',
45               '_FILE_OFFSET_BITS=64',
46             ],
47           }],
48           ['OS == "mac"', {
49             'defines': [ '_DARWIN_USE_64_BIT_INODE=1' ],
50           }],
51           ['OS == "linux"', {
52             'defines': [ '_POSIX_C_SOURCE=200112' ],
53           }],
54         ],
55       },
56       'defines': [
57         'HAVE_CONFIG_H'
58       ],
59       'sources': [
60         'common.gypi',
61         'include/uv.h',
62         'include/tree.h',
63         'include/uv-errno.h',
64         'src/fs-poll.c',
65         'src/inet.c',
66         'src/queue.h',
67         'src/uv-common.c',
68         'src/uv-common.h',
69         'src/version.c'
70       ],
71       'conditions': [
72         [ 'OS=="win"', {
73           'defines': [
74             '_WIN32_WINNT=0x0600',
75             '_GNU_SOURCE',
76           ],
77           'sources': [
78             'include/uv-win.h',
79             'src/win/async.c',
80             'src/win/atomicops-inl.h',
81             'src/win/core.c',
82             'src/win/dl.c',
83             'src/win/error.c',
84             'src/win/fs.c',
85             'src/win/fs-event.c',
86             'src/win/getaddrinfo.c',
87             'src/win/handle.c',
88             'src/win/handle-inl.h',
89             'src/win/internal.h',
90             'src/win/loop-watcher.c',
91             'src/win/pipe.c',
92             'src/win/thread.c',
93             'src/win/poll.c',
94             'src/win/process.c',
95             'src/win/process-stdio.c',
96             'src/win/req.c',
97             'src/win/req-inl.h',
98             'src/win/signal.c',
99             'src/win/stream.c',
100             'src/win/stream-inl.h',
101             'src/win/tcp.c',
102             'src/win/tty.c',
103             'src/win/threadpool.c',
104             'src/win/timer.c',
105             'src/win/udp.c',
106             'src/win/util.c',
107             'src/win/winapi.c',
108             'src/win/winapi.h',
109             'src/win/winsock.c',
110             'src/win/winsock.h',
111           ],
112           'link_settings': {
113             'libraries': [
114               '-ladvapi32.lib',
115               '-liphlpapi.lib',
116               '-lpsapi.lib',
117               '-lshell32.lib',
118               '-lws2_32.lib'
119             ],
120           },
121         }, { # Not Windows i.e. POSIX
122           'cflags': [
123             '-g',
124             '--std=gnu89',
125             '-pedantic',
126             '-Wall',
127             '-Wextra',
128             '-Wno-unused-parameter',
129           ],
130           'sources': [
131             'include/uv-unix.h',
132             'include/uv-linux.h',
133             'include/uv-sunos.h',
134             'include/uv-darwin.h',
135             'include/uv-bsd.h',
136             'src/unix/async.c',
137             'src/unix/atomic-ops.h',
138             'src/unix/core.c',
139             'src/unix/dl.c',
140             'src/unix/fs.c',
141             'src/unix/getaddrinfo.c',
142             'src/unix/internal.h',
143             'src/unix/loop.c',
144             'src/unix/loop-watcher.c',
145             'src/unix/pipe.c',
146             'src/unix/poll.c',
147             'src/unix/process.c',
148             'src/unix/signal.c',
149             'src/unix/spinlock.h',
150             'src/unix/stream.c',
151             'src/unix/tcp.c',
152             'src/unix/thread.c',
153             'src/unix/threadpool.c',
154             'src/unix/timer.c',
155             'src/unix/tty.c',
156             'src/unix/udp.c',
157           ],
158           'link_settings': {
159             'libraries': [ '-lm' ],
160             'conditions': [
161               ['OS=="solaris"', {
162                 'ldflags': [ '-pthreads' ],
163               }],
164               ['OS != "solaris" and OS != "android"', {
165                 'ldflags': [ '-pthread' ],
166               }],
167             ],
168           },
169           'conditions': [
170             ['library=="shared_library"', {
171               'cflags': [ '-fPIC' ],
172             }],
173             ['library=="shared_library" and OS!="mac"', {
174               'link_settings': {
175                 # Must correspond with UV_VERSION_MAJOR and UV_VERSION_MINOR
176                 # in src/version.c
177                 'libraries': [ '-Wl,-soname,libuv.so.0.11' ],
178               },
179             }],
180           ],
181         }],
182         [ 'OS in "linux mac android"', {
183           'sources': [ 'src/unix/proctitle.c' ],
184         }],
185         [ 'OS=="mac"', {
186           'sources': [
187             'src/unix/darwin.c',
188             'src/unix/fsevents.c',
189             'src/unix/darwin-proctitle.c',
190           ],
191           'defines': [
192             '_DARWIN_USE_64_BIT_INODE=1',
193           ]
194         }],
195         [ 'OS!="mac"', {
196           # Enable on all platforms except OS X. The antique gcc/clang that
197           # ships with Xcode emits waaaay too many false positives.
198           'cflags': [ '-Wstrict-aliasing' ],
199         }],
200         [ 'OS=="linux"', {
201           'sources': [
202             'src/unix/linux-core.c',
203             'src/unix/linux-inotify.c',
204             'src/unix/linux-syscalls.c',
205             'src/unix/linux-syscalls.h',
206           ],
207           'link_settings': {
208             'libraries': [ '-ldl', '-lrt' ],
209           },
210         }],
211         [ 'OS=="android"', {
212           'sources': [
213             'src/unix/linux-core.c',
214             'src/unix/linux-inotify.c',
215             'src/unix/linux-syscalls.c',
216             'src/unix/linux-syscalls.h',
217             'src/unix/pthread-fixes.c',
218           ],
219           'link_settings': {
220             'libraries': [ '-ldl' ],
221           },
222         }],
223         [ 'OS=="solaris"', {
224           'sources': [ 'src/unix/sunos.c' ],
225           'defines': [
226             '__EXTENSIONS__',
227             '_XOPEN_SOURCE=500',
228           ],
229           'link_settings': {
230             'libraries': [
231               '-lkstat',
232               '-lnsl',
233               '-lsendfile',
234               '-lsocket',
235             ],
236           },
237         }],
238         [ 'OS=="aix"', {
239           'include_dirs': [ 'src/ares/config_aix' ],
240           'sources': [ 'src/unix/aix.c' ],
241           'defines': [
242             '_ALL_SOURCE',
243             '_XOPEN_SOURCE=500',
244           ],
245           'link_settings': {
246             'libraries': [
247               '-lperfstat',
248             ],
249           },
250         }],
251         [ 'OS=="freebsd" or OS=="dragonflybsd"', {
252           'sources': [ 'src/unix/freebsd.c' ],
253         }],
254         [ 'OS=="openbsd"', {
255           'sources': [ 'src/unix/openbsd.c' ],
256         }],
257         [ 'OS=="netbsd"', {
258           'sources': [ 'src/unix/netbsd.c' ],
259         }],
260         [ 'OS in "freebsd dragonflybsd openbsd netbsd".split()', {
261           'link_settings': {
262             'libraries': [ '-lkvm' ],
263           },
264         }],
265         [ 'OS in "mac freebsd dragonflybsd openbsd netbsd".split()', {
266           'sources': [ 'src/unix/kqueue.c' ],
267         }],
268         ['library=="shared_library"', {
269           'defines': [ 'BUILDING_UV_SHARED=1' ]
270         }],
271         # FIXME(bnoordhuis or tjfontaine) Unify this, it's extremely ugly.
272         ['uv_use_dtrace=="true"', {
273           'defines': [ 'HAVE_DTRACE=1' ],
274           'dependencies': [ 'uv_dtrace_header' ],
275           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
276           'conditions': [
277             [ 'OS not in "mac linux"', {
278               'sources': [ 'src/unix/dtrace.c' ],
279             }],
280             [ 'OS=="linux"', {
281               'sources': [ '<(SHARED_INTERMEDIATE_DIR)/dtrace.o' ]
282             }],
283           ],
284         }],
285       ]
286     },
287
288     {
289       'target_name': 'run-tests',
290       'type': 'executable',
291       'dependencies': [ 'libuv' ],
292       'sources': [
293         'test/blackhole-server.c',
294         'test/echo-server.c',
295         'test/run-tests.c',
296         'test/runner.c',
297         'test/runner.h',
298         'test/test-get-loadavg.c',
299         'test/task.h',
300         'test/test-active.c',
301         'test/test-async.c',
302         'test/test-async-null-cb.c',
303         'test/test-callback-stack.c',
304         'test/test-callback-order.c',
305         'test/test-close-fd.c',
306         'test/test-close-order.c',
307         'test/test-connection-fail.c',
308         'test/test-cwd-and-chdir.c',
309         'test/test-delayed-accept.c',
310         'test/test-error.c',
311         'test/test-embed.c',
312         'test/test-emfile.c',
313         'test/test-fail-always.c',
314         'test/test-fs.c',
315         'test/test-fs-event.c',
316         'test/test-get-currentexe.c',
317         'test/test-get-memory.c',
318         'test/test-getaddrinfo.c',
319         'test/test-getsockname.c',
320         'test/test-hrtime.c',
321         'test/test-idle.c',
322         'test/test-ipc.c',
323         'test/test-ipc-send-recv.c',
324         'test/test-list.h',
325         'test/test-loop-handles.c',
326         'test/test-loop-stop.c',
327         'test/test-loop-time.c',
328         'test/test-walk-handles.c',
329         'test/test-watcher-cross-stop.c',
330         'test/test-multiple-listen.c',
331         'test/test-osx-select.c',
332         'test/test-pass-always.c',
333         'test/test-ping-pong.c',
334         'test/test-pipe-bind-error.c',
335         'test/test-pipe-connect-error.c',
336         'test/test-platform-output.c',
337         'test/test-poll.c',
338         'test/test-poll-close.c',
339         'test/test-process-title.c',
340         'test/test-ref.c',
341         'test/test-run-nowait.c',
342         'test/test-run-once.c',
343         'test/test-semaphore.c',
344         'test/test-shutdown-close.c',
345         'test/test-shutdown-eof.c',
346         'test/test-signal.c',
347         'test/test-signal-multiple-loops.c',
348         'test/test-spawn.c',
349         'test/test-fs-poll.c',
350         'test/test-stdio-over-pipes.c',
351         'test/test-tcp-bind-error.c',
352         'test/test-tcp-bind6-error.c',
353         'test/test-tcp-close.c',
354         'test/test-tcp-close-accept.c',
355         'test/test-tcp-close-while-connecting.c',
356         'test/test-tcp-connect-error-after-write.c',
357         'test/test-tcp-shutdown-after-write.c',
358         'test/test-tcp-flags.c',
359         'test/test-tcp-connect-error.c',
360         'test/test-tcp-connect-timeout.c',
361         'test/test-tcp-connect6-error.c',
362         'test/test-tcp-open.c',
363         'test/test-tcp-write-to-half-open-connection.c',
364         'test/test-tcp-writealot.c',
365         'test/test-tcp-try-write.c',
366         'test/test-tcp-unexpected-read.c',
367         'test/test-tcp-read-stop.c',
368         'test/test-threadpool.c',
369         'test/test-threadpool-cancel.c',
370         'test/test-mutexes.c',
371         'test/test-thread.c',
372         'test/test-barrier.c',
373         'test/test-condvar.c',
374         'test/test-timer-again.c',
375         'test/test-timer-from-check.c',
376         'test/test-timer.c',
377         'test/test-tty.c',
378         'test/test-udp-dgram-too-big.c',
379         'test/test-udp-ipv6.c',
380         'test/test-udp-open.c',
381         'test/test-udp-options.c',
382         'test/test-udp-send-and-recv.c',
383         'test/test-udp-multicast-join.c',
384         'test/test-dlerror.c',
385         'test/test-udp-multicast-ttl.c',
386         'test/test-ip4-addr.c',
387         'test/test-ip6-addr.c',
388       ],
389       'conditions': [
390         [ 'OS=="win"', {
391           'sources': [
392             'test/runner-win.c',
393             'test/runner-win.h'
394           ],
395           'libraries': [ 'ws2_32.lib' ]
396         }, { # POSIX
397           'defines': [ '_GNU_SOURCE' ],
398           'sources': [
399             'test/runner-unix.c',
400             'test/runner-unix.h',
401           ],
402         }],
403         [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE
404           'defines': [
405             '__EXTENSIONS__',
406             '_XOPEN_SOURCE=500',
407           ],
408         }],
409         [ 'OS=="aix"', {     # make test-fs.c compile, needs _POSIX_C_SOURCE
410           'defines': [
411             '_ALL_SOURCE',
412             '_XOPEN_SOURCE=500',
413           ],
414         }],
415       ],
416       'msvs-settings': {
417         'VCLinkerTool': {
418           'SubSystem': 1, # /subsystem:console
419         },
420       },
421     },
422
423     {
424       'target_name': 'run-benchmarks',
425       'type': 'executable',
426       'dependencies': [ 'libuv' ],
427       'sources': [
428         'test/benchmark-async.c',
429         'test/benchmark-async-pummel.c',
430         'test/benchmark-fs-stat.c',
431         'test/benchmark-getaddrinfo.c',
432         'test/benchmark-list.h',
433         'test/benchmark-loop-count.c',
434         'test/benchmark-million-async.c',
435         'test/benchmark-million-timers.c',
436         'test/benchmark-multi-accept.c',
437         'test/benchmark-ping-pongs.c',
438         'test/benchmark-pound.c',
439         'test/benchmark-pump.c',
440         'test/benchmark-sizes.c',
441         'test/benchmark-spawn.c',
442         'test/benchmark-thread.c',
443         'test/benchmark-tcp-write-batch.c',
444         'test/benchmark-udp-pummel.c',
445         'test/dns-server.c',
446         'test/echo-server.c',
447         'test/blackhole-server.c',
448         'test/run-benchmarks.c',
449         'test/runner.c',
450         'test/runner.h',
451         'test/task.h',
452       ],
453       'conditions': [
454         [ 'OS=="win"', {
455           'sources': [
456             'test/runner-win.c',
457             'test/runner-win.h',
458           ],
459           'libraries': [ 'ws2_32.lib' ]
460         }, { # POSIX
461           'defines': [ '_GNU_SOURCE' ],
462           'sources': [
463             'test/runner-unix.c',
464             'test/runner-unix.h',
465           ]
466         }]
467       ],
468       'msvs-settings': {
469         'VCLinkerTool': {
470           'SubSystem': 1, # /subsystem:console
471         },
472       },
473     },
474
475     {
476       'target_name': 'uv_dtrace_header',
477       'type': 'none',
478       'conditions': [
479         [ 'uv_use_dtrace=="true"', {
480           'actions': [
481             {
482               'action_name': 'uv_dtrace_header',
483               'inputs': [ 'src/unix/uv-dtrace.d' ],
484               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/uv-dtrace.h' ],
485               'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
486                 '-o', '<@(_outputs)' ],
487             },
488           ],
489         }],
490       ],
491     },
492
493     # FIXME(bnoordhuis or tjfontaine) Unify this, it's extremely ugly.
494     {
495       'target_name': 'uv_dtrace_provider',
496       'type': 'none',
497       'conditions': [
498         [ 'uv_use_dtrace=="true" and OS not in "mac linux"', {
499           'actions': [
500             {
501               'action_name': 'uv_dtrace_o',
502               'inputs': [
503                 'src/unix/uv-dtrace.d',
504                 '<(PRODUCT_DIR)/obj.target/libuv<(uv_parent_path)src/unix/core.o',
505               ],
506               'outputs': [
507                 '<(PRODUCT_DIR)/obj.target/libuv<(uv_parent_path)src/unix/dtrace.o',
508               ],
509               'action': [ 'dtrace', '-G', '-xnolibs', '-s', '<@(_inputs)',
510                 '-o', '<@(_outputs)' ]
511             }
512           ]
513         }],
514         [ 'uv_use_dtrace=="true" and OS=="linux"', {
515           'actions': [
516             {
517               'action_name': 'uv_dtrace_o',
518               'inputs': [ 'src/unix/uv-dtrace.d' ],
519               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/dtrace.o' ],
520               'action': [
521                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
522               ],
523             }
524           ]
525         }],
526       ]
527     },
528
529   ]
530 }