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