Skip to content

Commit 4b2344f

Browse files
himself65targos
andcommitted
build: using pymod_do_main in node.gyp
GYP uses the system path when parsing node.gyp; However, if system python is different from our gyp runtime python, like '2.7', gyp would crash. Co-authored-by: Michaël Zasso <[email protected]>
1 parent 4de6f20 commit 4b2344f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

node.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Windows command length limit or there would be an error.
3434
# See https://docs.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
3535
'library_files': [
36-
'<!@(python tools/search_files.py --ext js lib)',
36+
'<!@pymod_do_main(search_files --ext js lib)',
3737
],
3838
'deps_files': [
3939
'deps/v8/tools/splaytree.mjs',

tools/gyp_node.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
node_root = os.path.normpath(os.path.join(script_dir, os.pardir))
88

99
sys.path.insert(0, os.path.join(node_root, 'tools', 'gyp', 'pylib'))
10+
sys.path.insert(0, os.path.join(node_root, 'tools', 'search_files'))
1011
import gyp
1112

1213
# Directory within which we want all generated files (including Makefiles)

tools/search_files.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77

88
import argparse
99
import utils
10+
import sys
1011

11-
def main():
12+
def DoMain(args = []):
1213
parser = argparse.ArgumentParser(
1314
description='Search files with a specific extension under a directory',
1415
fromfile_prefix_chars='@'
1516
)
1617
parser.add_argument('--ext', required=True, help='extension to search for')
1718
parser.add_argument('directory', help='input directory')
18-
options = parser.parse_args()
19-
print('\n'.join(utils.SearchFiles(options.directory, options.ext)))
19+
options = parser.parse_args(args)
20+
return '\n'.join(utils.SearchFiles(options.directory, options.ext))
2021

21-
if __name__ == "__main__":
22-
main()
22+
23+
if __name__ == '__main__':
24+
DoMain(sys.argv[1:])

0 commit comments

Comments
 (0)