cluster: remove handles when disconnecting worker
[platform/upstream/nodejs.git] / node.gyp
1 {
2   'variables': {
3     'v8_use_snapshot%': 'false',
4     'node_use_dtrace%': 'false',
5     'node_use_lttng%': 'false',
6     'node_use_etw%': 'false',
7     'node_use_perfctr%': 'false',
8     'node_has_winsdk%': 'false',
9     'node_shared_zlib%': 'false',
10     'node_shared_http_parser%': 'false',
11     'node_shared_libuv%': 'false',
12     'node_use_openssl%': 'true',
13     'node_shared_openssl%': 'false',
14     'node_v8_options%': '',
15     'node_target_type%': 'executable',
16     'library_files': [
17       'src/node.js',
18       'lib/_debug_agent.js',
19       'lib/_debugger.js',
20       'lib/_linklist.js',
21       'lib/assert.js',
22       'lib/buffer.js',
23       'lib/child_process.js',
24       'lib/console.js',
25       'lib/constants.js',
26       'lib/crypto.js',
27       'lib/cluster.js',
28       'lib/dgram.js',
29       'lib/dns.js',
30       'lib/domain.js',
31       'lib/events.js',
32       'lib/freelist.js',
33       'lib/fs.js',
34       'lib/http.js',
35       'lib/_http_agent.js',
36       'lib/_http_client.js',
37       'lib/_http_common.js',
38       'lib/_http_incoming.js',
39       'lib/_http_outgoing.js',
40       'lib/_http_server.js',
41       'lib/https.js',
42       'lib/module.js',
43       'lib/net.js',
44       'lib/os.js',
45       'lib/path.js',
46       'lib/process.js',
47       'lib/punycode.js',
48       'lib/querystring.js',
49       'lib/readline.js',
50       'lib/repl.js',
51       'lib/stream.js',
52       'lib/_stream_readable.js',
53       'lib/_stream_writable.js',
54       'lib/_stream_duplex.js',
55       'lib/_stream_transform.js',
56       'lib/_stream_passthrough.js',
57       'lib/_stream_wrap.js',
58       'lib/string_decoder.js',
59       'lib/sys.js',
60       'lib/timers.js',
61       'lib/tls.js',
62       'lib/_tls_common.js',
63       'lib/_tls_legacy.js',
64       'lib/_tls_wrap.js',
65       'lib/tty.js',
66       'lib/url.js',
67       'lib/util.js',
68       'lib/v8.js',
69       'lib/vm.js',
70       'lib/zlib.js',
71       'lib/internal/child_process.js',
72       'lib/internal/cluster.js',
73       'lib/internal/freelist.js',
74       'lib/internal/module.js',
75       'lib/internal/socket_list.js',
76       'lib/internal/repl.js',
77       'lib/internal/util.js',
78       'lib/internal/streams/lazy_transform.js',
79     ],
80   },
81
82   'targets': [
83     {
84       'target_name': 'node',
85       'type': '<(node_target_type)',
86
87       'dependencies': [
88         'node_js2c#host',
89         'deps/cares/cares.gyp:cares',
90         'deps/v8/tools/gyp/v8.gyp:v8',
91         'deps/v8/tools/gyp/v8.gyp:v8_libplatform'
92       ],
93
94       'include_dirs': [
95         'src',
96         'tools/msvs/genfiles',
97         'deps/uv/src/ares',
98         '<(SHARED_INTERMEDIATE_DIR)', # for node_natives.h
99         'deps/v8' # include/v8_platform.h
100       ],
101
102       'sources': [
103         'src/debug-agent.cc',
104         'src/async-wrap.cc',
105         'src/env.cc',
106         'src/fs_event_wrap.cc',
107         'src/cares_wrap.cc',
108         'src/handle_wrap.cc',
109         'src/js_stream.cc',
110         'src/node.cc',
111         'src/node_buffer.cc',
112         'src/node_constants.cc',
113         'src/node_contextify.cc',
114         'src/node_file.cc',
115         'src/node_http_parser.cc',
116         'src/node_javascript.cc',
117         'src/node_main.cc',
118         'src/node_os.cc',
119         'src/node_util.cc',
120         'src/node_v8.cc',
121         'src/node_stat_watcher.cc',
122         'src/node_watchdog.cc',
123         'src/node_zlib.cc',
124         'src/node_i18n.cc',
125         'src/pipe_wrap.cc',
126         'src/signal_wrap.cc',
127         'src/spawn_sync.cc',
128         'src/string_bytes.cc',
129         'src/stream_base.cc',
130         'src/stream_wrap.cc',
131         'src/tcp_wrap.cc',
132         'src/timer_wrap.cc',
133         'src/tty_wrap.cc',
134         'src/process_wrap.cc',
135         'src/udp_wrap.cc',
136         'src/uv.cc',
137         # headers to make for a more pleasant IDE experience
138         'src/async-wrap.h',
139         'src/async-wrap-inl.h',
140         'src/base-object.h',
141         'src/base-object-inl.h',
142         'src/debug-agent.h',
143         'src/env.h',
144         'src/env-inl.h',
145         'src/handle_wrap.h',
146         'src/js_stream.h',
147         'src/node.h',
148         'src/node_buffer.h',
149         'src/node_constants.h',
150         'src/node_file.h',
151         'src/node_http_parser.h',
152         'src/node_internals.h',
153         'src/node_javascript.h',
154         'src/node_root_certs.h',
155         'src/node_version.h',
156         'src/node_watchdog.h',
157         'src/node_wrap.h',
158         'src/node_i18n.h',
159         'src/pipe_wrap.h',
160         'src/tty_wrap.h',
161         'src/tcp_wrap.h',
162         'src/udp_wrap.h',
163         'src/req-wrap.h',
164         'src/req-wrap-inl.h',
165         'src/string_bytes.h',
166         'src/stream_base.h',
167         'src/stream_base-inl.h',
168         'src/stream_wrap.h',
169         'src/tree.h',
170         'src/util.h',
171         'src/util-inl.h',
172         'src/util.cc',
173         'src/string_search.cc',
174         'deps/http_parser/http_parser.h',
175         'deps/v8/include/v8.h',
176         'deps/v8/include/v8-debug.h',
177         '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
178         # javascript files to make for an even more pleasant IDE experience
179         '<@(library_files)',
180         # node.gyp is added to the project by default.
181         'common.gypi',
182       ],
183
184       'defines': [
185         'NODE_ARCH="<(target_arch)"',
186         'NODE_PLATFORM="<(OS)"',
187         'NODE_WANT_INTERNALS=1',
188         # Warn when using deprecated V8 APIs.
189         'V8_DEPRECATION_WARNINGS=1',
190       ],
191
192
193       'conditions': [
194         [ 'node_tag!=""', {
195           'defines': [ 'NODE_TAG="<(node_tag)"' ],
196         }],
197         [ 'node_v8_options!=""', {
198           'defines': [ 'NODE_V8_OPTIONS="<(node_v8_options)"'],
199         }],
200         # No node_main.cc for anything except executable
201         [ 'node_target_type!="executable"', {
202           'sources!': [
203             'src/node_main.cc',
204           ],
205         }],
206         [ 'node_release_urlbase!=""', {
207           'defines': [
208             'NODE_RELEASE_URLBASE="<(node_release_urlbase)"',
209           ]
210         }],
211         [ 'v8_enable_i18n_support==1', {
212           'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
213           'dependencies': [
214             '<(icu_gyp_path):icui18n',
215             '<(icu_gyp_path):icuuc',
216           ],
217           'conditions': [
218             [ 'icu_small=="true"', {
219               'defines': [ 'NODE_HAVE_SMALL_ICU=1' ],
220           }]],
221         }],
222         [ 'node_use_openssl=="true"', {
223           'defines': [ 'HAVE_OPENSSL=1' ],
224           'sources': [
225             'src/node_crypto.cc',
226             'src/node_crypto_bio.cc',
227             'src/node_crypto_clienthello.cc',
228             'src/node_crypto.h',
229             'src/node_crypto_bio.h',
230             'src/node_crypto_clienthello.h',
231             'src/tls_wrap.cc',
232             'src/tls_wrap.h'
233           ],
234           'conditions': [
235             ['openssl_fips != ""', {
236               'defines': [ 'NODE_FIPS_MODE' ],
237             }],
238             [ 'node_shared_openssl=="false"', {
239               'dependencies': [
240                 './deps/openssl/openssl.gyp:openssl',
241
242                 # For tests
243                 './deps/openssl/openssl.gyp:openssl-cli',
244               ],
245               # Do not let unused OpenSSL symbols to slip away
246               'conditions': [
247                 # -force_load or --whole-archive are not applicable for
248                 # the static library
249                 [ 'node_target_type!="static_library"', {
250                   'xcode_settings': {
251                     'OTHER_LDFLAGS': [
252                       '-Wl,-force_load,<(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
253                     ],
254                   },
255                   'conditions': [
256                     ['OS in "linux freebsd"', {
257                       'ldflags': [
258                         '-Wl,--whole-archive <(PRODUCT_DIR)/<(OPENSSL_PRODUCT)',
259                         '-Wl,--no-whole-archive',
260                       ],
261                     }],
262                   ],
263                 }],
264               ],
265             }]]
266         }, {
267           'defines': [ 'HAVE_OPENSSL=0' ]
268         }],
269         [ 'node_use_dtrace=="true"', {
270           'defines': [ 'HAVE_DTRACE=1' ],
271           'dependencies': [
272             'node_dtrace_header',
273             'specialize_node_d',
274           ],
275           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
276
277           #
278           # DTrace is supported on linux, solaris, mac, and bsd.  There are
279           # three object files associated with DTrace support, but they're
280           # not all used all the time:
281           #
282           #   node_dtrace.o           all configurations
283           #   node_dtrace_ustack.o    not supported on mac and linux
284           #   node_dtrace_provider.o  All except OS X.  "dtrace -G" is not
285           #                           used on OS X.
286           #
287           # Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
288           # actually exist.  They're listed here to trick GYP into linking the
289           # corresponding object files into the final "node" executable.  These
290           # object files are generated by "dtrace -G" using custom actions
291           # below, and the GYP-generated Makefiles will properly build them when
292           # needed.
293           #
294           'sources': [ 'src/node_dtrace.cc' ],
295           'conditions': [
296             [ 'OS=="linux"', {
297               'sources': [
298                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
299               ],
300             }],
301             [ 'OS!="mac" and OS!="linux"', {
302               'sources': [
303                 'src/node_dtrace_ustack.cc',
304                 'src/node_dtrace_provider.cc',
305               ]
306             }
307           ] ]
308         } ],
309         [ 'node_use_lttng=="true"', {
310           'defines': [ 'HAVE_LTTNG=1' ],
311           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
312           'libraries': [ '-llttng-ust' ],
313           'sources': [
314             'src/node_lttng.cc'
315           ],
316         } ],
317         [ 'node_use_etw=="true"', {
318           'defines': [ 'HAVE_ETW=1' ],
319           'dependencies': [ 'node_etw' ],
320           'sources': [
321             'src/node_win32_etw_provider.h',
322             'src/node_win32_etw_provider-inl.h',
323             'src/node_win32_etw_provider.cc',
324             'src/node_dtrace.cc',
325             'tools/msvs/genfiles/node_etw_provider.h',
326             'tools/msvs/genfiles/node_etw_provider.rc',
327           ]
328         } ],
329         [ 'node_use_perfctr=="true"', {
330           'defines': [ 'HAVE_PERFCTR=1' ],
331           'dependencies': [ 'node_perfctr' ],
332           'sources': [
333             'src/node_win32_perfctr_provider.h',
334             'src/node_win32_perfctr_provider.cc',
335             'src/node_counters.cc',
336             'src/node_counters.h',
337             'tools/msvs/genfiles/node_perfctr_provider.rc',
338           ]
339         } ],
340         [ 'v8_postmortem_support=="true"', {
341           'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ],
342           'conditions': [
343             # -force_load is not applicable for the static library
344             [ 'node_target_type!="static_library"', {
345               'xcode_settings': {
346                 'OTHER_LDFLAGS': [
347                   '-Wl,-force_load,<(V8_BASE)',
348                 ],
349               },
350             }],
351           ],
352         }],
353         [ 'node_shared_zlib=="false"', {
354           'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
355         }],
356
357         [ 'node_shared_http_parser=="false"', {
358           'dependencies': [ 'deps/http_parser/http_parser.gyp:http_parser' ],
359         }],
360
361         [ 'node_shared_libuv=="false"', {
362           'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
363         }],
364
365         [ 'OS=="win"', {
366           'sources': [
367             'src/res/node.rc',
368           ],
369           'defines!': [
370             'NODE_PLATFORM="win"',
371           ],
372           'defines': [
373             'FD_SETSIZE=1024',
374             # we need to use node's preferred "win32" rather than gyp's preferred "win"
375             'NODE_PLATFORM="win32"',
376             '_UNICODE=1',
377           ],
378           'libraries': [ '-lpsapi.lib' ]
379         }, { # POSIX
380           'defines': [ '__POSIX__' ],
381         }],
382         [ 'OS=="mac"', {
383           # linking Corefoundation is needed since certain OSX debugging tools
384           # like Instruments require it for some features
385           'libraries': [ '-framework CoreFoundation' ],
386           'defines!': [
387             'NODE_PLATFORM="mac"',
388           ],
389           'defines': [
390             # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
391             'NODE_PLATFORM="darwin"',
392           ],
393         }],
394         [ 'OS=="freebsd"', {
395           'libraries': [
396             '-lutil',
397             '-lkvm',
398           ],
399         }],
400         [ 'OS=="aix"', {
401           'defines': [
402             '_LINUX_SOURCE_COMPAT',
403           ],
404         }],
405         [ 'OS=="solaris"', {
406           'libraries': [
407             '-lkstat',
408             '-lumem',
409           ],
410           'defines!': [
411             'NODE_PLATFORM="solaris"',
412           ],
413           'defines': [
414             # we need to use node's preferred "sunos"
415             # rather than gyp's preferred "solaris"
416             'NODE_PLATFORM="sunos"',
417           ],
418         }],
419         [ 'OS=="freebsd" or OS=="linux"', {
420           'ldflags': [ '-Wl,-z,noexecstack',
421                        '-Wl,--whole-archive <(V8_BASE)',
422                        '-Wl,--no-whole-archive' ]
423         }],
424         [ 'OS=="sunos"', {
425           'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
426         }],
427       ],
428       'msvs_settings': {
429         'VCManifestTool': {
430           'EmbedManifest': 'true',
431           'AdditionalManifestFiles': 'src/res/node.exe.extra.manifest'
432         }
433       },
434     },
435     # generate ETW header and resource files
436     {
437       'target_name': 'node_etw',
438       'type': 'none',
439       'conditions': [
440         [ 'node_use_etw=="true" and node_has_winsdk=="true"', {
441           'actions': [
442             {
443               'action_name': 'node_etw',
444               'inputs': [ 'src/res/node_etw_provider.man' ],
445               'outputs': [
446                 'tools/msvs/genfiles/node_etw_provider.rc',
447                 'tools/msvs/genfiles/node_etw_provider.h',
448                 'tools/msvs/genfiles/node_etw_providerTEMP.BIN',
449               ],
450               'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ]
451             }
452           ]
453         } ]
454       ]
455     },
456     # generate perf counter header and resource files
457     {
458       'target_name': 'node_perfctr',
459       'type': 'none',
460       'conditions': [
461         [ 'node_use_perfctr=="true" and node_has_winsdk=="true"', {
462           'actions': [
463             {
464               'action_name': 'node_perfctr_man',
465               'inputs': [ 'src/res/node_perfctr_provider.man' ],
466               'outputs': [
467                 'tools/msvs/genfiles/node_perfctr_provider.h',
468                 'tools/msvs/genfiles/node_perfctr_provider.rc',
469                 'tools/msvs/genfiles/MSG00001.BIN',
470               ],
471               'action': [ 'ctrpp <@(_inputs) '
472                           '-o tools/msvs/genfiles/node_perfctr_provider.h '
473                           '-rc tools/msvs/genfiles/node_perfctr_provider.rc'
474               ]
475             },
476           ],
477         } ]
478       ]
479     },
480     {
481       'target_name': 'node_js2c',
482       'type': 'none',
483       'toolsets': ['host'],
484       'actions': [
485         {
486           'action_name': 'node_js2c',
487           'inputs': [
488             '<@(library_files)',
489             './config.gypi',
490           ],
491           'outputs': [
492             '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
493           ],
494           'conditions': [
495             [ 'node_use_dtrace=="false" and node_use_etw=="false"', {
496               'inputs': [ 'src/notrace_macros.py' ]
497             }],
498             ['node_use_lttng=="false"', {
499               'inputs': [ 'src/nolttng_macros.py' ]
500             }],
501             [ 'node_use_perfctr=="false"', {
502               'inputs': [ 'src/perfctr_macros.py' ]
503             }]
504           ],
505           'action': [
506             '<(python)',
507             'tools/js2c.py',
508             '<@(_outputs)',
509             '<@(_inputs)',
510           ],
511         },
512       ],
513     }, # end node_js2c
514     {
515       'target_name': 'node_dtrace_header',
516       'type': 'none',
517       'conditions': [
518         [ 'node_use_dtrace=="true" and OS!="linux"', {
519           'actions': [
520             {
521               'action_name': 'node_dtrace_header',
522               'inputs': [ 'src/node_provider.d' ],
523               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
524               'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
525                 '-o', '<@(_outputs)' ]
526             }
527           ]
528         } ],
529         [ 'node_use_dtrace=="true" and OS=="linux"', {
530           'actions': [
531             {
532               'action_name': 'node_dtrace_header',
533               'inputs': [ 'src/node_provider.d' ],
534               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
535               'action': [ 'dtrace', '-h', '-s', '<@(_inputs)',
536                 '-o', '<@(_outputs)' ]
537             }
538           ]
539         } ],
540       ]
541     },
542     {
543       'target_name': 'node_dtrace_provider',
544       'type': 'none',
545       'conditions': [
546         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
547           'actions': [
548             {
549               'action_name': 'node_dtrace_provider_o',
550               'inputs': [
551                 '<(OBJ_DIR)/node/src/node_dtrace.o',
552               ],
553               'outputs': [
554                 '<(OBJ_DIR)/node/src/node_dtrace_provider.o'
555               ],
556               'action': [ 'dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d',
557                 '<@(_inputs)', '-o', '<@(_outputs)' ]
558             }
559           ]
560         }],
561         [ 'node_use_dtrace=="true" and OS=="linux"', {
562           'actions': [
563             {
564               'action_name': 'node_dtrace_provider_o',
565               'inputs': [ 'src/node_provider.d' ],
566               'outputs': [
567                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
568               ],
569               'action': [
570                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
571               ],
572             }
573           ],
574         }],
575       ]
576     },
577     {
578       'target_name': 'node_dtrace_ustack',
579       'type': 'none',
580       'conditions': [
581         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
582           'actions': [
583             {
584               'action_name': 'node_dtrace_ustack_constants',
585               'inputs': [
586                 '<(V8_BASE)'
587               ],
588               'outputs': [
589                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
590               ],
591               'action': [
592                 'tools/genv8constants.py',
593                 '<@(_outputs)',
594                 '<@(_inputs)'
595               ]
596             },
597             {
598               'action_name': 'node_dtrace_ustack',
599               'inputs': [
600                 'src/v8ustack.d',
601                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
602               ],
603               'outputs': [
604                 '<(OBJ_DIR)/node/src/node_dtrace_ustack.o'
605               ],
606               'conditions': [
607                 [ 'target_arch=="ia32"', {
608                   'action': [
609                     'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
610                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
611                   ]
612                 } ],
613                 [ 'target_arch=="x64"', {
614                   'action': [
615                     'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
616                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
617                   ]
618                 } ],
619               ]
620             },
621           ]
622         } ],
623       ]
624     },
625     {
626       'target_name': 'specialize_node_d',
627       'type': 'none',
628       'conditions': [
629         [ 'node_use_dtrace=="true"', {
630           'actions': [
631             {
632               'action_name': 'specialize_node_d',
633               'inputs': [
634                 'src/node.d'
635               ],
636               'outputs': [
637                 '<(PRODUCT_DIR)/node.d',
638               ],
639               'action': [
640                 'tools/specialize_node_d.py',
641                 '<@(_outputs)',
642                 '<@(_inputs)',
643                 '<@(OS)',
644                 '<@(target_arch)',
645               ],
646             },
647           ],
648         } ],
649       ]
650     },
651     {
652       'target_name': 'cctest',
653       'type': 'executable',
654       'dependencies': [
655         'deps/gtest/gtest.gyp:gtest',
656         'deps/v8/tools/gyp/v8.gyp:v8',
657         'deps/v8/tools/gyp/v8.gyp:v8_libplatform'
658       ],
659       'include_dirs': [
660         'src',
661         'deps/v8/include'
662       ],
663       'defines': [
664         # gtest's ASSERT macros conflict with our own.
665         'GTEST_DONT_DEFINE_ASSERT_EQ=1',
666         'GTEST_DONT_DEFINE_ASSERT_GE=1',
667         'GTEST_DONT_DEFINE_ASSERT_GT=1',
668         'GTEST_DONT_DEFINE_ASSERT_LE=1',
669         'GTEST_DONT_DEFINE_ASSERT_LT=1',
670         'GTEST_DONT_DEFINE_ASSERT_NE=1',
671       ],
672       'sources': [
673         'test/cctest/util.cc',
674       ],
675     }
676   ] # end targets
677 }