mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
Gyp appends search path for `pymod_do_main`, so `GN-scraper.py` in `v8_gypfiles` always takes precedence over `deps/zlib/GN-scraper.py`, and `deps/zlib/GN-scraper.py` is never loaded. PR-URL: https://github.com/nodejs/node/pull/57238 Refs: https://github.com/nodejs/gyp-next/blob/46fc91f1fa0aeb72a2581ea6996f5e37f7a2e9ce/pylib/gyp/input.py#L935 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
29 lines
886 B
Python
29 lines
886 B
Python
# Copyright (c) 2019 Refael Ackeramnn<refack@gmail.com>. All rights reserved.
|
|
# Use of this source code is governed by an MIT-style license.
|
|
import re
|
|
import os
|
|
import sys
|
|
|
|
PLAIN_SOURCE_RE = re.compile(r'\s*"([^/$].+)"\s*')
|
|
def DoMain(args):
|
|
gn_filename, pattern = args
|
|
src_root = os.path.dirname(gn_filename)
|
|
with open(gn_filename, 'rb') as gn_file:
|
|
gn_content = gn_file.read().decode('utf-8')
|
|
|
|
scraper_re = re.compile(pattern + r'\[([^\]]+)', re.DOTALL)
|
|
matches = scraper_re.search(gn_content)
|
|
match = matches.group(1)
|
|
files = []
|
|
for l in match.splitlines():
|
|
m2 = PLAIN_SOURCE_RE.match(l)
|
|
if not m2:
|
|
continue
|
|
files.append(m2.group(1))
|
|
# always use `/` since GYP will process paths further downstream
|
|
rel_files = ['"%s/%s"' % (src_root, f) for f in files]
|
|
return ' '.join(rel_files)
|
|
|
|
if __name__ == '__main__':
|
|
print(DoMain(sys.argv[1:]))
|