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