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