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