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