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