Skip to content

Commit

Permalink
build: fix generate_gn_filenames_json.py (#42427)
Browse files Browse the repository at this point in the history
build: fix generate_gn_filenames_json.py

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
  • Loading branch information
trop[bot] and codebytere committed Jun 11, 2024
1 parent f272c5f commit 2633298
Showing 1 changed file with 65 additions and 34 deletions.
99 changes: 65 additions & 34 deletions patches/node/build_add_gn_build_files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1256,10 +1256,10 @@ index 0000000000000000000000000000000000000000..af9cbada10203b387fb9732b346583b1
+}
diff --git a/filenames.json b/filenames.json
new file mode 100644
index 0000000000000000000000000000000000000000..1a9cba024f1762b0dfe31da92213b51e112101ec
index 0000000000000000000000000000000000000000..fd42e2a5e6163ff70db0f716d2f9a32f13cdf668
--- /dev/null
+++ b/filenames.json
@@ -0,0 +1,739 @@
@@ -0,0 +1,734 @@
+// This file is automatically generated by generate_gn_filenames_json.py
+// DO NOT EDIT
+{
Expand Down Expand Up @@ -1292,7 +1292,7 @@ index 0000000000000000000000000000000000000000..1a9cba024f1762b0dfe31da92213b51e
+ ]
+ },
+ {
+ "dest_dir": "include/node//",
+ "dest_dir": "include/node/./",
+ "files": [
+ "//v8/include/v8-array-buffer.h",
+ "//v8/include/v8-callbacks.h",
Expand Down Expand Up @@ -1346,19 +1346,20 @@ index 0000000000000000000000000000000000000000..1a9cba024f1762b0dfe31da92213b51e
+ "//v8/include/v8-wasm.h",
+ "//v8/include/v8-weak-callback-info.h",
+ "//v8/include/v8.h",
+ "//v8/include/v8config.h"
+ "//v8/include/v8config.h",
+ "deps/uv/include/uv.h"
+ ]
+ },
+ {
+ "dest_dir": "include/node//libplatform/",
+ "dest_dir": "include/node/libplatform/",
+ "files": [
+ "//v8/include/libplatform/libplatform-export.h",
+ "//v8/include/libplatform/libplatform.h",
+ "//v8/include/libplatform/v8-tracing.h"
+ ]
+ },
+ {
+ "dest_dir": "include/node//cppgc/",
+ "dest_dir": "include/node/cppgc/",
+ "files": [
+ "//v8/include/cppgc/allocation.h",
+ "//v8/include/cppgc/common.h",
Expand Down Expand Up @@ -1391,7 +1392,7 @@ index 0000000000000000000000000000000000000000..1a9cba024f1762b0dfe31da92213b51e
+ ]
+ },
+ {
+ "dest_dir": "include/node//cppgc/internal/",
+ "dest_dir": "include/node/cppgc/internal/",
+ "files": [
+ "//v8/include/cppgc/internal/api-constants.h",
+ "//v8/include/cppgc/internal/atomic-entry-flag.h",
Expand All @@ -1410,13 +1411,7 @@ index 0000000000000000000000000000000000000000..1a9cba024f1762b0dfe31da92213b51e
+ ]
+ },
+ {
+ "dest_dir": "include/node//",
+ "files": [
+ "deps/uv/include/uv.h"
+ ]
+ },
+ {
+ "dest_dir": "include/node//uv/",
+ "dest_dir": "include/node/uv/",
+ "files": [
+ "deps/uv/include/uv/aix.h",
+ "deps/uv/include/uv/bsd.h",
Expand Down Expand Up @@ -1891,7 +1886,7 @@ index 0000000000000000000000000000000000000000..1a9cba024f1762b0dfe31da92213b51e
+ "src/dataqueue/queue.h",
+ "src/debug_utils.h",
+ "src/debug_utils-inl.h",
+ "src/embeded_data.h",
+ "src/embedded_data.h",
+ "src/encoding_binding.h",
+ "src/env_properties.h",
+ "src/env.h",
Expand Down Expand Up @@ -2243,10 +2238,10 @@ index 75a7f3dd89e096d13ad7d70ed29d301cd56315b5..9a20a275fbe5df9f384b7b1d1d26806e
// bootstrap scripts, whose source are bundled into the binary as static data.
diff --git a/tools/generate_gn_filenames_json.py b/tools/generate_gn_filenames_json.py
new file mode 100755
index 0000000000000000000000000000000000000000..7848ddb1841b6d4f36e9376c73564eb4ff6d7c08
index 0000000000000000000000000000000000000000..37c16859003e61636fe2f1a4040b1e904c472d0b
--- /dev/null
+++ b/tools/generate_gn_filenames_json.py
@@ -0,0 +1,90 @@
@@ -0,0 +1,117 @@
+#!/usr/bin/env python3
+import json
+import os
Expand Down Expand Up @@ -2276,6 +2271,14 @@ index 0000000000000000000000000000000000000000..7848ddb1841b6d4f36e9376c73564eb4
+// DO NOT EDIT
+'''.lstrip()
+
+SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..'))
+
+def get_out_dir():
+ out_dir = 'Testing'
+ override = os.environ.get('ELECTRON_OUT_DIR')
+ if override is not None:
+ out_dir = override
+ return os.path.join(SRC_DIR, 'out', out_dir)
+
+if __name__ == '__main__':
+ node_root_dir = os.path.dirname(os.path.dirname(__file__))
Expand All @@ -2294,18 +2297,25 @@ index 0000000000000000000000000000000000000000..7848ddb1841b6d4f36e9376c73564eb4
+ }
+
+ def filter_v8_files(files):
+ if any(f.startswith('deps/v8/') for f in files):
+ files = [f.replace('deps/v8/', '../../v8/', 1) if f.endswith('js') else f.replace('deps/v8/', '//v8/') for f in files]
+
+ if any(f == '<@(node_builtin_shareable_builtins)' for f in files):
+ files.remove('<@(node_builtin_shareable_builtins)')
+ v8_files = [f for f in files if f.startswith('deps/v8/')]
+ other_files = [f for f in files if not f.startswith('deps/v8/')]
+
+ for i, f in enumerate(v8_files):
+ if not f.startswith('deps/v8/tools'):
+ if f.endswith('js'):
+ v8_files[i] = f.replace('deps/v8/', '../../v8/', 1)
+ else:
+ v8_files[i] = f.replace('deps/v8/', '//v8/')
+
+ if any(f == '<@(node_builtin_shareable_builtins)' for f in other_files):
+ other_files.remove('<@(node_builtin_shareable_builtins)')
+ shared_builtins = ['deps/cjs-module-lexer/lexer.js', 'deps/cjs-module-lexer/dist/lexer.js', 'deps/undici/undici.js']
+ files.extend(shared_builtins)
+ other_files.extend(shared_builtins)
+
+ return files
+ return v8_files + other_files
+
+ def filter_fs_files(files):
+ return [f for f in files if f.startswith('lib/internal/fs/')] + ['lib/fs.js']
+ return [f for f in files if f.startswith('lib/internal/fs/')] + ['lib/fs.js'] + ['lib/fs/promises.js']
+
+ lib_files = SearchFiles('lib', 'js')
+ out['library_files'] = filter_v8_files(lib_files)
Expand All @@ -2322,17 +2332,29 @@ index 0000000000000000000000000000000000000000..7848ddb1841b6d4f36e9376c73564eb4
+ out['node_sources'] += filter_v8_files(blocklisted_sources)
+
+ out['headers'] = []
+ def add_headers(files, dest_dir):
+ def add_headers(options, files, dest_dir):
+ if 'src/node.h' in files:
+ files = [f for f in files if f.endswith('.h') and f != 'src/node_version.h']
+ elif any(f.startswith('../../v8/') for f in files):
+ files = [f.replace('../../v8/', '//v8/', 1) for f in files]
+ if files:
+ hs = {'files': sorted(files), 'dest_dir': dest_dir}
+ out['headers'].append(hs)
+
+ install.variables = {'node_shared_libuv': 'false'}
+ install.headers(add_headers)
+ dir_index = next((i for i, d in enumerate(out['headers']) if d['dest_dir'] == dest_dir), -1)
+ if (dir_index != -1):
+ out['headers'][dir_index]['files'] += sorted(files)
+ else:
+ hs = {'files': sorted(files), 'dest_dir': dest_dir}
+ out['headers'].append(hs)
+
+ config_gypi_path = os.path.join(get_out_dir(), 'gen', 'config.gypi')
+ root_gen_dir = os.path.join(node_root_dir, 'out', 'Release', 'gen')
+
+ options = install.parse_options(['install', '--v8-dir', '../../v8', '--config-gypi-path', config_gypi_path, '--headers-only'])
+ options.variables['node_use_openssl'] = 'false'
+ options.variables['node_shared_libuv'] = 'false'
+ # We generate zlib headers in Electron's BUILD.gn.
+ options.variables['node_shared_zlib'] = ''
+
+ install.headers(options, add_headers)
+ with open(os.path.join(node_root_dir, 'filenames.json'), 'w') as f:
+ f.write(FILENAMES_JSON_HEADER)
+ f.write(json.dumps(out, sort_keys=True, indent=2, separators=(',', ': ')))
Expand Down Expand Up @@ -2363,18 +2385,27 @@ index 0000000000000000000000000000000000000000..9be3ac447f9a4dde23fefc26e0b922b4
+ transformed_f.write(transformed_contents)
+
diff --git a/tools/install.py b/tools/install.py
index b132c7bf26c02886a7ab341a1973bf449744ba0f..171b383a4b6c2528d11dd5f89a6837fd071bcf4b 100755
index b132c7bf26c02886a7ab341a1973bf449744ba0f..757e3e60a7be01fac55c5fbb010dbbae00b1bfca 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -284,6 +284,7 @@ def headers(options, action):
@@ -264,6 +264,7 @@ def headers(options, action):
'include/v8-forward.h',
'include/v8-function-callback.h',
'include/v8-function.h',
+ 'include/v8-handle-base.h',
'include/v8-initialization.h',
'include/v8-internal.h',
'include/v8-isolate.h',
@@ -284,6 +285,8 @@ def headers(options, action):
'include/v8-promise.h',
'include/v8-proxy.h',
'include/v8-regexp.h',
+ "include/v8-sandbox.h",
+ "include/v8-source-location.h",
'include/v8-script.h',
'include/v8-snapshot.h',
'include/v8-statistics.h',
@@ -390,7 +391,7 @@ def parse_options(args):
@@ -390,7 +393,7 @@ def parse_options(args):
parser.add_argument('--build-dir', help='the location of built binaries',
default='out/Release')
parser.add_argument('--v8-dir', help='the location of V8',
Expand Down

0 comments on commit 2633298

Please sign in to comment.