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