Merge remote-tracking branch 'origin/v0.10' into master
[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             }]]
188         }, {
189           'defines': [ 'HAVE_OPENSSL=0' ]
190         }],
191         [ 'node_use_dtrace=="true"', {
192           'defines': [ 'HAVE_DTRACE=1' ],
193           'dependencies': [
194             'node_dtrace_header',
195             'specialize_node_d',
196           ],
197           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
198
199           #
200           # DTrace is supported on linux, solaris, mac, and bsd.  There are
201           # three object files associated with DTrace support, but they're
202           # not all used all the time:
203           #
204           #   node_dtrace.o           all configurations
205           #   node_dtrace_ustack.o    not supported on mac and linux
206           #   node_dtrace_provider.o  All except OS X.  "dtrace -G" is not
207           #                           used on OS X.
208           #
209           # Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
210           # actually exist.  They're listed here to trick GYP into linking the
211           # corresponding object files into the final "node" executable.  These
212           # object files are generated by "dtrace -G" using custom actions
213           # below, and the GYP-generated Makefiles will properly build them when
214           # needed.
215           #
216           'sources': [ 'src/node_dtrace.cc' ],
217           'conditions': [
218             [ 'OS=="linux"', {
219               'sources': [
220                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o',
221                 '<(SHARED_INTERMEDIATE_DIR)/libuv_dtrace_provider.o',
222               ],
223             }],
224             [ 'OS!="mac" and OS!="linux"', {
225               'sources': [
226                 'src/node_dtrace_ustack.cc',
227                 'src/node_dtrace_provider.cc',
228               ]
229             }
230           ] ]
231         } ],
232         [ 'node_use_mdb=="true"', {
233           'dependencies': [ 'node_mdb' ],
234           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
235           'sources': [
236             'src/node_mdb.cc',
237           ],
238         } ],
239         [ 'node_use_etw=="true"', {
240           'defines': [ 'HAVE_ETW=1' ],
241           'dependencies': [ 'node_etw' ],
242           'sources': [
243             'src/node_win32_etw_provider.h',
244             'src/node_win32_etw_provider-inl.h',
245             'src/node_win32_etw_provider.cc',
246             'src/node_dtrace.cc',
247             'tools/msvs/genfiles/node_etw_provider.h',
248             'tools/msvs/genfiles/node_etw_provider.rc',
249           ]
250         } ],
251         [ 'node_use_perfctr=="true"', {
252           'defines': [ 'HAVE_PERFCTR=1' ],
253           'dependencies': [ 'node_perfctr' ],
254           'sources': [
255             'src/node_win32_perfctr_provider.h',
256             'src/node_win32_perfctr_provider.cc',
257             'src/node_counters.cc',
258             'src/node_counters.h',
259             'tools/msvs/genfiles/node_perfctr_provider.rc',
260           ]
261         } ],
262         [ 'v8_postmortem_support=="true"', {
263           'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ],
264           'xcode_settings': {
265             'OTHER_LDFLAGS': [
266               '-Wl,-force_load,<(V8_BASE)',
267             ],
268           },
269         }],
270         [ 'node_shared_v8=="false"', {
271           'sources': [
272             'deps/v8/include/v8.h',
273             'deps/v8/include/v8-debug.h',
274           ],
275           'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:v8' ],
276         }],
277
278         [ 'node_shared_zlib=="false"', {
279           'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
280         }],
281
282         [ 'node_shared_http_parser=="false"', {
283           'dependencies': [ 'deps/http_parser/http_parser.gyp:http_parser' ],
284         }],
285
286         [ 'node_shared_cares=="false"', {
287           'dependencies': [ 'deps/cares/cares.gyp:cares' ],
288         }],
289
290         [ 'node_shared_libuv=="false"', {
291           'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
292         }],
293
294         [ 'OS=="win"', {
295           'sources': [
296             'src/res/node.rc',
297           ],
298           'defines': [
299             'FD_SETSIZE=1024',
300             # we need to use node's preferred "win32" rather than gyp's preferred "win"
301             'PLATFORM="win32"',
302             '_UNICODE=1',
303           ],
304           'libraries': [ '-lpsapi.lib' ]
305         }, { # POSIX
306           'defines': [ '__POSIX__' ],
307         }],
308         [ 'OS=="mac"', {
309           'defines!': [
310             'PLATFORM="mac"',
311           ],
312           'defines': [
313             # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
314             'PLATFORM="darwin"',
315           ],
316         }],
317         [ 'OS=="freebsd"', {
318           'libraries': [
319             '-lutil',
320             '-lkvm',
321           ],
322         }],
323         [ 'OS=="solaris"', {
324           'libraries': [
325             '-lkstat',
326             '-lumem',
327           ],
328           'defines!': [
329             'PLATFORM="solaris"',
330           ],
331           'defines': [
332             # we need to use node's preferred "sunos"
333             # rather than gyp's preferred "solaris"
334             'PLATFORM="sunos"',
335           ],
336         }],
337         [
338           'OS=="linux" and node_shared_v8=="false"', {
339             'ldflags': [
340               '-Wl,--whole-archive <(V8_BASE) -Wl,--no-whole-archive',
341             ],
342         }],
343       ],
344       'msvs_settings': {
345         'VCLinkerTool': {
346           'SubSystem': 1, # /subsystem:console
347         },
348       },
349     },
350     # generate ETW header and resource files
351     {
352       'target_name': 'node_etw',
353       'type': 'none',
354       'conditions': [
355         [ 'node_use_etw=="true" and node_has_winsdk=="true"', {
356           'actions': [
357             {
358               'action_name': 'node_etw',
359               'inputs': [ 'src/res/node_etw_provider.man' ],
360               'outputs': [
361                 'tools/msvs/genfiles/node_etw_provider.rc',
362                 'tools/msvs/genfiles/node_etw_provider.h',
363                 'tools/msvs/genfiles/node_etw_providerTEMP.BIN',
364               ],
365               'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ]
366             }
367           ]
368         } ]
369       ]
370     },
371     # generate perf counter header and resource files
372     {
373       'target_name': 'node_perfctr',
374       'type': 'none',
375       'conditions': [
376         [ 'node_use_perfctr=="true" and node_has_winsdk=="true"', {
377           'actions': [
378             {
379               'action_name': 'node_perfctr_man',
380               'inputs': [ 'src/res/node_perfctr_provider.man' ],
381               'outputs': [
382                 'tools/msvs/genfiles/node_perfctr_provider.h',
383                 'tools/msvs/genfiles/node_perfctr_provider.rc',
384                 'tools/msvs/genfiles/MSG00001.BIN',
385               ],
386               'action': [ 'ctrpp <@(_inputs) '
387                           '-o tools/msvs/genfiles/node_perfctr_provider.h '
388                           '-rc tools/msvs/genfiles/node_perfctr_provider.rc'
389               ]
390             },
391           ],
392         } ]
393       ]
394     },
395     {
396       'target_name': 'node_js2c',
397       'type': 'none',
398       'toolsets': ['host'],
399       'actions': [
400         {
401           'action_name': 'node_js2c',
402           'inputs': [
403             '<@(library_files)',
404             './config.gypi',
405           ],
406           'outputs': [
407             '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
408           ],
409           'conditions': [
410             [ 'node_use_dtrace=="false" and node_use_etw=="false"', {
411               'inputs': [ 'src/notrace_macros.py' ]
412             }],
413             [ 'node_use_perfctr=="false"', {
414               'inputs': [ 'src/perfctr_macros.py' ]
415             }]
416           ],
417           'action': [
418             '<(python)',
419             'tools/js2c.py',
420             '<@(_outputs)',
421             '<@(_inputs)',
422           ],
423         },
424       ],
425     }, # end node_js2c
426     {
427       'target_name': 'node_dtrace_header',
428       'type': 'none',
429       'conditions': [
430         [ 'node_use_dtrace=="true"', {
431           'actions': [
432             {
433               'action_name': 'node_dtrace_header',
434               'inputs': [ 'src/node_provider.d' ],
435               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
436               'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
437                 '-o', '<@(_outputs)' ]
438             }
439           ]
440         } ]
441       ]
442     },
443     {
444       'target_name': 'node_mdb',
445       'type': 'none',
446       'conditions': [
447         [ 'node_use_mdb=="true"',
448           {
449             'dependencies': [ 'deps/mdb_v8/mdb_v8.gyp:mdb_v8' ],
450             'actions': [
451               {
452                 'action_name': 'node_mdb',
453                 'inputs': [ '<(PRODUCT_DIR)/obj.target/deps/mdb_v8/mdb_v8.so' ],
454                 'outputs': [ '<(PRODUCT_DIR)/obj.target/node/src/node_mdb.o' ],
455                 'conditions': [
456                   [ 'target_arch=="ia32"', {
457                     'action': [ 'elfwrap', '-o', '<@(_outputs)', '<@(_inputs)' ],
458                   } ],
459                   [ 'target_arch=="x64"', {
460                     'action': [ 'elfwrap', '-64', '-o', '<@(_outputs)', '<@(_inputs)' ],
461                   } ],
462                 ],
463               },
464             ],
465           },
466         ],
467       ],
468     },
469     {
470       'target_name': 'node_dtrace_provider',
471       'type': 'none',
472       'conditions': [
473         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
474           'actions': [
475             {
476               'action_name': 'node_dtrace_provider_o',
477               'inputs': [
478                 '<(OBJ_DIR)/libuv/deps/uv/src/unix/core.o',
479                 '<(OBJ_DIR)/node/src/node_dtrace.o',
480               ],
481               'outputs': [
482                 '<(OBJ_DIR)/node/src/node_dtrace_provider.o'
483               ],
484               'action': [ 'dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d',
485                 '-s', 'deps/uv/src/unix/uv-dtrace.d', '<@(_inputs)',
486                 '-o', '<@(_outputs)' ]
487             }
488           ]
489         }],
490         [ 'node_use_dtrace=="true" and OS=="linux"', {
491           'actions': [
492             {
493               'action_name': 'node_dtrace_provider_o',
494               'inputs': [ 'src/node_provider.d' ],
495               'outputs': [
496                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
497               ],
498               'action': [
499                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
500               ],
501             },
502             {
503               'action_name': 'libuv_dtrace_provider_o',
504               'inputs': [ 'deps/uv/src/unix/uv-dtrace.d' ],
505               'outputs': [
506                 '<(SHARED_INTERMEDIATE_DIR)/libuv_dtrace_provider.o'
507               ],
508               'action': [
509                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
510               ],
511             },
512           ],
513         }],
514       ]
515     },
516     {
517       'target_name': 'node_dtrace_ustack',
518       'type': 'none',
519       'conditions': [
520         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
521           'actions': [
522             {
523               'action_name': 'node_dtrace_ustack_constants',
524               'inputs': [
525                 '<(V8_BASE)'
526               ],
527               'outputs': [
528                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
529               ],
530               'action': [
531                 'tools/genv8constants.py',
532                 '<@(_outputs)',
533                 '<@(_inputs)'
534               ]
535             },
536             {
537               'action_name': 'node_dtrace_ustack',
538               'inputs': [
539                 'src/v8ustack.d',
540                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
541               ],
542               'outputs': [
543                 '<(OBJ_DIR)/node/src/node_dtrace_ustack.o'
544               ],
545               'conditions': [
546                 [ 'target_arch=="ia32"', {
547                   'action': [
548                     'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
549                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
550                   ]
551                 } ],
552                 [ 'target_arch=="x64"', {
553                   'action': [
554                     'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
555                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
556                   ]
557                 } ],
558               ]
559             },
560           ]
561         } ],
562       ]
563     },
564     {
565       'target_name': 'specialize_node_d',
566       'type': 'none',
567       'conditions': [
568         [ 'node_use_dtrace=="true"', {
569           'actions': [
570             {
571               'action_name': 'specialize_node_d',
572               'inputs': [
573                 'src/node.d'
574               ],
575               'outputs': [
576                 '<(PRODUCT_DIR)/node.d',
577               ],
578               'action': [
579                 'tools/specialize_node_d.py',
580                 '<@(_outputs)',
581                 '<@(_inputs)',
582                 '<@(OS)',
583                 '<@(target_arch)',
584               ],
585             },
586           ],
587         } ],
588       ]
589     }
590   ] # end targets
591 }