summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Zhao <zcbenz@gmail.com>2023-04-11 05:11:22 +0900
committerRafaelGSS <rafael.nunu@hotmail.com>2023-04-13 16:48:54 -0300
commit10005de6a80329f7fb3b71e65eb64e5c3db6a57f (patch)
tree645b1fae5bac888e20150c7509f916e0074e639b
parent1e2f9aca72c28b0862a52027ed23b9ff5673fcde (diff)
downloadnode-new-10005de6a80329f7fb3b71e65eb64e5c3db6a57f.tar.gz
tools: make `js2c.py` usable for other build systems
PR-URL: https://github.com/nodejs/node/pull/46930 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
-rwxr-xr-xtools/js2c.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/js2c.py b/tools/js2c.py
index 504345e789..50f34c070a 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -215,12 +215,20 @@ def main():
'--directory',
default=None,
help='input file directory')
+ parser.add_argument(
+ '--root',
+ default=None,
+ help='root directory containing the sources')
parser.add_argument('--verbose', action='store_true', help='output file')
parser.add_argument('sources', nargs='*', help='input files')
options = parser.parse_args()
global is_verbose
is_verbose = options.verbose
sources = options.sources
+
+ if options.root is not None:
+ os.chdir(options.root)
+
if options.directory is not None:
js_files = utils.SearchFiles(options.directory, 'js')
mjs_files = utils.SearchFiles(options.directory, 'mjs')
@@ -231,7 +239,8 @@ def main():
# Should have exactly 3 types: `.js`, `.mjs` and `.gypi`
assert len(source_files) == 3
# Currently config.gypi is the only `.gypi` file allowed
- assert source_files['.gypi'] == ['config.gypi']
+ assert len(source_files['.gypi']) == 1
+ assert os.path.basename(source_files['.gypi'][0]) == 'config.gypi'
source_files['config.gypi'] = source_files.pop('.gypi')[0]
JS2C(source_files, options.target)