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