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