Merge remote-tracking branch 'upstream/v0.10' into v0.12
[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=="linux"', {
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           'defines!': [
323             'PLATFORM="mac"',
324           ],
325           'defines': [
326             # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
327             'PLATFORM="darwin"',
328           ],
329         }],
330         [ 'OS=="freebsd"', {
331           'libraries': [
332             '-lutil',
333             '-lkvm',
334           ],
335         }],
336         [ 'OS=="solaris"', {
337           'libraries': [
338             '-lkstat',
339             '-lumem',
340           ],
341           'defines!': [
342             'PLATFORM="solaris"',
343           ],
344           'defines': [
345             # we need to use node's preferred "sunos"
346             # rather than gyp's preferred "solaris"
347             'PLATFORM="sunos"',
348           ],
349         }],
350         [
351           'OS=="linux" and node_shared_v8=="false"', {
352             'ldflags': [
353               '-Wl,--whole-archive <(V8_BASE) -Wl,--no-whole-archive',
354             ],
355         }],
356       ],
357       'msvs_settings': {
358         'VCLinkerTool': {
359           'SubSystem': 1, # /subsystem:console
360         },
361       },
362     },
363     # generate ETW header and resource files
364     {
365       'target_name': 'node_etw',
366       'type': 'none',
367       'conditions': [
368         [ 'node_use_etw=="true" and node_has_winsdk=="true"', {
369           'actions': [
370             {
371               'action_name': 'node_etw',
372               'inputs': [ 'src/res/node_etw_provider.man' ],
373               'outputs': [
374                 'tools/msvs/genfiles/node_etw_provider.rc',
375                 'tools/msvs/genfiles/node_etw_provider.h',
376                 'tools/msvs/genfiles/node_etw_providerTEMP.BIN',
377               ],
378               'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ]
379             }
380           ]
381         } ]
382       ]
383     },
384     # generate perf counter header and resource files
385     {
386       'target_name': 'node_perfctr',
387       'type': 'none',
388       'conditions': [
389         [ 'node_use_perfctr=="true" and node_has_winsdk=="true"', {
390           'actions': [
391             {
392               'action_name': 'node_perfctr_man',
393               'inputs': [ 'src/res/node_perfctr_provider.man' ],
394               'outputs': [
395                 'tools/msvs/genfiles/node_perfctr_provider.h',
396                 'tools/msvs/genfiles/node_perfctr_provider.rc',
397                 'tools/msvs/genfiles/MSG00001.BIN',
398               ],
399               'action': [ 'ctrpp <@(_inputs) '
400                           '-o tools/msvs/genfiles/node_perfctr_provider.h '
401                           '-rc tools/msvs/genfiles/node_perfctr_provider.rc'
402               ]
403             },
404           ],
405         } ]
406       ]
407     },
408     {
409       'target_name': 'node_js2c',
410       'type': 'none',
411       'toolsets': ['host'],
412       'actions': [
413         {
414           'action_name': 'node_js2c',
415           'inputs': [
416             '<@(library_files)',
417             './config.gypi',
418           ],
419           'outputs': [
420             '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
421           ],
422           'conditions': [
423             [ 'node_use_dtrace=="false" and node_use_etw=="false"', {
424               'inputs': [ 'src/notrace_macros.py' ]
425             }],
426             [ 'node_use_perfctr=="false"', {
427               'inputs': [ 'src/perfctr_macros.py' ]
428             }]
429           ],
430           'action': [
431             '<(python)',
432             'tools/js2c.py',
433             '<@(_outputs)',
434             '<@(_inputs)',
435           ],
436         },
437       ],
438     }, # end node_js2c
439     {
440       'target_name': 'node_dtrace_header',
441       'type': 'none',
442       'conditions': [
443         [ 'node_use_dtrace=="true"', {
444           'actions': [
445             {
446               'action_name': 'node_dtrace_header',
447               'inputs': [ 'src/node_provider.d' ],
448               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
449               'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
450                 '-o', '<@(_outputs)' ]
451             }
452           ]
453         } ]
454       ]
455     },
456     {
457       'target_name': 'node_mdb',
458       'type': 'none',
459       'conditions': [
460         [ 'node_use_mdb=="true"',
461           {
462             'dependencies': [ 'deps/mdb_v8/mdb_v8.gyp:mdb_v8' ],
463             'actions': [
464               {
465                 'action_name': 'node_mdb',
466                 'inputs': [ '<(PRODUCT_DIR)/obj.target/deps/mdb_v8/mdb_v8.so' ],
467                 'outputs': [ '<(PRODUCT_DIR)/obj.target/node/src/node_mdb.o' ],
468                 'conditions': [
469                   [ 'target_arch=="ia32"', {
470                     'action': [ 'elfwrap', '-o', '<@(_outputs)', '<@(_inputs)' ],
471                   } ],
472                   [ 'target_arch=="x64"', {
473                     'action': [ 'elfwrap', '-64', '-o', '<@(_outputs)', '<@(_inputs)' ],
474                   } ],
475                 ],
476               },
477             ],
478           },
479         ],
480       ],
481     },
482     {
483       'target_name': 'node_dtrace_provider',
484       'type': 'none',
485       'conditions': [
486         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
487           'actions': [
488             {
489               'action_name': 'node_dtrace_provider_o',
490               'inputs': [
491                 '<(OBJ_DIR)/libuv/deps/uv/src/unix/core.o',
492                 '<(OBJ_DIR)/node/src/node_dtrace.o',
493               ],
494               'outputs': [
495                 '<(OBJ_DIR)/node/src/node_dtrace_provider.o'
496               ],
497               'action': [ 'dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d',
498                 '-s', 'deps/uv/src/unix/uv-dtrace.d', '<@(_inputs)',
499                 '-o', '<@(_outputs)' ]
500             }
501           ]
502         }],
503         [ 'node_use_dtrace=="true" and OS=="linux"', {
504           'actions': [
505             {
506               'action_name': 'node_dtrace_provider_o',
507               'inputs': [ 'src/node_provider.d' ],
508               'outputs': [
509                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
510               ],
511               'action': [
512                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
513               ],
514             },
515             {
516               'action_name': 'libuv_dtrace_provider_o',
517               'inputs': [ 'deps/uv/src/unix/uv-dtrace.d' ],
518               'outputs': [
519                 '<(SHARED_INTERMEDIATE_DIR)/libuv_dtrace_provider.o'
520               ],
521               'action': [
522                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
523               ],
524             },
525           ],
526         }],
527       ]
528     },
529     {
530       'target_name': 'node_dtrace_ustack',
531       'type': 'none',
532       'conditions': [
533         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
534           'actions': [
535             {
536               'action_name': 'node_dtrace_ustack_constants',
537               'inputs': [
538                 '<(V8_BASE)'
539               ],
540               'outputs': [
541                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
542               ],
543               'action': [
544                 'tools/genv8constants.py',
545                 '<@(_outputs)',
546                 '<@(_inputs)'
547               ]
548             },
549             {
550               'action_name': 'node_dtrace_ustack',
551               'inputs': [
552                 'src/v8ustack.d',
553                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
554               ],
555               'outputs': [
556                 '<(OBJ_DIR)/node/src/node_dtrace_ustack.o'
557               ],
558               'conditions': [
559                 [ 'target_arch=="ia32"', {
560                   'action': [
561                     'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
562                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
563                   ]
564                 } ],
565                 [ 'target_arch=="x64"', {
566                   'action': [
567                     'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
568                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
569                   ]
570                 } ],
571               ]
572             },
573           ]
574         } ],
575       ]
576     },
577     {
578       'target_name': 'specialize_node_d',
579       'type': 'none',
580       'conditions': [
581         [ 'node_use_dtrace=="true"', {
582           'actions': [
583             {
584               'action_name': 'specialize_node_d',
585               'inputs': [
586                 'src/node.d'
587               ],
588               'outputs': [
589                 '<(PRODUCT_DIR)/node.d',
590               ],
591               'action': [
592                 'tools/specialize_node_d.py',
593                 '<@(_outputs)',
594                 '<@(_inputs)',
595                 '<@(OS)',
596                 '<@(target_arch)',
597               ],
598             },
599           ],
600         } ],
601       ]
602     }
603   ] # end targets
604 }