fbf0292a2ee92aa8644e67639d4927a31b394e0b
[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_use_systemtap%': 'false',
15     'node_shared_openssl%': 'false',
16     'library_files': [
17       'src/node.js',
18       'lib/_debugger.js',
19       'lib/_linklist.js',
20       'lib/assert.js',
21       'lib/buffer.js',
22       'lib/child_process.js',
23       'lib/console.js',
24       'lib/constants.js',
25       'lib/crypto.js',
26       'lib/cluster.js',
27       'lib/dgram.js',
28       'lib/dns.js',
29       'lib/domain.js',
30       'lib/events.js',
31       'lib/freelist.js',
32       'lib/fs.js',
33       'lib/http.js',
34       'lib/https.js',
35       'lib/module.js',
36       'lib/net.js',
37       'lib/os.js',
38       'lib/path.js',
39       'lib/punycode.js',
40       'lib/querystring.js',
41       'lib/readline.js',
42       'lib/repl.js',
43       'lib/stream.js',
44       'lib/_stream_readable.js',
45       'lib/_stream_writable.js',
46       'lib/_stream_duplex.js',
47       'lib/_stream_transform.js',
48       'lib/_stream_passthrough.js',
49       'lib/string_decoder.js',
50       'lib/sys.js',
51       'lib/timers.js',
52       'lib/tls.js',
53       'lib/tty.js',
54       'lib/url.js',
55       'lib/util.js',
56       'lib/vm.js',
57       'lib/zlib.js',
58     ],
59   },
60
61   'targets': [
62     {
63       'target_name': 'node',
64       'type': 'executable',
65
66       'dependencies': [
67         'node_js2c#host',
68       ],
69
70       'include_dirs': [
71         'src',
72         'tools/msvs/genfiles',
73         'deps/uv/src/ares',
74         '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
75       ],
76
77       'sources': [
78         'src/fs_event_wrap.cc',
79         'src/cares_wrap.cc',
80         'src/handle_wrap.cc',
81         'src/node.cc',
82         'src/node_buffer.cc',
83         'src/node_constants.cc',
84         'src/node_extensions.cc',
85         'src/node_file.cc',
86         'src/node_http_parser.cc',
87         'src/node_javascript.cc',
88         'src/node_main.cc',
89         'src/node_os.cc',
90         'src/node_script.cc',
91         'src/node_stat_watcher.cc',
92         'src/node_string.cc',
93         'src/node_zlib.cc',
94         'src/pipe_wrap.cc',
95         'src/signal_wrap.cc',
96         'src/string_bytes.cc',
97         'src/stream_wrap.cc',
98         'src/slab_allocator.cc',
99         'src/tcp_wrap.cc',
100         'src/timer_wrap.cc',
101         'src/tty_wrap.cc',
102         'src/process_wrap.cc',
103         'src/v8_typed_array.cc',
104         'src/udp_wrap.cc',
105         # headers to make for a more pleasant IDE experience
106         'src/handle_wrap.h',
107         'src/node.h',
108         'src/node_buffer.h',
109         'src/node_constants.h',
110         'src/node_crypto.h',
111         'src/node_extensions.h',
112         'src/node_file.h',
113         'src/node_http_parser.h',
114         'src/node_javascript.h',
115         'src/node_os.h',
116         'src/node_root_certs.h',
117         'src/node_script.h',
118         'src/node_string.h',
119         'src/node_version.h',
120         'src/ngx-queue.h',
121         'src/pipe_wrap.h',
122         'src/tty_wrap.h',
123         'src/tcp_wrap.h',
124         'src/udp_wrap.h',
125         'src/req_wrap.h',
126         'src/slab_allocator.h',
127         'src/string_bytes.h',
128         'src/stream_wrap.h',
129         'src/tree.h',
130         'src/v8_typed_array.h',
131         'deps/http_parser/http_parser.h',
132         '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
133         # javascript files to make for an even more pleasant IDE experience
134         '<@(library_files)',
135         # node.gyp is added to the project by default.
136         'common.gypi',
137       ],
138
139       'defines': [
140         'NODE_WANT_INTERNALS=1',
141         'ARCH="<(target_arch)"',
142         'PLATFORM="<(OS)"',
143         'NODE_TAG="<(node_tag)"',
144       ],
145
146       'conditions': [
147         [ 'node_use_openssl=="true"', {
148           'defines': [ 'HAVE_OPENSSL=1' ],
149           'sources': [ 'src/node_crypto.cc' ],
150           'conditions': [
151             [ 'node_shared_openssl=="false"', {
152               'dependencies': [
153                 './deps/openssl/openssl.gyp:openssl',
154
155                 # For tests
156                 './deps/openssl/openssl.gyp:openssl-cli',
157               ],
158               # Do not let unused OpenSSL symbols to slip away
159               'xcode_settings': {
160                 'OTHER_LDFLAGS': [
161                   '-Wl,-force_load,<(PRODUCT_DIR)/libopenssl.a',
162                 ],
163               },
164               'conditions': [
165                 ['OS in "linux freebsd"', {
166                   'ldflags': [
167                     '-Wl,--whole-archive <(PRODUCT_DIR)/libopenssl.a -Wl,--no-whole-archive',
168                   ],
169                 }],
170               ],
171             }]]
172         }, {
173           'defines': [ 'HAVE_OPENSSL=0' ]
174         }],
175         [ 'node_use_dtrace=="true"', {
176           'defines': [ 'HAVE_DTRACE=1' ],
177           'dependencies': [
178             'node_dtrace_header',
179             'specialize_node_d',
180           ],
181           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
182
183           #
184           # DTrace is supported on solaris, mac, and bsd.  There are three
185           # object files associated with DTrace support, but they're not all
186           # used all the time:
187           #
188           #   node_dtrace.o           all configurations
189           #   node_dtrace_ustack.o    not supported on OS X
190           #   node_dtrace_provider.o  All except OS X.  "dtrace -G" is not
191           #                           used on OS X.
192           #
193           # Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
194           # actually exist.  They're listed here to trick GYP into linking the
195           # corresponding object files into the final "node" executable.  These
196           # object files are generated by "dtrace -G" using custom actions
197           # below, and the GYP-generated Makefiles will properly build them when
198           # needed.
199           #
200           'sources': [
201             'src/node_dtrace.cc',
202           ],
203           'conditions': [ [
204             'OS!="mac"', {
205               'sources': [
206                 'src/node_dtrace_ustack.cc',
207                 'src/node_dtrace_provider.cc',
208               ]
209             }
210           ] ]
211         } ],
212         [ 'node_use_systemtap=="true"', {
213           'defines': [ 'HAVE_SYSTEMTAP=1', 'STAP_SDT_V1=1' ],
214           'dependencies': [ 'node_systemtap_header' ],
215           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
216           'sources': [
217             'src/node_dtrace.cc',
218             '<(SHARED_INTERMEDIATE_DIR)/node_systemtap.h',
219           ],
220         } ],
221         [ 'node_use_etw=="true"', {
222           'defines': [ 'HAVE_ETW=1' ],
223           'dependencies': [ 'node_etw' ],
224           'sources': [
225             'src/node_win32_etw_provider.h',
226             'src/node_win32_etw_provider-inl.h',
227             'src/node_win32_etw_provider.cc',
228             'src/node_dtrace.cc',
229             'tools/msvs/genfiles/node_etw_provider.h',
230             'tools/msvs/genfiles/node_etw_provider.rc',
231           ]
232         } ],
233         [ 'node_use_perfctr=="true"', {
234           'defines': [ 'HAVE_PERFCTR=1' ],
235           'dependencies': [ 'node_perfctr' ],
236           'sources': [
237             'src/node_win32_perfctr_provider.h',
238             'src/node_win32_perfctr_provider.cc',
239             'src/node_counters.cc',
240             'src/node_counters.h',
241             'tools/msvs/genfiles/node_perfctr_provider.rc',
242           ]
243         } ],
244         [ 'node_shared_v8=="false"', {
245           'sources': [
246             'deps/v8/include/v8.h',
247             'deps/v8/include/v8-debug.h',
248           ],
249           'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:v8' ],
250         }],
251
252         [ 'node_shared_zlib=="false"', {
253           'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
254         }],
255
256         [ 'node_shared_http_parser=="false"', {
257           'dependencies': [ 'deps/http_parser/http_parser.gyp:http_parser' ],
258         }],
259
260         [ 'node_shared_cares=="false"', {
261           'dependencies': [ 'deps/cares/cares.gyp:cares' ],
262         }],
263
264         [ 'node_shared_libuv=="false"', {
265           'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
266         }],
267
268         [ 'OS=="win"', {
269           'sources': [
270             'src/res/node.rc',
271           ],
272           'defines': [
273             'FD_SETSIZE=1024',
274             # we need to use node's preferred "win32" rather than gyp's preferred "win"
275             'PLATFORM="win32"',
276             '_UNICODE=1',
277           ],
278           'libraries': [ '-lpsapi.lib' ]
279         }, { # POSIX
280           'defines': [ '__POSIX__' ],
281         }],
282         [ 'OS=="mac"', {
283           'libraries': [ '-framework Carbon' ],
284           'defines!': [
285             'PLATFORM="mac"',
286           ],
287           'defines': [
288             # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
289             'PLATFORM="darwin"',
290           ],
291         }],
292         [ 'OS=="mac" and v8_postmortem_support=="true"', {
293           # Do not let `v8dbg_` symbols slip away
294           'xcode_settings': {
295             'OTHER_LDFLAGS': [
296               '-Wl,-force_load,<(V8_BASE)',
297             ],
298           },
299         }],
300         [ 'OS=="freebsd"', {
301           'libraries': [
302             '-lutil',
303             '-lkvm',
304           ],
305         }],
306         [ 'OS=="solaris"', {
307           'libraries': [
308             '-lkstat',
309             '-lumem',
310           ],
311           'defines!': [
312             'PLATFORM="solaris"',
313           ],
314           'defines': [
315             # we need to use node's preferred "sunos"
316             # rather than gyp's preferred "solaris"
317             'PLATFORM="sunos"',
318           ],
319         }],
320         [
321           'OS in "linux freebsd" and node_shared_v8=="false"', {
322             'ldflags': [
323               '-Wl,--whole-archive <(V8_BASE) -Wl,--no-whole-archive',
324             ],
325         }],
326       ],
327       'msvs_settings': {
328         'VCLinkerTool': {
329           'SubSystem': 1, # /subsystem:console
330         },
331       },
332     },
333     # generate ETW header and resource files
334     {
335       'target_name': 'node_etw',
336       'type': 'none',
337       'conditions': [
338         [ 'node_use_etw=="true" and node_has_winsdk=="true"', {
339           'actions': [
340             {
341               'action_name': 'node_etw',
342               'inputs': [ 'src/res/node_etw_provider.man' ],
343               'outputs': [
344                 'tools/msvs/genfiles/node_etw_provider.rc',
345                 'tools/msvs/genfiles/node_etw_provider.h',
346                 'tools/msvs/genfiles/node_etw_providerTEMP.BIN',
347               ],
348               'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ]
349             }
350           ]
351         } ]
352       ]
353     },
354     # generate perf counter header and resource files
355     {
356       'target_name': 'node_perfctr',
357       'type': 'none',
358       'conditions': [
359         [ 'node_use_perfctr=="true" and node_has_winsdk=="true"', {
360           'actions': [
361             {
362               'action_name': 'node_perfctr_man',
363               'inputs': [ 'src/res/node_perfctr_provider.man' ],
364               'outputs': [
365                 'tools/msvs/genfiles/node_perfctr_provider.h',
366                 'tools/msvs/genfiles/node_perfctr_provider.rc',
367                 'tools/msvs/genfiles/MSG00001.BIN',
368               ],
369               'action': [ 'ctrpp <@(_inputs) '
370                           '-o tools/msvs/genfiles/node_perfctr_provider.h '
371                           '-rc tools/msvs/genfiles/node_perfctr_provider.rc'
372               ]
373             },
374           ],
375         } ]
376       ]
377     },
378     {
379       'target_name': 'node_js2c',
380       'type': 'none',
381       'toolsets': ['host'],
382       'actions': [
383         {
384           'action_name': 'node_js2c',
385           'inputs': [
386             '<@(library_files)',
387             './config.gypi',
388           ],
389           'outputs': [
390             '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
391           ],
392           'conditions': [
393             [ 'node_use_dtrace=="false"'
394               ' and node_use_etw=="false"'
395               ' and node_use_systemtap=="false"',
396             {
397                 'inputs': ['src/macros.py']
398               }
399               ],
400             [ 'node_use_perfctr=="false"', {
401               'inputs': [ 'src/perfctr_macros.py' ]
402             }]
403           ],
404               'action': [
405                 '<(python)',
406                 'tools/js2c.py',
407                 '<@(_outputs)',
408                 '<@(_inputs)',
409               ],
410         },
411       ],
412     }, # end node_js2c
413     {
414       'target_name': 'node_dtrace_header',
415       'type': 'none',
416       'conditions': [
417         [ 'node_use_dtrace=="true"', {
418           'actions': [
419             {
420               'action_name': 'node_dtrace_header',
421               'inputs': [ 'src/node_provider.d' ],
422               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
423               'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
424                 '-o', '<@(_outputs)' ]
425             }
426           ]
427         } ]
428       ]
429     },
430     {
431       'target_name': 'node_systemtap_header',
432       'type': 'none',
433       'conditions': [
434         [ 'node_use_systemtap=="true"', {
435           'actions': [
436             {
437               'action_name': 'node_systemtap_header',
438               'inputs': [ 'src/node_systemtap.d' ],
439               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_systemtap.h' ],
440               'action': [ 'dtrace', '-h', '-C', '-s', '<@(_inputs)',
441                 '-o', '<@(_outputs)' ]
442             }
443           ]
444         } ]
445       ]
446     },
447     {
448       'target_name': 'node_dtrace_provider',
449       'type': 'none',
450       'conditions': [
451         [ 'node_use_dtrace=="true" and OS!="mac"', {
452           'actions': [
453             {
454               'action_name': 'node_dtrace_provider_o',
455               'inputs': [
456                 'src/node_provider.d',
457                 '<(OBJ_DIR)/node/src/node_dtrace.o'
458               ],
459               'outputs': [
460                 '<(OBJ_DIR)/node/src/node_dtrace_provider.o'
461               ],
462               'action': [ 'dtrace', '-G', '-xnolibs', '-s', '<@(_inputs)',
463                 '-o', '<@(_outputs)' ]
464             }
465           ]
466         } ]
467       ]
468     },
469     {
470       'target_name': 'node_dtrace_ustack',
471       'type': 'none',
472       'conditions': [
473         [ 'node_use_dtrace=="true" and OS!="mac"', {
474           'actions': [
475             {
476               'action_name': 'node_dtrace_ustack_constants',
477               'inputs': [
478                 '<(V8_BASE)'
479               ],
480               'outputs': [
481                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
482               ],
483               'action': [
484                 'tools/genv8constants.py',
485                 '<@(_outputs)',
486                 '<@(_inputs)'
487               ]
488             },
489             {
490               'action_name': 'node_dtrace_ustack',
491               'inputs': [
492                 'src/v8ustack.d',
493                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
494               ],
495               'outputs': [
496                 '<(OBJ_DIR)/node/src/node_dtrace_ustack.o'
497               ],
498               'conditions': [
499                 [ 'target_arch=="ia32"', {
500                   'action': [
501                     'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
502                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
503                   ]
504                 } ],
505                 [ 'target_arch=="x64"', {
506                   'action': [
507                     'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
508                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
509                   ]
510                 } ],
511               ]
512             },
513           ]
514         } ],
515       ]
516     },
517     {
518       'target_name': 'specialize_node_d',
519       'type': 'none',
520       'conditions': [
521         [ 'node_use_dtrace=="true"', {
522           'actions': [
523             {
524               'action_name': 'specialize_node_d',
525               'inputs': [
526                 'src/node.d'
527               ],
528               'outputs': [
529                 '<(PRODUCT_DIR)/node.d',
530               ],
531               'action': [
532                 'tools/specialize_node_d.py',
533                 '<@(_outputs)',
534                 '<@(_inputs)',
535                 '<@(OS)',
536                 '<@(target_arch)',
537               ],
538             },
539           ],
540         } ],
541       ]
542     }
543   ] # end targets
544 }