Skip to content

Commit 10005de

Browse files
zcbenzRafaelGSS
authored andcommitted
tools: make js2c.py usable for other build systems
PR-URL: #46930 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 1e2f9ac commit 10005de

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/js2c.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,20 @@ def main():
215215
'--directory',
216216
default=None,
217217
help='input file directory')
218+
parser.add_argument(
219+
'--root',
220+
default=None,
221+
help='root directory containing the sources')
218222
parser.add_argument('--verbose', action='store_true', help='output file')
219223
parser.add_argument('sources', nargs='*', help='input files')
220224
options = parser.parse_args()
221225
global is_verbose
222226
is_verbose = options.verbose
223227
sources = options.sources
228+
229+
if options.root is not None:
230+
os.chdir(options.root)
231+
224232
if options.directory is not None:
225233
js_files = utils.SearchFiles(options.directory, 'js')
226234
mjs_files = utils.SearchFiles(options.directory, 'mjs')
@@ -231,7 +239,8 @@ def main():
231239
# Should have exactly 3 types: `.js`, `.mjs` and `.gypi`
232240
assert len(source_files) == 3
233241
# Currently config.gypi is the only `.gypi` file allowed
234-
assert source_files['.gypi'] == ['config.gypi']
242+
assert len(source_files['.gypi']) == 1
243+
assert os.path.basename(source_files['.gypi'][0]) == 'config.gypi'
235244
source_files['config.gypi'] = source_files.pop('.gypi')[0]
236245
JS2C(source_files, options.target)
237246

0 commit comments

Comments
 (0)