• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2  'variables': {
3    'v8_use_siphash%': 0,
4    'v8_trace_maps%': 0,
5    'v8_enable_pointer_compression%': 0,
6    'v8_enable_31bit_smis_on_64bit_arch%': 0,
7    'node_use_dtrace%': 'false',
8    'node_use_etw%': 'false',
9    'node_no_browser_globals%': 'false',
10    'node_use_node_snapshot%': 'false',
11    'node_use_v8_platform%': 'true',
12    'node_use_bundled_v8%': 'true',
13    'node_shared%': 'false',
14    'force_dynamic_crt%': 0,
15    'ossfuzz' : 'false',
16    'node_module_version%': '',
17    'node_shared_brotli%': 'false',
18    'node_shared_zlib%': 'false',
19    'node_shared_http_parser%': 'false',
20    'node_shared_cares%': 'false',
21    'node_shared_libuv%': 'false',
22    'node_shared_nghttp2%': 'false',
23    'node_use_openssl%': 'true',
24    'node_shared_openssl%': 'false',
25    'node_v8_options%': '',
26    'node_core_target_name%': 'node',
27    'node_lib_target_name%': 'libnode',
28    'node_intermediate_lib_type%': 'static_library',
29    'node_builtin_modules_path%': '',
30    # We list the deps/ files out instead of globbing them in js2c.py since we
31    # only include a subset of all the files under these directories.
32    # The lengths of their file names combined should not exceed the
33    # Windows command length limit or there would be an error.
34    # See https://docs.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
35    'library_files': [
36      '<@(node_library_files)',
37    ],
38    'deps_files': [
39      'deps/v8/tools/splaytree.js',
40      'deps/v8/tools/codemap.js',
41      'deps/v8/tools/consarray.js',
42      'deps/v8/tools/csvparser.js',
43      'deps/v8/tools/profile.js',
44      'deps/v8/tools/profile_view.js',
45      'deps/v8/tools/logreader.js',
46      'deps/v8/tools/arguments.js',
47      'deps/v8/tools/tickprocessor.js',
48      'deps/v8/tools/SourceMap.js',
49      'deps/v8/tools/tickprocessor-driver.js',
50      'deps/acorn/acorn/dist/acorn.js',
51      'deps/acorn/acorn-walk/dist/walk.js',
52      'deps/cjs-module-lexer/lexer.js',
53      'deps/cjs-module-lexer/dist/lexer.js',
54    ],
55    'node_mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_mksnapshot<(EXECUTABLE_SUFFIX)',
56    'mkcodecache_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkcodecache<(EXECUTABLE_SUFFIX)',
57    'conditions': [
58      ['GENERATOR == "ninja"', {
59        'node_text_start_object_path': 'src/large_pages/node_text_start.node_text_start.o'
60      }, {
61        'node_text_start_object_path': 'node_text_start/src/large_pages/node_text_start.o'
62      }],
63      [ 'node_shared=="true"', {
64        'node_target_type%': 'shared_library',
65        'conditions': [
66          ['OS=="aix"', {
67            # For AIX, always generate static library first,
68            # It needs an extra step to generate exp and
69            # then use both static lib and exp to create
70            # shared lib.
71            'node_intermediate_lib_type': 'static_library',
72          }, {
73            'node_intermediate_lib_type': 'shared_library',
74          }],
75        ],
76      }, {
77        'node_target_type%': 'executable',
78      }],
79      [ 'OS=="win" and '
80        'node_use_openssl=="true" and '
81        'node_shared_openssl=="false"', {
82        'use_openssl_def%': 1,
83      }, {
84        'use_openssl_def%': 0,
85      }],
86    ],
87  },
88
89  'target_defaults': {
90    # Putting these explicitly here so not to depend on `common.gypi`.
91    # `common.gypi` need to be more general because it is used to build userland native addons.
92    # Refs: https://github.com/nodejs/node-gyp/issues/1118
93    'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
94    'xcode_settings': {
95      'WARNING_CFLAGS': [
96        '-Wall',
97        '-Wendif-labels',
98        '-W',
99        '-Wno-unused-parameter',
100        '-Werror=undefined-inline',
101      ],
102    },
103
104    # Relevant only for x86.
105    # Refs: https://github.com/nodejs/node/pull/25852
106    # Refs: https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers
107    'msvs_settings': {
108      'VCLinkerTool': {
109        'ImageHasSafeExceptionHandlers': 'false',
110      },
111    },
112
113    'conditions': [
114      ['OS=="aix"', {
115        'ldflags': [
116          '-Wl,-bnoerrmsg',
117        ],
118      }],
119      ['OS == "linux" and llvm_version != "0.0"', {
120        'libraries': ['-latomic'],
121      }],
122    ],
123  },
124
125  'targets': [
126    {
127      'target_name': 'node_text_start',
128      'type': 'none',
129      'conditions': [
130        [ 'OS in "linux freebsd solaris" and '
131          'target_arch=="x64"', {
132          'type': 'static_library',
133          'sources': [
134            'src/large_pages/node_text_start.S'
135          ]
136        }],
137      ]
138    },
139    {
140      'target_name': '<(node_core_target_name)',
141      'type': 'executable',
142
143      'defines': [
144        'NODE_ARCH="<(target_arch)"',
145        'NODE_PLATFORM="<(OS)"',
146        'NODE_WANT_INTERNALS=1',
147      ],
148
149      'includes': [
150        'node.gypi'
151      ],
152
153      'include_dirs': [
154        'src',
155        'deps/v8/include'
156      ],
157
158      'sources': [
159        'src/node_main.cc'
160      ],
161
162      'dependencies': [
163        'deps/histogram/histogram.gyp:histogram',
164        'deps/uvwasi/uvwasi.gyp:uvwasi',
165      ],
166
167      'msvs_settings': {
168        'VCLinkerTool': {
169          'GenerateMapFile': 'true', # /MAP
170          'MapExports': 'true', # /MAPINFO:EXPORTS
171          'RandomizedBaseAddress': 2, # enable ASLR
172          'DataExecutionPrevention': 2, # enable DEP
173          'AllowIsolation': 'true',
174        },
175      },
176
177      # - "C4244: conversion from 'type1' to 'type2', possible loss of data"
178      #   Ususaly safe. Disable for `dep`, enable for `src`
179      'msvs_disabled_warnings!': [4244],
180
181      'conditions': [
182        [ 'error_on_warn=="true"', {
183          'cflags': ['-Werror'],
184          'xcode_settings': {
185            'WARNING_CFLAGS': [ '-Werror' ],
186          },
187        }],
188        [ 'node_intermediate_lib_type=="static_library" and '
189            'node_shared=="true" and OS=="aix"', {
190          # For AIX, shared lib is linked by static lib and .exp. In the
191          # case here, the executable needs to link to shared lib.
192          # Therefore, use 'node_aix_shared' target to generate the
193          # shared lib and then executable.
194          'dependencies': [ 'node_aix_shared' ],
195        }, {
196          'dependencies': [ '<(node_lib_target_name)' ],
197        }],
198        [ 'node_intermediate_lib_type=="static_library" and node_shared=="false"', {
199          'xcode_settings': {
200            'OTHER_LDFLAGS': [
201              '-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
202              '-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
203            ],
204          },
205          'msvs_settings': {
206            'VCLinkerTool': {
207              'AdditionalOptions': [
208                '/WHOLEARCHIVE:<(node_lib_target_name)<(STATIC_LIB_SUFFIX)',
209                '/WHOLEARCHIVE:<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
210              ],
211            },
212          },
213          'conditions': [
214            ['OS != "aix" and OS != "mac"', {
215              'ldflags': [
216                '-Wl,--whole-archive',
217                '<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
218                '<(obj_dir)/tools/v8_gypfiles/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
219                '-Wl,--no-whole-archive',
220              ],
221            }],
222            [ 'OS=="win"', {
223              'sources': [ 'src/res/node.rc' ],
224              'conditions': [
225                [ 'node_use_etw=="true"', {
226                  'sources': [
227                    'tools/msvs/genfiles/node_etw_provider.rc'
228                  ],
229                }],
230              ],
231            }],
232          ],
233        }],
234        [ 'node_shared=="true"', {
235          'xcode_settings': {
236            'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
237          },
238        }],
239        ['OS=="win"', {
240          'libraries': [
241            'Dbghelp.lib',
242            'winmm.lib',
243            'Ws2_32.lib',
244          ],
245        }],
246        ['node_with_ltcg=="true"', {
247          'msvs_settings': {
248            'VCCLCompilerTool': {
249              'WholeProgramOptimization': 'true'   # /GL, whole program optimization, needed for LTCG
250            },
251            'VCLibrarianTool': {
252              'AdditionalOptions': [
253                '/LTCG:INCREMENTAL',               # link time code generation
254              ],
255            },
256            'VCLinkerTool': {
257              'OptimizeReferences': 2,             # /OPT:REF
258              'EnableCOMDATFolding': 2,            # /OPT:ICF
259              'LinkIncremental': 1,                # disable incremental linking
260              'AdditionalOptions': [
261                '/LTCG:INCREMENTAL',               # incremental link-time code generation
262              ],
263            }
264          }
265        }, {
266          'msvs_settings': {
267            'VCCLCompilerTool': {
268              'WholeProgramOptimization': 'false'
269            },
270            'VCLinkerTool': {
271              'LinkIncremental': 2                 # enable incremental linking
272            },
273          },
274         }],
275        ['node_use_node_code_cache=="true"', {
276          'dependencies': [
277            'mkcodecache',
278          ],
279          'actions': [
280            {
281              'action_name': 'run_mkcodecache',
282              'process_outputs_as_sources': 1,
283              'inputs': [
284                '<(mkcodecache_exec)',
285              ],
286              'outputs': [
287                '<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc',
288              ],
289              'action': [
290                '<@(_inputs)',
291                '<@(_outputs)',
292              ],
293            },
294          ],
295        }, {
296          'sources': [
297            'src/node_code_cache_stub.cc'
298          ],
299        }],
300        ['node_use_node_snapshot=="true"', {
301          'dependencies': [
302            'node_mksnapshot',
303          ],
304          'actions': [
305            {
306              'action_name': 'node_mksnapshot',
307              'process_outputs_as_sources': 1,
308              'inputs': [
309                '<(node_mksnapshot_exec)',
310              ],
311              'outputs': [
312                '<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
313              ],
314              'action': [
315                '<@(_inputs)',
316                '<@(_outputs)',
317              ],
318            },
319          ],
320        }, {
321          'sources': [
322            'src/node_snapshot_stub.cc'
323          ],
324        }],
325        [ 'OS in "linux freebsd" and '
326          'target_arch=="x64"', {
327          'dependencies': [ 'node_text_start' ],
328          'ldflags+': [
329            '<(obj_dir)/<(node_text_start_object_path)'
330          ]
331        }],
332      ],
333    }, # node_core_target_name
334    {
335      'target_name': '<(node_lib_target_name)',
336      'type': '<(node_intermediate_lib_type)',
337      'includes': [
338        'node.gypi',
339      ],
340
341      'include_dirs': [
342        'src',
343        '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
344      ],
345      'dependencies': [
346        'deps/googletest/googletest.gyp:gtest_prod',
347        'deps/histogram/histogram.gyp:histogram',
348        'deps/uvwasi/uvwasi.gyp:uvwasi',
349      ],
350
351      'sources': [
352        'src/api/async_resource.cc',
353        'src/api/callback.cc',
354        'src/api/encoding.cc',
355        'src/api/environment.cc',
356        'src/api/exceptions.cc',
357        'src/api/hooks.cc',
358        'src/api/utils.cc',
359        'src/async_wrap.cc',
360        'src/cares_wrap.cc',
361        'src/connect_wrap.cc',
362        'src/connection_wrap.cc',
363        'src/debug_utils.cc',
364        'src/env.cc',
365        'src/fs_event_wrap.cc',
366        'src/handle_wrap.cc',
367        'src/heap_utils.cc',
368        'src/histogram.cc',
369        'src/js_native_api.h',
370        'src/js_native_api_types.h',
371        'src/js_native_api_v8.cc',
372        'src/js_native_api_v8.h',
373        'src/js_native_api_v8_internals.h',
374        'src/js_stream.cc',
375        'src/json_utils.cc',
376        'src/js_udp_wrap.cc',
377        'src/module_wrap.cc',
378        'src/node.cc',
379        'src/node_api.cc',
380        'src/node_binding.cc',
381        'src/node_blob.cc',
382        'src/node_buffer.cc',
383        'src/node_config.cc',
384        'src/node_constants.cc',
385        'src/node_contextify.cc',
386        'src/node_credentials.cc',
387        'src/node_dir.cc',
388        'src/node_env_var.cc',
389        'src/node_errors.cc',
390        'src/node_file.cc',
391        'src/node_http_parser.cc',
392        'src/node_http2.cc',
393        'src/node_i18n.cc',
394        'src/node_main_instance.cc',
395        'src/node_messaging.cc',
396        'src/node_metadata.cc',
397        'src/node_native_module.cc',
398        'src/node_native_module_env.cc',
399        'src/node_options.cc',
400        'src/node_os.cc',
401        'src/node_perf.cc',
402        'src/node_platform.cc',
403        'src/node_postmortem_metadata.cc',
404        'src/node_process_events.cc',
405        'src/node_process_methods.cc',
406        'src/node_process_object.cc',
407        'src/node_report.cc',
408        'src/node_report_module.cc',
409        'src/node_report_utils.cc',
410        'src/node_serdes.cc',
411        'src/node_sockaddr.cc',
412        'src/node_stat_watcher.cc',
413        'src/node_symbols.cc',
414        'src/node_task_queue.cc',
415        'src/node_trace_events.cc',
416        'src/node_types.cc',
417        'src/node_url.cc',
418        'src/node_url_tables.cc',
419        'src/node_util.cc',
420        'src/node_v8.cc',
421        'src/node_wasi.cc',
422        'src/node_watchdog.cc',
423        'src/node_worker.cc',
424        'src/node_zlib.cc',
425        'src/pipe_wrap.cc',
426        'src/process_wrap.cc',
427        'src/signal_wrap.cc',
428        'src/spawn_sync.cc',
429        'src/stream_base.cc',
430        'src/stream_pipe.cc',
431        'src/stream_wrap.cc',
432        'src/string_bytes.cc',
433        'src/string_decoder.cc',
434        'src/tcp_wrap.cc',
435        'src/timers.cc',
436        'src/timer_wrap.cc',
437        'src/tracing/agent.cc',
438        'src/tracing/node_trace_buffer.cc',
439        'src/tracing/node_trace_writer.cc',
440        'src/tracing/trace_event.cc',
441        'src/tracing/traced_value.cc',
442        'src/tty_wrap.cc',
443        'src/udp_wrap.cc',
444        'src/util.cc',
445        'src/uv.cc',
446        # headers to make for a more pleasant IDE experience
447        'src/aliased_buffer.h',
448        'src/aliased_struct.h',
449        'src/aliased_struct-inl.h',
450        'src/allocated_buffer.h',
451        'src/allocated_buffer-inl.h',
452        'src/async_wrap.h',
453        'src/async_wrap-inl.h',
454        'src/base_object.h',
455        'src/base_object-inl.h',
456        'src/base64.h',
457        'src/base64-inl.h',
458        'src/callback_queue.h',
459        'src/callback_queue-inl.h',
460        'src/connect_wrap.h',
461        'src/connection_wrap.h',
462        'src/debug_utils.h',
463        'src/debug_utils-inl.h',
464        'src/env.h',
465        'src/env-inl.h',
466        'src/handle_wrap.h',
467        'src/histogram.h',
468        'src/histogram-inl.h',
469        'src/js_stream.h',
470        'src/json_utils.h',
471        'src/large_pages/node_large_page.cc',
472        'src/large_pages/node_large_page.h',
473        'src/memory_tracker.h',
474        'src/memory_tracker-inl.h',
475        'src/module_wrap.h',
476        'src/node.h',
477        'src/node_api.h',
478        'src/node_api_types.h',
479        'src/node_binding.h',
480        'src/node_blob.h',
481        'src/node_buffer.h',
482        'src/node_constants.h',
483        'src/node_context_data.h',
484        'src/node_contextify.h',
485        'src/node_dir.h',
486        'src/node_errors.h',
487        'src/node_file.h',
488        'src/node_file-inl.h',
489        'src/node_http_common.h',
490        'src/node_http_common-inl.h',
491        'src/node_http2.h',
492        'src/node_http2_state.h',
493        'src/node_i18n.h',
494        'src/node_internals.h',
495        'src/node_main_instance.h',
496        'src/node_mem.h',
497        'src/node_mem-inl.h',
498        'src/node_messaging.h',
499        'src/node_metadata.h',
500        'src/node_mutex.h',
501        'src/node_native_module.h',
502        'src/node_native_module_env.h',
503        'src/node_object_wrap.h',
504        'src/node_options.h',
505        'src/node_options-inl.h',
506        'src/node_perf.h',
507        'src/node_perf_common.h',
508        'src/node_platform.h',
509        'src/node_process.h',
510        'src/node_process-inl.h',
511        'src/node_report.h',
512        'src/node_revert.h',
513        'src/node_root_certs.h',
514        'src/node_sockaddr.h',
515        'src/node_sockaddr-inl.h',
516        'src/node_stat_watcher.h',
517        'src/node_union_bytes.h',
518        'src/node_url.h',
519        'src/node_version.h',
520        'src/node_v8.h',
521        'src/node_v8_platform-inl.h',
522        'src/node_wasi.h',
523        'src/node_watchdog.h',
524        'src/node_worker.h',
525        'src/pipe_wrap.h',
526        'src/req_wrap.h',
527        'src/req_wrap-inl.h',
528        'src/spawn_sync.h',
529        'src/stream_base.h',
530        'src/stream_base-inl.h',
531        'src/stream_pipe.h',
532        'src/stream_wrap.h',
533        'src/string_bytes.h',
534        'src/string_decoder.h',
535        'src/string_decoder-inl.h',
536        'src/string_search.h',
537        'src/tcp_wrap.h',
538        'src/tracing/agent.h',
539        'src/tracing/node_trace_buffer.h',
540        'src/tracing/node_trace_writer.h',
541        'src/tracing/trace_event.h',
542        'src/tracing/trace_event_common.h',
543        'src/tracing/traced_value.h',
544        'src/timer_wrap.h',
545        'src/tty_wrap.h',
546        'src/udp_wrap.h',
547        'src/util.h',
548        'src/util-inl.h',
549        # Dependency headers
550        'deps/v8/include/v8.h',
551        # javascript files to make for an even more pleasant IDE experience
552        '<@(library_files)',
553        '<@(deps_files)',
554        # node.gyp is added by default, common.gypi is added for change detection
555        'common.gypi',
556      ],
557
558      'variables': {
559        'openssl_system_ca_path%': '',
560        'openssl_default_cipher_list%': '',
561      },
562
563      'defines': [
564        'NODE_ARCH="<(target_arch)"',
565        'NODE_PLATFORM="<(OS)"',
566        'NODE_WANT_INTERNALS=1',
567        # Warn when using deprecated V8 APIs.
568        'V8_DEPRECATION_WARNINGS=1',
569        'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
570      ],
571
572      # - "C4244: conversion from 'type1' to 'type2', possible loss of data"
573      #   Ususaly safe. Disable for `dep`, enable for `src`
574      'msvs_disabled_warnings!': [4244],
575
576      'conditions': [
577        [ 'openssl_default_cipher_list!=""', {
578          'defines': [
579            'NODE_OPENSSL_DEFAULT_CIPHER_LIST="<(openssl_default_cipher_list)"'
580           ]
581        }],
582        [ 'error_on_warn=="true"', {
583          'cflags': ['-Werror'],
584          'xcode_settings': {
585            'WARNING_CFLAGS': [ '-Werror' ],
586          },
587        }],
588        [ 'node_builtin_modules_path!=""', {
589          'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ]
590        }],
591        [ 'node_shared=="true"', {
592          'sources': [
593            'src/node_snapshot_stub.cc',
594            'src/node_code_cache_stub.cc',
595          ]
596        }],
597        [ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
598          'product_extension': '<(shlib_suffix)',
599          'xcode_settings': {
600            'LD_DYLIB_INSTALL_NAME':
601              '@rpath/lib<(node_core_target_name).<(shlib_suffix)'
602          },
603        }],
604        ['node_shared=="true" and OS=="aix"', {
605          'product_name': 'node_base',
606        }],
607        [ 'v8_enable_inspector==1', {
608          'includes' : [ 'src/inspector/node_inspector.gypi' ],
609        }, {
610          'defines': [ 'HAVE_INSPECTOR=0' ]
611        }],
612        [ 'OS=="win"', {
613          'conditions': [
614            [ 'node_intermediate_lib_type!="static_library"', {
615              'sources': [
616                'src/res/node.rc',
617              ],
618            }],
619          ],
620          'libraries': [
621            'Dbghelp',
622            'Psapi',
623            'Ws2_32',
624          ],
625        }],
626        [ 'node_use_etw=="true"', {
627          'defines': [ 'HAVE_ETW=1' ],
628          'dependencies': [ 'node_etw' ],
629          'include_dirs': [
630            'src',
631            'tools/msvs/genfiles',
632            '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
633          ],
634          'sources': [
635            'src/node_win32_etw_provider.h',
636            'src/node_win32_etw_provider-inl.h',
637            'src/node_win32_etw_provider.cc',
638            'src/node_dtrace.h',
639            'src/node_dtrace.cc',
640            'tools/msvs/genfiles/node_etw_provider.h',
641          ],
642          'conditions': [
643            ['node_intermediate_lib_type != "static_library"', {
644              'sources': [
645                'tools/msvs/genfiles/node_etw_provider.rc',
646              ],
647            }],
648          ],
649        }],
650        [ 'node_use_dtrace=="true"', {
651          'defines': [ 'HAVE_DTRACE=1' ],
652          'dependencies': [
653            'node_dtrace_header',
654            'specialize_node_d',
655          ],
656          'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
657          #
658          # DTrace is supported on linux, solaris, mac, and bsd.  There are
659          # three object files associated with DTrace support, but they're
660          # not all used all the time:
661          #
662          #   node_dtrace.o           all configurations
663          #   node_dtrace_ustack.o    not supported on mac and linux
664          #   node_dtrace_provider.o  All except OS X.  "dtrace -G" is not
665          #                           used on OS X.
666          #
667          # Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
668          # actually exist.  They're listed here to trick GYP into linking the
669          # corresponding object files into the final "node" executable.  These
670          # object files are generated by "dtrace -G" using custom actions
671          # below, and the GYP-generated Makefiles will properly build them when
672          # needed.
673          #
674          'sources': [
675            'src/node_dtrace.h',
676            'src/node_dtrace.cc',
677          ],
678          'conditions': [
679            [ 'OS=="linux"', {
680              'sources': [
681                '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
682              ],
683            }],
684            [ 'OS!="mac" and OS!="linux"', {
685              'sources': [
686                'src/node_dtrace_ustack.cc',
687                'src/node_dtrace_provider.cc',
688              ]
689            }
690          ] ]
691        } ],
692        [ 'node_use_openssl=="true"', {
693          'sources': [
694            'src/node_crypto.cc',
695            'src/node_crypto_common.cc',
696            'src/node_crypto_bio.cc',
697            'src/node_crypto_clienthello.cc',
698            'src/node_crypto.h',
699            'src/node_crypto_common.h',
700            'src/node_crypto_bio.h',
701            'src/node_crypto_clienthello.h',
702            'src/node_crypto_clienthello-inl.h',
703            'src/node_crypto_groups.h',
704            'src/tls_wrap.cc',
705            'src/tls_wrap.h'
706          ],
707        }],
708        [ 'OS in "linux freebsd mac solaris" and '
709          'target_arch=="x64" and '
710          'node_target_type=="executable"', {
711          'defines': [ 'NODE_ENABLE_LARGE_CODE_PAGES=1' ],
712        }],
713        [ 'use_openssl_def==1', {
714          # TODO(bnoordhuis) Make all platforms export the same list of symbols.
715          # Teach mkssldef.py to generate linker maps that UNIX linkers understand.
716          'variables': {
717            'mkssldef_flags': [
718              # Categories to export.
719              '-CAES,BF,BIO,DES,DH,DSA,EC,ECDH,ECDSA,ENGINE,EVP,HMAC,MD4,MD5,'
720              'PSK,RC2,RC4,RSA,SHA,SHA0,SHA1,SHA256,SHA512,SOCK,STDIO,TLSEXT,'
721              'UI,FP_API,TLS1_METHOD,TLS1_1_METHOD,TLS1_2_METHOD,SCRYPT,OCSP,'
722              'NEXTPROTONEG,RMD160,CAST,DEPRECATEDIN_1_1_0,DEPRECATEDIN_1_2_0',
723              # Defines.
724              '-DWIN32',
725              # Symbols to filter from the export list.
726              '-X^DSO',
727              '-X^_',
728              '-X^private_',
729              # Base generated DEF on zlib.def
730              '-Bdeps/zlib/win32/zlib.def'
731            ],
732          },
733          'conditions': [
734            ['openssl_fips!=""', {
735              'variables': { 'mkssldef_flags': ['-DOPENSSL_FIPS'] },
736            }],
737          ],
738          'actions': [
739            {
740              'action_name': 'mkssldef',
741              'inputs': [
742                'deps/openssl/openssl/util/libcrypto.num',
743                'deps/openssl/openssl/util/libssl.num',
744              ],
745              'outputs': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
746              'process_outputs_as_sources': 1,
747              'action': [
748                '<(python)',
749                'tools/mkssldef.py',
750                '<@(mkssldef_flags)',
751                '-o',
752                '<@(_outputs)',
753                '<@(_inputs)',
754              ],
755            },
756          ],
757        }],
758      ],
759      'actions': [
760        {
761          'action_name': 'node_js2c',
762          'process_outputs_as_sources': 1,
763          'inputs': [
764            # Put the code first so it's a dependency and can be used for invocation.
765            'tools/js2c.py',
766            '<@(library_files)',
767            '<@(deps_files)',
768            'config.gypi'
769          ],
770          'outputs': [
771            '<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
772          ],
773          'action': [
774            '<(python)',
775            'tools/js2c.py',
776            '--directory',
777            'lib',
778            '--target',
779            '<@(_outputs)',
780            'config.gypi',
781            '<@(deps_files)',
782          ],
783        },
784      ],
785    }, # node_lib_target_name
786    {
787       # generate ETW header and resource files
788      'target_name': 'node_etw',
789      'type': 'none',
790      'conditions': [
791        [ 'node_use_etw=="true"', {
792          'actions': [
793            {
794              'action_name': 'node_etw',
795              'inputs': [ 'src/res/node_etw_provider.man' ],
796              'outputs': [
797                'tools/msvs/genfiles/node_etw_provider.rc',
798                'tools/msvs/genfiles/node_etw_provider.h',
799                'tools/msvs/genfiles/node_etw_providerTEMP.BIN',
800              ],
801              'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ]
802            }
803          ]
804        } ]
805      ]
806    }, # node_etw
807    {
808      'target_name': 'node_dtrace_header',
809      'type': 'none',
810      'conditions': [
811        [ 'node_use_dtrace=="true" and OS!="linux"', {
812          'actions': [
813            {
814              'action_name': 'node_dtrace_header',
815              'inputs': [ 'src/node_provider.d' ],
816              'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
817              'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
818                '-o', '<@(_outputs)' ]
819            }
820          ]
821        } ],
822        [ 'node_use_dtrace=="true" and OS=="linux"', {
823          'actions': [
824            {
825              'action_name': 'node_dtrace_header',
826              'inputs': [ 'src/node_provider.d' ],
827              'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
828              'action': [ 'dtrace', '-h', '-s', '<@(_inputs)',
829                '-o', '<@(_outputs)' ]
830            }
831          ]
832        } ],
833      ]
834    }, # node_dtrace_header
835    {
836      'target_name': 'node_dtrace_provider',
837      'type': 'none',
838      'conditions': [
839        [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
840          'actions': [
841            {
842              'action_name': 'node_dtrace_provider_o',
843              'inputs': [
844                '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace.o',
845              ],
846              'outputs': [
847                '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace_provider.o'
848              ],
849              'action': [ 'dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d',
850                '<@(_inputs)', '-o', '<@(_outputs)' ]
851            }
852          ]
853        }],
854        [ 'node_use_dtrace=="true" and OS=="linux"', {
855          'actions': [
856            {
857              'action_name': 'node_dtrace_provider_o',
858              'inputs': [ 'src/node_provider.d' ],
859              'outputs': [
860                '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
861              ],
862              'action': [
863                'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
864              ],
865            }
866          ],
867        }],
868      ]
869    }, # node_dtrace_provider
870    {
871      'target_name': 'node_dtrace_ustack',
872      'type': 'none',
873      'conditions': [
874        [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
875          'actions': [
876            {
877              'action_name': 'node_dtrace_ustack_constants',
878              'inputs': [
879                '<(obj_dir)/tools/v8_gypfiles/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)'
880              ],
881              'outputs': [
882                '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
883              ],
884              'action': [
885                'tools/genv8constants.py',
886                '<@(_outputs)',
887                '<@(_inputs)'
888              ]
889            },
890            {
891              'action_name': 'node_dtrace_ustack',
892              'inputs': [
893                'src/v8ustack.d',
894                '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
895              ],
896              'outputs': [
897                '<(obj_dir)/<(node_lib_target_name)/src/node_dtrace_ustack.o'
898              ],
899              'conditions': [
900                [ 'target_arch=="ia32" or target_arch=="arm"', {
901                  'action': [
902                    'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
903                    '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
904                  ]
905                } ],
906                [ 'target_arch=="x64"', {
907                  'action': [
908                    'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
909                    '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
910                  ]
911                } ],
912              ]
913            },
914          ]
915        } ],
916      ]
917    }, # node_dtrace_ustack
918    {
919      'target_name': 'specialize_node_d',
920      'type': 'none',
921      'conditions': [
922        [ 'node_use_dtrace=="true"', {
923          'actions': [
924            {
925              'action_name': 'specialize_node_d',
926              'inputs': [
927                'src/node.d'
928              ],
929              'outputs': [
930                '<(PRODUCT_DIR)/node.d',
931              ],
932              'action': [
933                'tools/specialize_node_d.py',
934                '<@(_outputs)',
935                '<@(_inputs)',
936                '<@(OS)',
937                '<@(target_arch)',
938              ],
939            },
940          ],
941        } ],
942      ]
943    }, # specialize_node_d
944    { # fuzz_url
945      'target_name': 'fuzz_url',
946      'type': 'executable',
947      'dependencies': [
948        '<(node_lib_target_name)',
949      ],
950      'includes': [
951        'node.gypi'
952      ],
953      'include_dirs': [
954        'src',
955      ],
956      'defines': [
957        'NODE_ARCH="<(target_arch)"',
958        'NODE_PLATFORM="<(OS)"',
959        'NODE_WANT_INTERNALS=1',
960      ],
961      'sources': [
962        'src/node_snapshot_stub.cc',
963        'src/node_code_cache_stub.cc',
964        'test/fuzzers/fuzz_url.cc',
965      ],
966      'conditions': [
967        ['OS=="linux"', {
968          'ldflags': [ '-fsanitize=fuzzer' ]
969        }],
970        # Ensure that ossfuzz flag has been set and that we are on Linux
971        [ 'OS!="linux" or ossfuzz!="true"', {
972          'type': 'none',
973        }],
974      ],
975    }, # fuzz_url
976    { # fuzz_env
977      'target_name': 'fuzz_env',
978      'type': 'executable',
979      'dependencies': [
980        '<(node_lib_target_name)',
981        'deps/histogram/histogram.gyp:histogram',
982        'deps/uvwasi/uvwasi.gyp:uvwasi',
983        'node_dtrace_header',
984        'node_dtrace_ustack',
985        'node_dtrace_provider',
986      ],
987      'includes': [
988        'node.gypi'
989      ],
990      'include_dirs': [
991        'src',
992        'tools/msvs/genfiles',
993        'deps/v8/include',
994        'deps/cares/include',
995        'deps/uv/include',
996        'deps/uvwasi/include',
997        'test/cctest',
998      ],
999      'defines': [
1000        'NODE_ARCH="<(target_arch)"',
1001        'NODE_PLATFORM="<(OS)"',
1002        'NODE_WANT_INTERNALS=1',
1003      ],
1004      'sources': [
1005        'src/node_snapshot_stub.cc',
1006        'src/node_code_cache_stub.cc',
1007        'test/fuzzers/fuzz_env.cc',
1008      ],
1009      'conditions': [
1010        ['OS=="linux"', {
1011          'ldflags': [ '-fsanitize=fuzzer' ]
1012        }],
1013        # Ensure that ossfuzz flag has been set and that we are on Linux
1014        [ 'OS!="linux" or ossfuzz!="true"', {
1015          'type': 'none',
1016        }],
1017      ],
1018    }, # fuzz_env
1019    {
1020      'target_name': 'cctest',
1021      'type': 'executable',
1022
1023      'dependencies': [
1024        '<(node_lib_target_name)',
1025        'deps/googletest/googletest.gyp:gtest',
1026        'deps/googletest/googletest.gyp:gtest_main',
1027        'deps/histogram/histogram.gyp:histogram',
1028        'deps/uvwasi/uvwasi.gyp:uvwasi',
1029        'node_dtrace_header',
1030        'node_dtrace_ustack',
1031        'node_dtrace_provider',
1032      ],
1033
1034      'includes': [
1035        'node.gypi'
1036      ],
1037
1038      'include_dirs': [
1039        'src',
1040        'tools/msvs/genfiles',
1041        'deps/v8/include',
1042        'deps/cares/include',
1043        'deps/uv/include',
1044        'deps/uvwasi/include',
1045        'test/cctest',
1046      ],
1047
1048      'defines': [
1049        'NODE_ARCH="<(target_arch)"',
1050        'NODE_PLATFORM="<(OS)"',
1051        'NODE_WANT_INTERNALS=1',
1052      ],
1053
1054      'sources': [
1055        'src/node_snapshot_stub.cc',
1056        'src/node_code_cache_stub.cc',
1057        'test/cctest/node_test_fixture.cc',
1058        'test/cctest/node_test_fixture.h',
1059        'test/cctest/test_aliased_buffer.cc',
1060        'test/cctest/test_base64.cc',
1061        'test/cctest/test_base_object_ptr.cc',
1062        'test/cctest/test_node_postmortem_metadata.cc',
1063        'test/cctest/test_environment.cc',
1064        'test/cctest/test_js_native_api_v8.cc',
1065        'test/cctest/test_linked_binding.cc',
1066        'test/cctest/test_node_api.cc',
1067        'test/cctest/test_per_process.cc',
1068        'test/cctest/test_platform.cc',
1069        'test/cctest/test_json_utils.cc',
1070        'test/cctest/test_sockaddr.cc',
1071        'test/cctest/test_traced_value.cc',
1072        'test/cctest/test_util.cc',
1073        'test/cctest/test_url.cc',
1074      ],
1075
1076      'conditions': [
1077        [ 'node_use_openssl=="true"', {
1078          'defines': [
1079            'HAVE_OPENSSL=1',
1080          ],
1081        }],
1082        ['v8_enable_inspector==1', {
1083          'sources': [
1084            'test/cctest/test_inspector_socket.cc',
1085            'test/cctest/test_inspector_socket_server.cc'
1086          ],
1087          'defines': [
1088            'HAVE_INSPECTOR=1',
1089          ],
1090        }, {
1091           'defines': [
1092             'HAVE_INSPECTOR=0',
1093           ]
1094        }],
1095        ['OS=="solaris"', {
1096          'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
1097        }],
1098        # Skip cctest while building shared lib node for Windows
1099        [ 'OS=="win" and node_shared=="true"', {
1100          'type': 'none',
1101        }],
1102        [ 'node_shared=="true"', {
1103          'xcode_settings': {
1104            'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
1105          },
1106        }],
1107        ['OS=="win"', {
1108          'libraries': [
1109            'Dbghelp.lib',
1110            'winmm.lib',
1111            'Ws2_32.lib',
1112          ],
1113        }],
1114      ],
1115    }, # cctest
1116
1117    {
1118      'target_name': 'embedtest',
1119      'type': 'executable',
1120
1121      'dependencies': [
1122        '<(node_lib_target_name)',
1123        'deps/histogram/histogram.gyp:histogram',
1124        'deps/uvwasi/uvwasi.gyp:uvwasi',
1125        'node_dtrace_header',
1126        'node_dtrace_ustack',
1127        'node_dtrace_provider',
1128      ],
1129
1130      'includes': [
1131        'node.gypi'
1132      ],
1133
1134      'include_dirs': [
1135        'src',
1136        'tools/msvs/genfiles',
1137        'deps/v8/include',
1138        'deps/cares/include',
1139        'deps/uv/include',
1140        'deps/uvwasi/include',
1141        'test/embedding',
1142      ],
1143
1144      'sources': [
1145        'src/node_snapshot_stub.cc',
1146        'src/node_code_cache_stub.cc',
1147        'test/embedding/embedtest.cc',
1148      ],
1149
1150      'conditions': [
1151        ['OS=="solaris"', {
1152          'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
1153        }],
1154        # Skip cctest while building shared lib node for Windows
1155        [ 'OS=="win" and node_shared=="true"', {
1156          'type': 'none',
1157        }],
1158        [ 'node_shared=="true"', {
1159          'xcode_settings': {
1160            'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
1161          },
1162        }],
1163        ['OS=="win"', {
1164          'libraries': [
1165            'Dbghelp.lib',
1166            'winmm.lib',
1167            'Ws2_32.lib',
1168          ],
1169        }],
1170      ],
1171    }, # embedtest
1172
1173    {
1174      'target_name': 'overlapped-checker',
1175      'type': 'executable',
1176
1177      'conditions': [
1178        ['OS=="win"', {
1179          'sources': [
1180            'test/overlapped-checker/main_win.c'
1181          ],
1182        }],
1183        ['OS!="win"', {
1184          'sources': [
1185            'test/overlapped-checker/main_unix.c'
1186          ],
1187        }],
1188      ]
1189    }, # overlapped-checker
1190
1191    # TODO(joyeecheung): do not depend on node_lib,
1192    # instead create a smaller static library node_lib_base that does
1193    # just enough for node_native_module.cc and the cache builder to
1194    # compile without compiling the generated code cache C++ file.
1195    # So generate_code_cache -> mkcodecache -> node_lib_base,
1196    #    node_lib -> node_lib_base & generate_code_cache
1197    {
1198      'target_name': 'mkcodecache',
1199      'type': 'executable',
1200
1201      'dependencies': [
1202        '<(node_lib_target_name)',
1203        'deps/histogram/histogram.gyp:histogram',
1204        'deps/uvwasi/uvwasi.gyp:uvwasi',
1205      ],
1206
1207      'includes': [
1208        'node.gypi'
1209      ],
1210
1211      'include_dirs': [
1212        'src',
1213        'tools/msvs/genfiles',
1214        'deps/v8/include',
1215        'deps/cares/include',
1216        'deps/uv/include',
1217        'deps/uvwasi/include',
1218      ],
1219
1220      'defines': [
1221        'NODE_WANT_INTERNALS=1'
1222      ],
1223      'sources': [
1224        'src/node_snapshot_stub.cc',
1225        'src/node_code_cache_stub.cc',
1226        'tools/code_cache/mkcodecache.cc',
1227        'tools/code_cache/cache_builder.cc',
1228        'tools/code_cache/cache_builder.h',
1229      ],
1230
1231      'conditions': [
1232        [ 'node_use_openssl=="true"', {
1233          'defines': [
1234            'HAVE_OPENSSL=1',
1235          ],
1236        }],
1237        ['v8_enable_inspector==1', {
1238          'defines': [
1239            'HAVE_INSPECTOR=1',
1240          ],
1241        }],
1242        ['OS=="win"', {
1243          'libraries': [
1244            'dbghelp.lib',
1245            'PsApi.lib',
1246            'winmm.lib',
1247            'Ws2_32.lib',
1248          ],
1249        }],
1250      ],
1251    }, # mkcodecache
1252    {
1253      'target_name': 'node_mksnapshot',
1254      'type': 'executable',
1255
1256      'dependencies': [
1257        '<(node_lib_target_name)',
1258        'deps/histogram/histogram.gyp:histogram',
1259        'deps/uvwasi/uvwasi.gyp:uvwasi',
1260      ],
1261
1262      'includes': [
1263        'node.gypi'
1264      ],
1265
1266      'include_dirs': [
1267        'src',
1268        'tools/msvs/genfiles',
1269        'deps/v8/include',
1270        'deps/cares/include',
1271        'deps/uv/include',
1272        'deps/uvwasi/include',
1273      ],
1274
1275      'defines': [ 'NODE_WANT_INTERNALS=1' ],
1276
1277      'sources': [
1278        'src/node_snapshot_stub.cc',
1279        'src/node_code_cache_stub.cc',
1280        'tools/snapshot/node_mksnapshot.cc',
1281        'tools/snapshot/snapshot_builder.cc',
1282        'tools/snapshot/snapshot_builder.h',
1283      ],
1284
1285      'conditions': [
1286        [ 'node_use_openssl=="true"', {
1287          'defines': [
1288            'HAVE_OPENSSL=1',
1289          ],
1290        }],
1291        ['v8_enable_inspector==1', {
1292          'defines': [
1293            'HAVE_INSPECTOR=1',
1294          ],
1295        }],
1296        ['OS=="win"', {
1297          'libraries': [
1298            'Dbghelp.lib',
1299            'winmm.lib',
1300            'Ws2_32.lib',
1301          ],
1302        }],
1303      ],
1304    }, # node_mksnapshot
1305  ], # end targets
1306
1307  'conditions': [
1308    ['OS=="aix" and node_shared=="true"', {
1309      'targets': [
1310        {
1311          'target_name': 'node_aix_shared',
1312          'type': 'shared_library',
1313          'product_name': '<(node_core_target_name)',
1314          'ldflags': ['--shared'],
1315          'product_extension': '<(shlib_suffix)',
1316          'includes': [
1317            'node.gypi'
1318          ],
1319          'dependencies': ['<(node_lib_target_name)'],
1320          'include_dirs': [
1321            'src',
1322            'deps/v8/include',
1323          ],
1324          'sources': [
1325            '<@(library_files)',
1326            '<@(deps_files)',
1327            'common.gypi',
1328          ],
1329          'direct_dependent_settings': {
1330            'ldflags': [ '-Wl,-brtl' ],
1331          },
1332        },
1333      ]
1334    }], # end aix section
1335  ], # end conditions block
1336}
1337