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