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