From 9b59718f506d6f9733e554e58e212dcce1638156 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Sat, 4 Mar 2023 20:59:55 +0900
Subject: [PATCH] gyp: put filenames in variables

---
 deps/ada/ada.gyp                  |   3 +-
 deps/base64/base64.gyp            |  15 +-
 deps/brotli/brotli.gyp            |  73 ++--
 deps/cares/cares.gyp              | 175 ++++-----
 deps/googletest/googletest.gyp    |  73 ++--
 deps/histogram/histogram.gyp      |   7 +-
 deps/llhttp/llhttp.gyp            |  11 +-
 deps/nghttp2/nghttp2.gyp          |  51 +--
 deps/simdutf/simdutf.gyp          |   9 +-
 deps/uv/uv.gyp                    | 238 +++++++------
 deps/uvwasi/uvwasi.gyp            |  21 +-
 node.gyp                          | 567 +++++++++++++++---------------
 src/inspector/node_inspector.gypi |  51 +--
 13 files changed, 688 insertions(+), 606 deletions(-)

diff --git a/deps/ada/ada.gyp b/deps/ada/ada.gyp
index 1171e8750755e1..9e21432287d629 100644
--- a/deps/ada/ada.gyp
+++ b/deps/ada/ada.gyp
@@ -1,6 +1,7 @@
 {
   'variables': {
     'v8_enable_i18n_support%': 1,
+    'ada_sources': [ 'ada.cpp' ],
   },
   'targets': [
     {
@@ -10,7 +11,7 @@
       'direct_dependent_settings': {
         'include_dirs': ['.'],
       },
-      'sources': ['ada.cpp'],
+      'sources': [ '<@(ada_sources)' ],
       'conditions': [
         ['v8_enable_i18n_support==0', {
           'defines': ['ADA_HAS_ICU=0'],
diff --git a/deps/base64/base64.gyp b/deps/base64/base64.gyp
index be68561708fef0..06b20a142b1679 100644
--- a/deps/base64/base64.gyp
+++ b/deps/base64/base64.gyp
@@ -2,6 +2,14 @@
   'variables': {
     'arm_fpu%': '',
     'target_arch%': '',
+    'base64_sources_common': [
+      'base64/include/libbase64.h',
+      'base64/lib/arch/generic/codec.c',
+      'base64/lib/tables/tables.c',
+      'base64/lib/codec_choose.c',
+      'base64/lib/codecs.h',
+      'base64/lib/lib.c',
+    ],
   },
   'targets': [
     {
@@ -14,12 +22,7 @@
       },
       'defines': [ 'BASE64_STATIC_DEFINE' ],
       'sources': [
-        'base64/include/libbase64.h',
-        'base64/lib/arch/generic/codec.c',
-        'base64/lib/tables/tables.c',
-        'base64/lib/codec_choose.c',
-        'base64/lib/codecs.h',
-        'base64/lib/lib.c',
+        '<@(base64_sources_common)',
       ],
 
       'conditions': [
diff --git a/deps/brotli/brotli.gyp b/deps/brotli/brotli.gyp
index 2e6ab9bde3d1b7..9fc9bcdfd54ece 100644
--- a/deps/brotli/brotli.gyp
+++ b/deps/brotli/brotli.gyp
@@ -1,4 +1,42 @@
 {
+  'variables': {
+    'brotli_sources': [
+      # Common
+      'c/common/constants.c',
+      'c/common/context.c',
+      'c/common/dictionary.c',
+      'c/common/platform.c',
+      'c/common/transform.c',
+
+      # Decoder
+      'c/dec/bit_reader.c',
+      'c/dec/decode.c',
+      'c/dec/huffman.c',
+      'c/dec/state.c',
+
+      # Encoder
+      'c/enc/backward_references.c',
+      'c/enc/backward_references_hq.c',
+      'c/enc/bit_cost.c',
+      'c/enc/block_splitter.c',
+      'c/enc/brotli_bit_stream.c',
+      'c/enc/cluster.c',
+      'c/enc/command.c',
+      'c/enc/compress_fragment.c',
+      'c/enc/compress_fragment_two_pass.c',
+      'c/enc/dictionary_hash.c',
+      'c/enc/encode.c',
+      'c/enc/encoder_dict.c',
+      'c/enc/entropy_encode.c',
+      'c/enc/fast_log.c',
+      'c/enc/histogram.c',
+      'c/enc/literal_cost.c',
+      'c/enc/memory.c',
+      'c/enc/metablock.c',
+      'c/enc/static_dict.c',
+      'c/enc/utf8_util.c',
+    ]
+  },
   'targets': [
     {
       'target_name': 'brotli',
@@ -28,40 +66,7 @@
         '-lm',
       ],
       'sources': [
-        # Common
-        'c/common/constants.c',
-        'c/common/context.c',
-        'c/common/dictionary.c',
-        'c/common/platform.c',
-        'c/common/transform.c',
-
-        # Decoder
-        'c/dec/bit_reader.c',
-        'c/dec/decode.c',
-        'c/dec/huffman.c',
-        'c/dec/state.c',
-
-        # Encoder
-        'c/enc/backward_references.c',
-        'c/enc/backward_references_hq.c',
-        'c/enc/bit_cost.c',
-        'c/enc/block_splitter.c',
-        'c/enc/brotli_bit_stream.c',
-        'c/enc/cluster.c',
-        'c/enc/command.c',
-        'c/enc/compress_fragment.c',
-        'c/enc/compress_fragment_two_pass.c',
-        'c/enc/dictionary_hash.c',
-        'c/enc/encode.c',
-        'c/enc/encoder_dict.c',
-        'c/enc/entropy_encode.c',
-        'c/enc/fast_log.c',
-        'c/enc/histogram.c',
-        'c/enc/literal_cost.c',
-        'c/enc/memory.c',
-        'c/enc/metablock.c',
-        'c/enc/static_dict.c',
-        'c/enc/utf8_util.c'
+        '<@(brotli_sources)',
       ]
     }
   ]
diff --git a/deps/cares/cares.gyp b/deps/cares/cares.gyp
index 6c93a07e60e1a8..501e79e79105f9 100644
--- a/deps/cares/cares.gyp
+++ b/deps/cares/cares.gyp
@@ -1,4 +1,94 @@
 {
+  'variables': {
+    'cares_sources_common': [
+      'include/ares.h',
+      'include/ares_dns.h',
+      'include/ares_nameser.h',
+      'include/ares_rules.h',
+      'include/ares_version.h',
+      'src/lib/ares__addrinfo2hostent.c',
+      'src/lib/ares__addrinfo_localhost.c',
+      'src/lib/ares_android.c',
+      'src/lib/ares_cancel.c',
+      'src/lib/ares__close_sockets.c',
+      'src/lib/ares_create_query.c',
+      'src/lib/ares_data.c',
+      'src/lib/ares_data.h',
+      'src/lib/ares_destroy.c',
+      'src/lib/ares_expand_name.c',
+      'src/lib/ares_expand_string.c',
+      'src/lib/ares_fds.c',
+      'src/lib/ares_free_hostent.c',
+      'src/lib/ares_free_string.c',
+      'src/lib/ares_freeaddrinfo.c',
+      'src/lib/ares_getenv.h',
+      'src/lib/ares_getaddrinfo.c',
+      'src/lib/ares_gethostbyaddr.c',
+      'src/lib/ares_gethostbyname.c',
+      'src/lib/ares__get_hostent.c',
+      'src/lib/ares_getnameinfo.c',
+      'src/lib/ares_getsock.c',
+      'src/lib/ares_init.c',
+      'src/lib/ares_ipv6.h',
+      'src/lib/ares_library_init.c',
+      'src/lib/ares_library_init.h',
+      'src/lib/ares_llist.c',
+      'src/lib/ares_llist.h',
+      'src/lib/ares_mkquery.c',
+      'src/lib/ares_nowarn.c',
+      'src/lib/ares_nowarn.h',
+      'src/lib/ares_options.c',
+      'src/lib/ares__parse_into_addrinfo.c',
+      'src/lib/ares_parse_aaaa_reply.c',
+      'src/lib/ares_parse_a_reply.c',
+      'src/lib/ares_parse_caa_reply.c',
+      'src/lib/ares_parse_mx_reply.c',
+      'src/lib/ares_parse_naptr_reply.c',
+      'src/lib/ares_parse_ns_reply.c',
+      'src/lib/ares_parse_ptr_reply.c',
+      'src/lib/ares_parse_soa_reply.c',
+      'src/lib/ares_parse_srv_reply.c',
+      'src/lib/ares_parse_txt_reply.c',
+      'src/lib/ares_parse_uri_reply.c',
+      'src/lib/ares_platform.h',
+      'src/lib/ares_private.h',
+      'src/lib/ares_process.c',
+      'src/lib/ares_query.c',
+      'src/lib/ares__read_line.c',
+      'src/lib/ares__readaddrinfo.c',
+      'src/lib/ares_search.c',
+      'src/lib/ares_send.c',
+      'src/lib/ares_setup.h',
+      'src/lib/ares__sortaddrinfo.c',
+      'src/lib/ares_strcasecmp.c',
+      'src/lib/ares_strcasecmp.h',
+      'src/lib/ares_strdup.c',
+      'src/lib/ares_strdup.h',
+      'src/lib/ares_strerror.c',
+      'src/lib/ares_strsplit.c',
+      'src/lib/ares_timeout.c',
+      'src/lib/ares__timeval.c',
+      'src/lib/ares_version.c',
+      'src/lib/ares_writev.c',
+      'src/lib/ares_writev.h',
+      'src/lib/bitncmp.c',
+      'src/lib/bitncmp.h',
+      'src/lib/inet_net_pton.c',
+      'src/lib/inet_ntop.c',
+      'src/lib/ares_inet_net_pton.h',
+      'src/lib/setup_once.h',
+      'src/tools/ares_getopt.c',
+      'src/tools/ares_getopt.h',
+    ],
+    'cares_sources_win': [
+      'src/lib/config-win32.h',
+      'src/lib/windows_port.c',
+      'src/lib/ares_getenv.c',
+      'src/lib/ares_iphlpapi.h',
+      'src/lib/ares_platform.c',
+    ],
+  },
+
   'target_defaults': {
     'conditions': [
       ['OS!="win"', {
@@ -35,84 +125,7 @@
         'include_dirs': [ 'include' ]
       },
       'sources': [
-        'include/ares.h',
-        'include/ares_dns.h',
-        'include/ares_nameser.h',
-        'include/ares_rules.h',
-        'include/ares_version.h',
-        'src/lib/ares__addrinfo2hostent.c',
-        'src/lib/ares__addrinfo_localhost.c',
-        'src/lib/ares_android.c',
-        'src/lib/ares_cancel.c',
-        'src/lib/ares__close_sockets.c',
-        'src/lib/ares_create_query.c',
-        'src/lib/ares_data.c',
-        'src/lib/ares_data.h',
-        'src/lib/ares_destroy.c',
-        'src/lib/ares_expand_name.c',
-        'src/lib/ares_expand_string.c',
-        'src/lib/ares_fds.c',
-        'src/lib/ares_free_hostent.c',
-        'src/lib/ares_free_string.c',
-        'src/lib/ares_freeaddrinfo.c',
-        'src/lib/ares_getenv.h',
-        'src/lib/ares_getaddrinfo.c',
-        'src/lib/ares_gethostbyaddr.c',
-        'src/lib/ares_gethostbyname.c',
-        'src/lib/ares__get_hostent.c',
-        'src/lib/ares_getnameinfo.c',
-        'src/lib/ares_getsock.c',
-        'src/lib/ares_init.c',
-        'src/lib/ares_ipv6.h',
-        'src/lib/ares_library_init.c',
-        'src/lib/ares_library_init.h',
-        'src/lib/ares_llist.c',
-        'src/lib/ares_llist.h',
-        'src/lib/ares_mkquery.c',
-        'src/lib/ares_nowarn.c',
-        'src/lib/ares_nowarn.h',
-        'src/lib/ares_options.c',
-        'src/lib/ares__parse_into_addrinfo.c',
-        'src/lib/ares_parse_aaaa_reply.c',
-        'src/lib/ares_parse_a_reply.c',
-        'src/lib/ares_parse_caa_reply.c',
-        'src/lib/ares_parse_mx_reply.c',
-        'src/lib/ares_parse_naptr_reply.c',
-        'src/lib/ares_parse_ns_reply.c',
-        'src/lib/ares_parse_ptr_reply.c',
-        'src/lib/ares_parse_soa_reply.c',
-        'src/lib/ares_parse_srv_reply.c',
-        'src/lib/ares_parse_txt_reply.c',
-        'src/lib/ares_parse_uri_reply.c',
-        'src/lib/ares_platform.h',
-        'src/lib/ares_private.h',
-        'src/lib/ares_process.c',
-        'src/lib/ares_query.c',
-        'src/lib/ares__read_line.c',
-        'src/lib/ares__readaddrinfo.c',
-        'src/lib/ares_search.c',
-        'src/lib/ares_send.c',
-        'src/lib/ares_setup.h',
-        'src/lib/ares__sortaddrinfo.c',
-        'src/lib/ares_strcasecmp.c',
-        'src/lib/ares_strcasecmp.h',
-        'src/lib/ares_strdup.c',
-        'src/lib/ares_strdup.h',
-        'src/lib/ares_strerror.c',
-        'src/lib/ares_strsplit.c',
-        'src/lib/ares_timeout.c',
-        'src/lib/ares__timeval.c',
-        'src/lib/ares_version.c',
-        'src/lib/ares_writev.c',
-        'src/lib/ares_writev.h',
-        'src/lib/bitncmp.c',
-        'src/lib/bitncmp.h',
-        'src/lib/inet_net_pton.c',
-        'src/lib/inet_ntop.c',
-        'src/lib/ares_inet_net_pton.h',
-        'src/lib/setup_once.h',
-        'src/tools/ares_getopt.c',
-        'src/tools/ares_getopt.h',
+        '<@(cares_sources_common)',
       ],
       'conditions': [
         [ 'library=="static_library"', {
@@ -127,11 +140,7 @@
           ],
           'include_dirs': [ 'config/win32' ],
           'sources': [
-            'src/lib/config-win32.h',
-            'src/lib/windows_port.c',
-            'src/lib/ares_getenv.c',
-            'src/lib/ares_iphlpapi.h',
-            'src/lib/ares_platform.c'
+            '<@(cares_sources_win)',
           ],
           'libraries': [
             '-lws2_32.lib',
diff --git a/deps/googletest/googletest.gyp b/deps/googletest/googletest.gyp
index 0b4ef28d582aa7..cf21a665f7ceb4 100644
--- a/deps/googletest/googletest.gyp
+++ b/deps/googletest/googletest.gyp
@@ -1,45 +1,46 @@
 {
+  'variables': {
+    'googletest_sources': [
+      'include/gtest/gtest-assertion-result.h',
+      'include/gtest/gtest-death-test.h',
+      'include/gtest/gtest-matchers.h',
+      'include/gtest/gtest-message.h',
+      'include/gtest/gtest-param-test.h',
+      'include/gtest/gtest-printers.h',
+      'include/gtest/gtest-spi.h',
+      'include/gtest/gtest-test-part.h',
+      'include/gtest/gtest-typed-test.h',
+      'include/gtest/gtest.h',
+      'include/gtest/gtest_pred_impl.h',
+      'include/gtest/internal/custom/gtest-port.h',
+      'include/gtest/internal/custom/gtest-printers.h',
+      'include/gtest/internal/custom/gtest.h',
+      'include/gtest/internal/gtest-death-test-internal.h',
+      'include/gtest/internal/gtest-filepath.h',
+      'include/gtest/internal/gtest-internal.h',
+      'include/gtest/internal/gtest-param-util.h',
+      'include/gtest/internal/gtest-port-arch.h',
+      'include/gtest/internal/gtest-port.h',
+      'include/gtest/internal/gtest-string.h',
+      'include/gtest/internal/gtest-type-util.h',
+      'src/gtest-assertion-result.cc',
+      'src/gtest-death-test.cc',
+      'src/gtest-filepath.cc',
+      'src/gtest-internal-inl.h',
+      'src/gtest-matchers.cc',
+      'src/gtest-port.cc',
+      'src/gtest-printers.cc',
+      'src/gtest-test-part.cc',
+      'src/gtest-typed-test.cc',
+      'src/gtest.cc',
+    ]
+  },
   'targets': [
     {
       'target_name': 'gtest',
       'type': 'static_library',
       'sources': [
-        'include/gtest/gtest-assertion-result.h',
-        'include/gtest/gtest-death-test.h',
-        'include/gtest/gtest-matchers.h',
-        'include/gtest/gtest-message.h',
-        'include/gtest/gtest-param-test.h',
-        'include/gtest/gtest-printers.h',
-        'include/gtest/gtest-spi.h',
-        'include/gtest/gtest-test-part.h',
-        'include/gtest/gtest-typed-test.h',
-        'include/gtest/gtest.h',
-        'include/gtest/gtest_pred_impl.h',
-        'include/gtest/internal/custom/gtest-port.h',
-        'include/gtest/internal/custom/gtest-printers.h',
-        'include/gtest/internal/custom/gtest.h',
-        'include/gtest/internal/gtest-death-test-internal.h',
-        'include/gtest/internal/gtest-filepath.h',
-        'include/gtest/internal/gtest-internal.h',
-        'include/gtest/internal/gtest-param-util.h',
-        'include/gtest/internal/gtest-port-arch.h',
-        'include/gtest/internal/gtest-port.h',
-        'include/gtest/internal/gtest-string.h',
-        'include/gtest/internal/gtest-type-util.h',
-        'src/gtest-all.cc',
-        'src/gtest-assertion-result.cc',
-        'src/gtest-death-test.cc',
-        'src/gtest-filepath.cc',
-        'src/gtest-internal-inl.h',
-        'src/gtest-matchers.cc',
-        'src/gtest-port.cc',
-        'src/gtest-printers.cc',
-        'src/gtest-test-part.cc',
-        'src/gtest-typed-test.cc',
-        'src/gtest.cc',
-      ],
-      'sources!': [
-        'src/gtest-all.cc',  # Not needed by our build.
+        '<@(googletest_sources)',
       ],
       'include_dirs': [
         '.', # src
diff --git a/deps/histogram/histogram.gyp b/deps/histogram/histogram.gyp
index e3f5fd7a46bb72..54999412ad99d7 100644
--- a/deps/histogram/histogram.gyp
+++ b/deps/histogram/histogram.gyp
@@ -1,4 +1,9 @@
 {
+  'variables': {
+    'histogram_sources': [
+      'src/hdr_histogram.c',
+    ]
+  },
   'targets': [
     {
       'target_name': 'histogram',
@@ -12,7 +17,7 @@
         'include_dirs': [ 'src' ]
       },
       'sources': [
-        'src/hdr_histogram.c',
+        '<@(histogram_sources)',
       ]
     }
   ]
diff --git a/deps/llhttp/llhttp.gyp b/deps/llhttp/llhttp.gyp
index 4acc79bdf399fc..c7b8800a4f18c4 100644
--- a/deps/llhttp/llhttp.gyp
+++ b/deps/llhttp/llhttp.gyp
@@ -1,4 +1,11 @@
 {
+  'variables': {
+    'llhttp_sources': [
+      'src/llhttp.c',
+      'src/api.c',
+      'src/http.c',
+    ]
+  },
   'targets': [
     {
       'target_name': 'llhttp',
@@ -7,7 +14,9 @@
       'direct_dependent_settings': {
         'include_dirs': [ 'include' ],
       },
-      'sources': [ 'src/llhttp.c', 'src/api.c', 'src/http.c' ],
+      'sources': [
+        '<@(llhttp_sources)',
+      ],
     },
   ]
 }
diff --git a/deps/nghttp2/nghttp2.gyp b/deps/nghttp2/nghttp2.gyp
index c4a18650efe789..4e48a707cc2197 100644
--- a/deps/nghttp2/nghttp2.gyp
+++ b/deps/nghttp2/nghttp2.gyp
@@ -1,4 +1,31 @@
 {
+  'variables': {
+    'nghttp2_sources': [
+      'lib/nghttp2_buf.c',
+      'lib/nghttp2_callbacks.c',
+      'lib/nghttp2_debug.c',
+      'lib/nghttp2_extpri.c',
+      'lib/nghttp2_frame.c',
+      'lib/nghttp2_hd.c',
+      'lib/nghttp2_hd_huffman.c',
+      'lib/nghttp2_hd_huffman_data.c',
+      'lib/nghttp2_helper.c',
+      'lib/nghttp2_http.c',
+      'lib/nghttp2_map.c',
+      'lib/nghttp2_mem.c',
+      'lib/nghttp2_npn.c',
+      'lib/nghttp2_option.c',
+      'lib/nghttp2_outbound_item.c',
+      'lib/nghttp2_pq.c',
+      'lib/nghttp2_priority_spec.c',
+      'lib/nghttp2_queue.c',
+      'lib/nghttp2_rcbuf.c',
+      'lib/nghttp2_session.c',
+      'lib/nghttp2_stream.c',
+      'lib/nghttp2_submit.c',
+      'lib/nghttp2_version.c',
+    ]
+  },
   'target_defaults': {
     'defines': [
       '_U_='
@@ -35,29 +62,7 @@
         'include_dirs': [ 'lib/includes' ]
       },
       'sources': [
-        'lib/nghttp2_buf.c',
-        'lib/nghttp2_callbacks.c',
-        'lib/nghttp2_debug.c',
-        'lib/nghttp2_extpri.c',
-        'lib/nghttp2_frame.c',
-        'lib/nghttp2_hd.c',
-        'lib/nghttp2_hd_huffman.c',
-        'lib/nghttp2_hd_huffman_data.c',
-        'lib/nghttp2_helper.c',
-        'lib/nghttp2_http.c',
-        'lib/nghttp2_map.c',
-        'lib/nghttp2_mem.c',
-        'lib/nghttp2_npn.c',
-        'lib/nghttp2_option.c',
-        'lib/nghttp2_outbound_item.c',
-        'lib/nghttp2_pq.c',
-        'lib/nghttp2_priority_spec.c',
-        'lib/nghttp2_queue.c',
-        'lib/nghttp2_rcbuf.c',
-        'lib/nghttp2_session.c',
-        'lib/nghttp2_stream.c',
-        'lib/nghttp2_submit.c',
-        'lib/nghttp2_version.c'
+        '<@(nghttp2_sources)',
       ]
     }
   ]
diff --git a/deps/simdutf/simdutf.gyp b/deps/simdutf/simdutf.gyp
index baa6ad7e437956..a86e92eb608d7e 100644
--- a/deps/simdutf/simdutf.gyp
+++ b/deps/simdutf/simdutf.gyp
@@ -1,4 +1,9 @@
 {
+  'variables': {
+    'simdutf_sources': [
+      'simdutf.cpp',
+    ]
+  },
   'targets': [
     {
       'target_name': 'simdutf',
@@ -7,7 +12,9 @@
       'direct_dependent_settings': {
         'include_dirs': ['.'],
       },
-      'sources': ['simdutf.cpp'],
+      'sources': [
+        '<@(simdutf_sources)',
+      ],
     },
   ]
 }
diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp
index c1adbc1b714d68..ad13f89dfa5bde 100644
--- a/deps/uv/uv.gyp
+++ b/deps/uv/uv.gyp
@@ -34,6 +34,129 @@
         'shared_zos_defines': [ ],
       }],
     ],
+    'uv_sources_common': [
+      'include/uv.h',
+      'include/uv/tree.h',
+      'include/uv/errno.h',
+      'include/uv/threadpool.h',
+      'include/uv/version.h',
+      'src/fs-poll.c',
+      'src/heap-inl.h',
+      'src/idna.c',
+      'src/idna.h',
+      'src/inet.c',
+      'src/queue.h',
+      'src/random.c',
+      'src/strscpy.c',
+      'src/strscpy.h',
+      'src/strtok.c',
+      'src/strtok.h',
+      'src/threadpool.c',
+      'src/timer.c',
+      'src/uv-data-getter-setters.c',
+      'src/uv-common.c',
+      'src/uv-common.h',
+      'src/version.c',
+    ],
+    'uv_sources_win': [
+      'include/uv/win.h',
+      'src/win/async.c',
+      'src/win/atomicops-inl.h',
+      'src/win/core.c',
+      'src/win/detect-wakeup.c',
+      'src/win/dl.c',
+      'src/win/error.c',
+      'src/win/fs.c',
+      'src/win/fs-event.c',
+      'src/win/getaddrinfo.c',
+      'src/win/getnameinfo.c',
+      'src/win/handle.c',
+      'src/win/handle-inl.h',
+      'src/win/internal.h',
+      'src/win/loop-watcher.c',
+      'src/win/pipe.c',
+      'src/win/thread.c',
+      'src/win/poll.c',
+      'src/win/process.c',
+      'src/win/process-stdio.c',
+      'src/win/req-inl.h',
+      'src/win/signal.c',
+      'src/win/snprintf.c',
+      'src/win/stream.c',
+      'src/win/stream-inl.h',
+      'src/win/tcp.c',
+      'src/win/tty.c',
+      'src/win/udp.c',
+      'src/win/util.c',
+      'src/win/winapi.c',
+      'src/win/winapi.h',
+      'src/win/winsock.c',
+      'src/win/winsock.h',
+    ],
+    'uv_sources_posix': [
+      'include/uv/unix.h',
+      'include/uv/linux.h',
+      'include/uv/sunos.h',
+      'include/uv/darwin.h',
+      'include/uv/bsd.h',
+      'include/uv/aix.h',
+      'src/unix/async.c',
+      'src/unix/atomic-ops.h',
+      'src/unix/core.c',
+      'src/unix/dl.c',
+      'src/unix/fs.c',
+      'src/unix/getaddrinfo.c',
+      'src/unix/getnameinfo.c',
+      'src/unix/internal.h',
+      'src/unix/loop.c',
+      'src/unix/loop-watcher.c',
+      'src/unix/pipe.c',
+      'src/unix/poll.c',
+      'src/unix/process.c',
+      'src/unix/random-devurandom.c',
+      'src/unix/signal.c',
+      'src/unix/spinlock.h',
+      'src/unix/stream.c',
+      'src/unix/tcp.c',
+      'src/unix/thread.c',
+      'src/unix/tty.c',
+      'src/unix/udp.c',
+    ],
+    'uv_sources_apple': [
+      'src/unix/darwin.c',
+      'src/unix/fsevents.c',
+      'src/unix/darwin-proctitle.c',
+      'src/unix/random-getentropy.c',
+    ],
+    'uv_sources_linux': [
+      'src/unix/epoll.c',
+      'src/unix/linux-core.c',
+      'src/unix/linux-inotify.c',
+      'src/unix/linux-syscalls.c',
+      'src/unix/linux-syscalls.h',
+      'src/unix/procfs-exepath.c',
+      'src/unix/random-getrandom.c',
+      'src/unix/random-sysctl-linux.c',
+    ],
+    'uv_sources_android': [
+      'src/unix/linux-core.c',
+      'src/unix/linux-inotify.c',
+      'src/unix/linux-syscalls.c',
+      'src/unix/procfs-exepath.c',
+      'src/unix/pthread-fixes.c',
+      'src/unix/random-getentropy.c',
+      'src/unix/random-getrandom.c',
+      'src/unix/random-sysctl-linux.c',
+      'src/unix/epoll.c',
+    ],
+    'uv_sources_solaris': [
+      'src/unix/no-proctitle.c',
+      'src/unix/sunos.c',
+    ],
+    'uv_sources_bsd_common': [
+      'src/unix/bsd-ifaddrs.c',
+      'src/unix/kqueue.c',
+    ],
   },
 
   'targets': [
@@ -64,28 +187,7 @@
       },
       'sources': [
         'common.gypi',
-        'include/uv.h',
-        'include/uv/tree.h',
-        'include/uv/errno.h',
-        'include/uv/threadpool.h',
-        'include/uv/version.h',
-        'src/fs-poll.c',
-        'src/heap-inl.h',
-        'src/idna.c',
-        'src/idna.h',
-        'src/inet.c',
-        'src/queue.h',
-        'src/random.c',
-        'src/strscpy.c',
-        'src/strscpy.h',
-        'src/strtok.c',
-        'src/strtok.h',
-        'src/threadpool.c',
-        'src/timer.c',
-        'src/uv-data-getter-setters.c',
-        'src/uv-common.c',
-        'src/uv-common.h',
-        'src/version.c'
+        '<@(uv_sources_common)',
       ],
       'xcode_settings': {
         'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',  # -fvisibility=hidden
@@ -104,39 +206,7 @@
             '_GNU_SOURCE',
           ],
           'sources': [
-            'include/uv/win.h',
-            'src/win/async.c',
-            'src/win/atomicops-inl.h',
-            'src/win/core.c',
-            'src/win/detect-wakeup.c',
-            'src/win/dl.c',
-            'src/win/error.c',
-            'src/win/fs.c',
-            'src/win/fs-event.c',
-            'src/win/getaddrinfo.c',
-            'src/win/getnameinfo.c',
-            'src/win/handle.c',
-            'src/win/handle-inl.h',
-            'src/win/internal.h',
-            'src/win/loop-watcher.c',
-            'src/win/pipe.c',
-            'src/win/thread.c',
-            'src/win/poll.c',
-            'src/win/process.c',
-            'src/win/process-stdio.c',
-            'src/win/req-inl.h',
-            'src/win/signal.c',
-            'src/win/snprintf.c',
-            'src/win/stream.c',
-            'src/win/stream-inl.h',
-            'src/win/tcp.c',
-            'src/win/tty.c',
-            'src/win/udp.c',
-            'src/win/util.c',
-            'src/win/winapi.c',
-            'src/win/winapi.h',
-            'src/win/winsock.c',
-            'src/win/winsock.h',
+            '<@(uv_sources_win)',
           ],
           'link_settings': {
             'libraries': [
@@ -151,33 +221,7 @@
           },
         }, { # Not Windows i.e. POSIX
           'sources': [
-            'include/uv/unix.h',
-            'include/uv/linux.h',
-            'include/uv/sunos.h',
-            'include/uv/darwin.h',
-            'include/uv/bsd.h',
-            'include/uv/aix.h',
-            'src/unix/async.c',
-            'src/unix/atomic-ops.h',
-            'src/unix/core.c',
-            'src/unix/dl.c',
-            'src/unix/fs.c',
-            'src/unix/getaddrinfo.c',
-            'src/unix/getnameinfo.c',
-            'src/unix/internal.h',
-            'src/unix/loop.c',
-            'src/unix/loop-watcher.c',
-            'src/unix/pipe.c',
-            'src/unix/poll.c',
-            'src/unix/process.c',
-            'src/unix/random-devurandom.c',
-            'src/unix/signal.c',
-            'src/unix/spinlock.h',
-            'src/unix/stream.c',
-            'src/unix/tcp.c',
-            'src/unix/thread.c',
-            'src/unix/tty.c',
-            'src/unix/udp.c',
+            '<@(uv_sources_posix)',
           ],
           'link_settings': {
             'libraries': [ '-lm' ],
@@ -228,10 +272,7 @@
         }],
         [ 'OS in "mac ios"', {
           'sources': [
-            'src/unix/darwin.c',
-            'src/unix/fsevents.c',
-            'src/unix/darwin-proctitle.c',
-            'src/unix/random-getentropy.c',
+            '<@(uv_sources_apple)',
           ],
           'defines': [
             '_DARWIN_USE_64_BIT_INODE=1',
@@ -241,14 +282,7 @@
         [ 'OS=="linux"', {
           'defines': [ '_GNU_SOURCE' ],
           'sources': [
-            'src/unix/epoll.c',
-            'src/unix/linux-core.c',
-            'src/unix/linux-inotify.c',
-            'src/unix/linux-syscalls.c',
-            'src/unix/linux-syscalls.h',
-            'src/unix/procfs-exepath.c',
-            'src/unix/random-getrandom.c',
-            'src/unix/random-sysctl-linux.c',
+            '<@(uv_sources_linux)',
           ],
           'link_settings': {
             'libraries': [ '-ldl', '-lrt' ],
@@ -259,15 +293,7 @@
             '_GNU_SOURCE',
           ],
           'sources': [
-            'src/unix/linux-core.c',
-            'src/unix/linux-inotify.c',
-            'src/unix/linux-syscalls.c',
-            'src/unix/procfs-exepath.c',
-            'src/unix/pthread-fixes.c',
-            'src/unix/random-getentropy.c',
-            'src/unix/random-getrandom.c',
-            'src/unix/random-sysctl-linux.c',
-            'src/unix/epoll.c',
+            '<@(uv_sources_android)',
           ],
           'link_settings': {
             'libraries': [ '-ldl' ],
@@ -275,8 +301,7 @@
         }],
         [ 'OS=="solaris"', {
           'sources': [
-            'src/unix/no-proctitle.c',
-            'src/unix/sunos.c',
+            '<@(uv_sources_solaris)',
           ],
           'defines': [
             '__EXTENSIONS__',
@@ -369,8 +394,7 @@
         }],
         [ 'OS in "ios mac freebsd dragonflybsd openbsd netbsd".split()', {
           'sources': [
-            'src/unix/bsd-ifaddrs.c',
-            'src/unix/kqueue.c',
+            '<@(uv_sources_bsd_common)',
           ],
         }],
         ['uv_library=="shared_library"', {
diff --git a/deps/uvwasi/uvwasi.gyp b/deps/uvwasi/uvwasi.gyp
index 5822f8d59bd9e9..229dc9f41f8de8 100644
--- a/deps/uvwasi/uvwasi.gyp
+++ b/deps/uvwasi/uvwasi.gyp
@@ -1,4 +1,16 @@
 {
+  'variables': {
+    'uvwasi_sources': [
+      'src/clocks.c',
+      'src/fd_table.c',
+      'src/path_resolver.c',
+      'src/poll_oneoff.c',
+      'src/uv_mapping.c',
+      'src/uvwasi.c',
+      'src/wasi_rights.c',
+      'src/wasi_serdes.c',
+    ]
+  },
   'targets': [
     {
       'target_name': 'uvwasi',
@@ -9,14 +21,7 @@
       },
       'include_dirs': ['include'],
       'sources': [
-        'src/clocks.c',
-        'src/fd_table.c',
-        'src/path_resolver.c',
-        'src/poll_oneoff.c',
-        'src/uv_mapping.c',
-        'src/uvwasi.c',
-        'src/wasi_rights.c',
-        'src/wasi_serdes.c',
+        '<@(uvwasi_sources)',
       ],
       'direct_dependent_settings': {
         'include_dirs': ['include']
diff --git a/node.gyp b/node.gyp
index 72d90ec5f4ad14..cad1061d878b59 100644
--- a/node.gyp
+++ b/node.gyp
@@ -51,6 +51,290 @@
       'deps/acorn/acorn-walk/dist/walk.js',
       '<@(node_builtin_shareable_builtins)',
     ],
+    'node_sources': [
+      'src/api/async_resource.cc',
+      'src/api/callback.cc',
+      'src/api/embed_helpers.cc',
+      'src/api/encoding.cc',
+      'src/api/environment.cc',
+      'src/api/exceptions.cc',
+      'src/api/hooks.cc',
+      'src/api/utils.cc',
+      'src/async_wrap.cc',
+      'src/base_object.cc',
+      'src/cares_wrap.cc',
+      'src/cleanup_queue.cc',
+      'src/connect_wrap.cc',
+      'src/connection_wrap.cc',
+      'src/dataqueue/queue.cc',
+      'src/debug_utils.cc',
+      'src/encoding_binding.cc',
+      'src/env.cc',
+      'src/fs_event_wrap.cc',
+      'src/handle_wrap.cc',
+      'src/heap_utils.cc',
+      'src/histogram.cc',
+      'src/js_native_api.h',
+      'src/js_native_api_types.h',
+      'src/js_native_api_v8.cc',
+      'src/js_native_api_v8.h',
+      'src/js_native_api_v8_internals.h',
+      'src/js_stream.cc',
+      'src/json_utils.cc',
+      'src/js_udp_wrap.cc',
+      'src/module_wrap.cc',
+      'src/node.cc',
+      'src/node_api.cc',
+      'src/node_binding.cc',
+      'src/node_blob.cc',
+      'src/node_buffer.cc',
+      'src/node_builtins.cc',
+      'src/node_config.cc',
+      'src/node_constants.cc',
+      'src/node_contextify.cc',
+      'src/node_credentials.cc',
+      'src/node_dir.cc',
+      'src/node_env_var.cc',
+      'src/node_errors.cc',
+      'src/node_external_reference.cc',
+      'src/node_file.cc',
+      'src/node_http_parser.cc',
+      'src/node_http2.cc',
+      'src/node_i18n.cc',
+      'src/node_main_instance.cc',
+      'src/node_messaging.cc',
+      'src/node_metadata.cc',
+      'src/node_options.cc',
+      'src/node_os.cc',
+      'src/node_perf.cc',
+      'src/node_platform.cc',
+      'src/node_postmortem_metadata.cc',
+      'src/node_process_events.cc',
+      'src/node_process_methods.cc',
+      'src/node_process_object.cc',
+      'src/node_realm.cc',
+      'src/node_report.cc',
+      'src/node_report_module.cc',
+      'src/node_report_utils.cc',
+      'src/node_sea.cc',
+      'src/node_serdes.cc',
+      'src/node_shadow_realm.cc',
+      'src/node_snapshotable.cc',
+      'src/node_sockaddr.cc',
+      'src/node_stat_watcher.cc',
+      'src/node_symbols.cc',
+      'src/node_task_queue.cc',
+      'src/node_trace_events.cc',
+      'src/node_types.cc',
+      'src/node_url.cc',
+      'src/node_util.cc',
+      'src/node_v8.cc',
+      'src/node_wasi.cc',
+      'src/node_wasm_web_api.cc',
+      'src/node_watchdog.cc',
+      'src/node_worker.cc',
+      'src/node_zlib.cc',
+      'src/permission/child_process_permission.cc',
+      'src/permission/fs_permission.cc',
+      'src/permission/permission.cc',
+      'src/permission/worker_permission.cc',
+      'src/pipe_wrap.cc',
+      'src/process_wrap.cc',
+      'src/signal_wrap.cc',
+      'src/spawn_sync.cc',
+      'src/stream_base.cc',
+      'src/stream_pipe.cc',
+      'src/stream_wrap.cc',
+      'src/string_bytes.cc',
+      'src/string_decoder.cc',
+      'src/tcp_wrap.cc',
+      'src/timers.cc',
+      'src/timer_wrap.cc',
+      'src/tracing/agent.cc',
+      'src/tracing/node_trace_buffer.cc',
+      'src/tracing/node_trace_writer.cc',
+      'src/tracing/trace_event.cc',
+      'src/tracing/traced_value.cc',
+      'src/tty_wrap.cc',
+      'src/udp_wrap.cc',
+      'src/util.cc',
+      'src/uv.cc',
+      # headers to make for a more pleasant IDE experience
+      'src/aliased_buffer.h',
+      'src/aliased_buffer-inl.h',
+      'src/aliased_struct.h',
+      'src/aliased_struct-inl.h',
+      'src/async_wrap.h',
+      'src/async_wrap-inl.h',
+      'src/base_object.h',
+      'src/base_object-inl.h',
+      'src/base_object_types.h',
+      'src/base64.h',
+      'src/base64-inl.h',
+      'src/callback_queue.h',
+      'src/callback_queue-inl.h',
+      'src/cleanup_queue.h',
+      'src/cleanup_queue-inl.h',
+      'src/connect_wrap.h',
+      'src/connection_wrap.h',
+      'src/dataqueue/queue.h',
+      'src/debug_utils.h',
+      'src/debug_utils-inl.h',
+      'src/encoding_binding.h',
+      'src/env_properties.h',
+      'src/env.h',
+      'src/env-inl.h',
+      'src/handle_wrap.h',
+      'src/histogram.h',
+      'src/histogram-inl.h',
+      'src/js_stream.h',
+      'src/json_utils.h',
+      'src/large_pages/node_large_page.cc',
+      'src/large_pages/node_large_page.h',
+      'src/memory_tracker.h',
+      'src/memory_tracker-inl.h',
+      'src/module_wrap.h',
+      'src/node.h',
+      'src/node_api.h',
+      'src/node_api_types.h',
+      'src/node_binding.h',
+      'src/node_blob.h',
+      'src/node_buffer.h',
+      'src/node_builtins.h',
+      'src/node_constants.h',
+      'src/node_context_data.h',
+      'src/node_contextify.h',
+      'src/node_dir.h',
+      'src/node_errors.h',
+      'src/node_exit_code.h',
+      'src/node_external_reference.h',
+      'src/node_file.h',
+      'src/node_file-inl.h',
+      'src/node_http_common.h',
+      'src/node_http_common-inl.h',
+      'src/node_http2.h',
+      'src/node_http2_state.h',
+      'src/node_i18n.h',
+      'src/node_internals.h',
+      'src/node_main_instance.h',
+      'src/node_mem.h',
+      'src/node_mem-inl.h',
+      'src/node_messaging.h',
+      'src/node_metadata.h',
+      'src/node_mutex.h',
+      'src/node_object_wrap.h',
+      'src/node_options.h',
+      'src/node_options-inl.h',
+      'src/node_perf.h',
+      'src/node_perf_common.h',
+      'src/node_platform.h',
+      'src/node_process.h',
+      'src/node_process-inl.h',
+      'src/node_realm.h',
+      'src/node_realm-inl.h',
+      'src/node_report.h',
+      'src/node_revert.h',
+      'src/node_root_certs.h',
+      'src/node_sea.h',
+      'src/node_shadow_realm.h',
+      'src/node_snapshotable.h',
+      'src/node_snapshot_builder.h',
+      'src/node_sockaddr.h',
+      'src/node_sockaddr-inl.h',
+      'src/node_stat_watcher.h',
+      'src/node_union_bytes.h',
+      'src/node_url.h',
+      'src/node_util.h',
+      'src/node_version.h',
+      'src/node_v8.h',
+      'src/node_v8_platform-inl.h',
+      'src/node_wasi.h',
+      'src/node_watchdog.h',
+      'src/node_worker.h',
+      'src/permission/child_process_permission.h',
+      'src/permission/fs_permission.h',
+      'src/permission/permission.h',
+      'src/permission/permission_node.h',
+      'src/permission/worker_permission.h',
+      'src/pipe_wrap.h',
+      'src/req_wrap.h',
+      'src/req_wrap-inl.h',
+      'src/spawn_sync.h',
+      'src/stream_base.h',
+      'src/stream_base-inl.h',
+      'src/stream_pipe.h',
+      'src/stream_wrap.h',
+      'src/string_bytes.h',
+      'src/string_decoder.h',
+      'src/string_decoder-inl.h',
+      'src/string_search.h',
+      'src/tcp_wrap.h',
+      'src/timers.h',
+      'src/tracing/agent.h',
+      'src/tracing/node_trace_buffer.h',
+      'src/tracing/node_trace_writer.h',
+      'src/tracing/trace_event.h',
+      'src/tracing/trace_event_common.h',
+      'src/tracing/traced_value.h',
+      'src/timer_wrap.h',
+      'src/timer_wrap-inl.h',
+      'src/tty_wrap.h',
+      'src/udp_wrap.h',
+      'src/util.h',
+      'src/util-inl.h',
+    ],
+    'node_crypto_sources': [
+      'src/crypto/crypto_aes.cc',
+      'src/crypto/crypto_bio.cc',
+      'src/crypto/crypto_common.cc',
+      'src/crypto/crypto_dsa.cc',
+      'src/crypto/crypto_hkdf.cc',
+      'src/crypto/crypto_pbkdf2.cc',
+      'src/crypto/crypto_sig.cc',
+      'src/crypto/crypto_timing.cc',
+      'src/crypto/crypto_cipher.cc',
+      'src/crypto/crypto_context.cc',
+      'src/crypto/crypto_ec.cc',
+      'src/crypto/crypto_hmac.cc',
+      'src/crypto/crypto_random.cc',
+      'src/crypto/crypto_rsa.cc',
+      'src/crypto/crypto_spkac.cc',
+      'src/crypto/crypto_util.cc',
+      'src/crypto/crypto_clienthello.cc',
+      'src/crypto/crypto_dh.cc',
+      'src/crypto/crypto_hash.cc',
+      'src/crypto/crypto_keys.cc',
+      'src/crypto/crypto_keygen.cc',
+      'src/crypto/crypto_scrypt.cc',
+      'src/crypto/crypto_tls.cc',
+      'src/crypto/crypto_x509.cc',
+      'src/crypto/crypto_bio.h',
+      'src/crypto/crypto_clienthello-inl.h',
+      'src/crypto/crypto_dh.h',
+      'src/crypto/crypto_hmac.h',
+      'src/crypto/crypto_rsa.h',
+      'src/crypto/crypto_spkac.h',
+      'src/crypto/crypto_util.h',
+      'src/crypto/crypto_cipher.h',
+      'src/crypto/crypto_common.h',
+      'src/crypto/crypto_dsa.h',
+      'src/crypto/crypto_hash.h',
+      'src/crypto/crypto_keys.h',
+      'src/crypto/crypto_keygen.h',
+      'src/crypto/crypto_scrypt.h',
+      'src/crypto/crypto_tls.h',
+      'src/crypto/crypto_clienthello.h',
+      'src/crypto/crypto_context.h',
+      'src/crypto/crypto_ec.h',
+      'src/crypto/crypto_hkdf.h',
+      'src/crypto/crypto_pbkdf2.h',
+      'src/crypto/crypto_sig.h',
+      'src/crypto/crypto_random.h',
+      'src/crypto/crypto_timing.h',
+      'src/crypto/crypto_x509.h',
+      'src/node_crypto.cc',
+      'src/node_crypto.h',
+    ],
     'node_mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_mksnapshot<(EXECUTABLE_SUFFIX)',
     'conditions': [
       ['GENERATOR == "ninja"', {
@@ -463,236 +747,7 @@
       ],
 
       'sources': [
-        'src/api/async_resource.cc',
-        'src/api/callback.cc',
-        'src/api/embed_helpers.cc',
-        'src/api/encoding.cc',
-        'src/api/environment.cc',
-        'src/api/exceptions.cc',
-        'src/api/hooks.cc',
-        'src/api/utils.cc',
-        'src/async_wrap.cc',
-        'src/base_object.cc',
-        'src/cares_wrap.cc',
-        'src/cleanup_queue.cc',
-        'src/connect_wrap.cc',
-        'src/connection_wrap.cc',
-        'src/dataqueue/queue.cc',
-        'src/debug_utils.cc',
-        'src/encoding_binding.cc',
-        'src/env.cc',
-        'src/fs_event_wrap.cc',
-        'src/handle_wrap.cc',
-        'src/heap_utils.cc',
-        'src/histogram.cc',
-        'src/js_native_api.h',
-        'src/js_native_api_types.h',
-        'src/js_native_api_v8.cc',
-        'src/js_native_api_v8.h',
-        'src/js_native_api_v8_internals.h',
-        'src/js_stream.cc',
-        'src/json_utils.cc',
-        'src/js_udp_wrap.cc',
-        'src/module_wrap.cc',
-        'src/node.cc',
-        'src/node_api.cc',
-        'src/node_binding.cc',
-        'src/node_blob.cc',
-        'src/node_buffer.cc',
-        'src/node_builtins.cc',
-        'src/node_config.cc',
-        'src/node_constants.cc',
-        'src/node_contextify.cc',
-        'src/node_credentials.cc',
-        'src/node_dir.cc',
-        'src/node_env_var.cc',
-        'src/node_errors.cc',
-        'src/node_external_reference.cc',
-        'src/node_file.cc',
-        'src/node_http_parser.cc',
-        'src/node_http2.cc',
-        'src/node_i18n.cc',
-        'src/node_main_instance.cc',
-        'src/node_messaging.cc',
-        'src/node_metadata.cc',
-        'src/node_options.cc',
-        'src/node_os.cc',
-        'src/node_perf.cc',
-        'src/node_platform.cc',
-        'src/node_postmortem_metadata.cc',
-        'src/node_process_events.cc',
-        'src/node_process_methods.cc',
-        'src/node_process_object.cc',
-        'src/node_realm.cc',
-        'src/node_report.cc',
-        'src/node_report_module.cc',
-        'src/node_report_utils.cc',
-        'src/node_sea.cc',
-        'src/node_serdes.cc',
-        'src/node_shadow_realm.cc',
-        'src/node_snapshotable.cc',
-        'src/node_sockaddr.cc',
-        'src/node_stat_watcher.cc',
-        'src/node_symbols.cc',
-        'src/node_task_queue.cc',
-        'src/node_trace_events.cc',
-        'src/node_types.cc',
-        'src/node_url.cc',
-        'src/node_util.cc',
-        'src/node_v8.cc',
-        'src/node_wasi.cc',
-        'src/node_wasm_web_api.cc',
-        'src/node_watchdog.cc',
-        'src/node_worker.cc',
-        'src/node_zlib.cc',
-        'src/permission/child_process_permission.cc',
-        'src/permission/fs_permission.cc',
-        'src/permission/permission.cc',
-        'src/permission/worker_permission.cc',
-        'src/pipe_wrap.cc',
-        'src/process_wrap.cc',
-        'src/signal_wrap.cc',
-        'src/spawn_sync.cc',
-        'src/stream_base.cc',
-        'src/stream_pipe.cc',
-        'src/stream_wrap.cc',
-        'src/string_bytes.cc',
-        'src/string_decoder.cc',
-        'src/tcp_wrap.cc',
-        'src/timers.cc',
-        'src/timer_wrap.cc',
-        'src/tracing/agent.cc',
-        'src/tracing/node_trace_buffer.cc',
-        'src/tracing/node_trace_writer.cc',
-        'src/tracing/trace_event.cc',
-        'src/tracing/traced_value.cc',
-        'src/tty_wrap.cc',
-        'src/udp_wrap.cc',
-        'src/util.cc',
-        'src/uv.cc',
-        # headers to make for a more pleasant IDE experience
-        'src/aliased_buffer.h',
-        'src/aliased_buffer-inl.h',
-        'src/aliased_struct.h',
-        'src/aliased_struct-inl.h',
-        'src/async_wrap.h',
-        'src/async_wrap-inl.h',
-        'src/base_object.h',
-        'src/base_object-inl.h',
-        'src/base_object_types.h',
-        'src/base64.h',
-        'src/base64-inl.h',
-        'src/callback_queue.h',
-        'src/callback_queue-inl.h',
-        'src/cleanup_queue.h',
-        'src/cleanup_queue-inl.h',
-        'src/connect_wrap.h',
-        'src/connection_wrap.h',
-        'src/dataqueue/queue.h',
-        'src/debug_utils.h',
-        'src/debug_utils-inl.h',
-        'src/encoding_binding.h',
-        'src/env_properties.h',
-        'src/env.h',
-        'src/env-inl.h',
-        'src/handle_wrap.h',
-        'src/histogram.h',
-        'src/histogram-inl.h',
-        'src/js_stream.h',
-        'src/json_utils.h',
-        'src/large_pages/node_large_page.cc',
-        'src/large_pages/node_large_page.h',
-        'src/memory_tracker.h',
-        'src/memory_tracker-inl.h',
-        'src/module_wrap.h',
-        'src/node.h',
-        'src/node_api.h',
-        'src/node_api_types.h',
-        'src/node_binding.h',
-        'src/node_blob.h',
-        'src/node_buffer.h',
-        'src/node_builtins.h',
-        'src/node_constants.h',
-        'src/node_context_data.h',
-        'src/node_contextify.h',
-        'src/node_dir.h',
-        'src/node_errors.h',
-        'src/node_exit_code.h',
-        'src/node_external_reference.h',
-        'src/node_file.h',
-        'src/node_file-inl.h',
-        'src/node_http_common.h',
-        'src/node_http_common-inl.h',
-        'src/node_http2.h',
-        'src/node_http2_state.h',
-        'src/node_i18n.h',
-        'src/node_internals.h',
-        'src/node_main_instance.h',
-        'src/node_mem.h',
-        'src/node_mem-inl.h',
-        'src/node_messaging.h',
-        'src/node_metadata.h',
-        'src/node_mutex.h',
-        'src/node_object_wrap.h',
-        'src/node_options.h',
-        'src/node_options-inl.h',
-        'src/node_perf.h',
-        'src/node_perf_common.h',
-        'src/node_platform.h',
-        'src/node_process.h',
-        'src/node_process-inl.h',
-        'src/node_realm.h',
-        'src/node_realm-inl.h',
-        'src/node_report.h',
-        'src/node_revert.h',
-        'src/node_root_certs.h',
-        'src/node_sea.h',
-        'src/node_shadow_realm.h',
-        'src/node_snapshotable.h',
-        'src/node_snapshot_builder.h',
-        'src/node_sockaddr.h',
-        'src/node_sockaddr-inl.h',
-        'src/node_stat_watcher.h',
-        'src/node_union_bytes.h',
-        'src/node_url.h',
-        'src/node_util.h',
-        'src/node_version.h',
-        'src/node_v8.h',
-        'src/node_v8_platform-inl.h',
-        'src/node_wasi.h',
-        'src/node_watchdog.h',
-        'src/node_worker.h',
-        'src/permission/child_process_permission.h',
-        'src/permission/fs_permission.h',
-        'src/permission/permission.h',
-        'src/permission/permission_node.h',
-        'src/permission/worker_permission.h',
-        'src/pipe_wrap.h',
-        'src/req_wrap.h',
-        'src/req_wrap-inl.h',
-        'src/spawn_sync.h',
-        'src/stream_base.h',
-        'src/stream_base-inl.h',
-        'src/stream_pipe.h',
-        'src/stream_wrap.h',
-        'src/string_bytes.h',
-        'src/string_decoder.h',
-        'src/string_decoder-inl.h',
-        'src/string_search.h',
-        'src/tcp_wrap.h',
-        'src/timers.h',
-        'src/tracing/agent.h',
-        'src/tracing/node_trace_buffer.h',
-        'src/tracing/node_trace_writer.h',
-        'src/tracing/trace_event.h',
-        'src/tracing/trace_event_common.h',
-        'src/tracing/traced_value.h',
-        'src/timer_wrap.h',
-        'src/timer_wrap-inl.h',
-        'src/tty_wrap.h',
-        'src/udp_wrap.h',
-        'src/util.h',
-        'src/util-inl.h',
+        '<@(node_sources)',
         # Dependency headers
         'deps/v8/include/v8.h',
         'deps/postject/postject-api.h',
@@ -780,57 +835,7 @@
         }],
         [ 'node_use_openssl=="true"', {
           'sources': [
-            'src/crypto/crypto_aes.cc',
-            'src/crypto/crypto_bio.cc',
-            'src/crypto/crypto_common.cc',
-            'src/crypto/crypto_dsa.cc',
-            'src/crypto/crypto_hkdf.cc',
-            'src/crypto/crypto_pbkdf2.cc',
-            'src/crypto/crypto_sig.cc',
-            'src/crypto/crypto_timing.cc',
-            'src/crypto/crypto_cipher.cc',
-            'src/crypto/crypto_context.cc',
-            'src/crypto/crypto_ec.cc',
-            'src/crypto/crypto_hmac.cc',
-            'src/crypto/crypto_random.cc',
-            'src/crypto/crypto_rsa.cc',
-            'src/crypto/crypto_spkac.cc',
-            'src/crypto/crypto_util.cc',
-            'src/crypto/crypto_clienthello.cc',
-            'src/crypto/crypto_dh.cc',
-            'src/crypto/crypto_hash.cc',
-            'src/crypto/crypto_keys.cc',
-            'src/crypto/crypto_keygen.cc',
-            'src/crypto/crypto_scrypt.cc',
-            'src/crypto/crypto_tls.cc',
-            'src/crypto/crypto_aes.cc',
-            'src/crypto/crypto_x509.cc',
-            'src/crypto/crypto_bio.h',
-            'src/crypto/crypto_clienthello-inl.h',
-            'src/crypto/crypto_dh.h',
-            'src/crypto/crypto_hmac.h',
-            'src/crypto/crypto_rsa.h',
-            'src/crypto/crypto_spkac.h',
-            'src/crypto/crypto_util.h',
-            'src/crypto/crypto_cipher.h',
-            'src/crypto/crypto_common.h',
-            'src/crypto/crypto_dsa.h',
-            'src/crypto/crypto_hash.h',
-            'src/crypto/crypto_keys.h',
-            'src/crypto/crypto_keygen.h',
-            'src/crypto/crypto_scrypt.h',
-            'src/crypto/crypto_tls.h',
-            'src/crypto/crypto_clienthello.h',
-            'src/crypto/crypto_context.h',
-            'src/crypto/crypto_ec.h',
-            'src/crypto/crypto_hkdf.h',
-            'src/crypto/crypto_pbkdf2.h',
-            'src/crypto/crypto_sig.h',
-            'src/crypto/crypto_random.h',
-            'src/crypto/crypto_timing.h',
-            'src/crypto/crypto_x509.h',
-            'src/node_crypto.cc',
-            'src/node_crypto.h'
+            '<@(node_crypto_sources)',
           ],
         }],
         [ 'OS in "linux freebsd mac solaris" and '
diff --git a/src/inspector/node_inspector.gypi b/src/inspector/node_inspector.gypi
index 89c315cfcb772f..ba24e6acfc0744 100644
--- a/src/inspector/node_inspector.gypi
+++ b/src/inspector/node_inspector.gypi
@@ -1,6 +1,31 @@
 {
   'variables': {
     'protocol_tool_path': '../../tools/inspector_protocol',
+    'node_inspector_sources': [
+      'src/inspector_agent.cc',
+      'src/inspector_io.cc',
+      'src/inspector_agent.h',
+      'src/inspector_io.h',
+      'src/inspector_profiler.h',
+      'src/inspector_profiler.cc',
+      'src/inspector_js_api.cc',
+      'src/inspector_socket.cc',
+      'src/inspector_socket.h',
+      'src/inspector_socket_server.cc',
+      'src/inspector_socket_server.h',
+      'src/inspector/main_thread_interface.cc',
+      'src/inspector/main_thread_interface.h',
+      'src/inspector/node_string.cc',
+      'src/inspector/node_string.h',
+      'src/inspector/runtime_agent.cc',
+      'src/inspector/runtime_agent.h',
+      'src/inspector/tracing_agent.cc',
+      'src/inspector/tracing_agent.h',
+      'src/inspector/worker_agent.cc',
+      'src/inspector/worker_agent.h',
+      'src/inspector/worker_inspector.cc',
+      'src/inspector/worker_inspector.h',
+    ],
     'node_inspector_generated_sources': [
       '<(SHARED_INTERMEDIATE_DIR)/src/node/inspector/protocol/Forward.h',
       '<(SHARED_INTERMEDIATE_DIR)/src/node/inspector/protocol/Protocol.cpp',
@@ -38,36 +63,13 @@
       '<(protocol_tool_path)/templates/Imported_h.template',
       '<(protocol_tool_path)/templates/TypeBuilder_cpp.template',
       '<(protocol_tool_path)/templates/TypeBuilder_h.template',
-      '<(protocol_tool_path)/code_generator.py',
     ]
   },
   'defines': [
     'HAVE_INSPECTOR=1',
   ],
   'sources': [
-    '../../src/inspector_agent.cc',
-    '../../src/inspector_io.cc',
-    '../../src/inspector_agent.h',
-    '../../src/inspector_io.h',
-    '../../src/inspector_profiler.h',
-    '../../src/inspector_profiler.cc',
-    '../../src/inspector_js_api.cc',
-    '../../src/inspector_socket.cc',
-    '../../src/inspector_socket.h',
-    '../../src/inspector_socket_server.cc',
-    '../../src/inspector_socket_server.h',
-    '../../src/inspector/main_thread_interface.cc',
-    '../../src/inspector/main_thread_interface.h',
-    '../../src/inspector/node_string.cc',
-    '../../src/inspector/node_string.h',
-    '../../src/inspector/runtime_agent.cc',
-    '../../src/inspector/runtime_agent.h',
-    '../../src/inspector/tracing_agent.cc',
-    '../../src/inspector/tracing_agent.h',
-    '../../src/inspector/worker_agent.cc',
-    '../../src/inspector/worker_agent.h',
-    '../../src/inspector/worker_inspector.cc',
-    '../../src/inspector/worker_inspector.h',
+    '<@(node_inspector_sources)',
   ],
   'include_dirs': [
     '<(SHARED_INTERMEDIATE_DIR)/include', # for inspector
@@ -96,6 +98,7 @@
         'node_protocol_config.json',
         '<(SHARED_INTERMEDIATE_DIR)/src/node_protocol.json',
         '<@(node_protocol_files)',
+        '<(protocol_tool_path)/code_generator.py',
       ],
       'outputs': [
         '<@(node_inspector_generated_sources)',