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