Skip to content

Commit

Permalink
build: using pymod_do_main in node.gyp
Browse files Browse the repository at this point in the history
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 <targos@protonmail.com>
  • Loading branch information
himself65 and targos committed Jul 7, 2021
1 parent 4de6f20 commit 4b2344f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion node.gyp
Expand Up @@ -33,7 +33,7 @@
# Windows command length limit or there would be an error.
# See https://docs.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
'library_files': [
'<!@(python tools/search_files.py --ext js lib)',
'<!@pymod_do_main(search_files --ext js lib)',
],
'deps_files': [
'deps/v8/tools/splaytree.mjs',
Expand Down
1 change: 1 addition & 0 deletions tools/gyp_node.py
Expand Up @@ -7,6 +7,7 @@
node_root = os.path.normpath(os.path.join(script_dir, os.pardir))

sys.path.insert(0, os.path.join(node_root, 'tools', 'gyp', 'pylib'))
sys.path.insert(0, os.path.join(node_root, 'tools', 'search_files'))
import gyp

# Directory within which we want all generated files (including Makefiles)
Expand Down
12 changes: 7 additions & 5 deletions tools/search_files.py
Expand Up @@ -7,16 +7,18 @@

import argparse
import utils
import sys

def main():
def DoMain(args = []):
parser = argparse.ArgumentParser(
description='Search files with a specific extension under a directory',
fromfile_prefix_chars='@'
)
parser.add_argument('--ext', required=True, help='extension to search for')
parser.add_argument('directory', help='input directory')
options = parser.parse_args()
print('\n'.join(utils.SearchFiles(options.directory, options.ext)))
options = parser.parse_args(args)
return '\n'.join(utils.SearchFiles(options.directory, options.ext))

if __name__ == "__main__":
main()

if __name__ == '__main__':
DoMain(sys.argv[1:])

0 comments on commit 4b2344f

Please sign in to comment.