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