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