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