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