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