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