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