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