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