Skip to content

Commit 0560672

Browse files
zcbenzMoLow
authored andcommitted
tools: make js2c.py usable for other build systems
PR-URL: #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>
1 parent d11c6ba commit 0560672

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/js2c.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,20 @@ def main():
209209
'--directory',
210210
default=None,
211211
help='input file directory')
212+
parser.add_argument(
213+
'--root',
214+
default=None,
215+
help='root directory containing the sources')
212216
parser.add_argument('--verbose', action='store_true', help='output file')
213217
parser.add_argument('sources', nargs='*', help='input files')
214218
options = parser.parse_args()
215219
global is_verbose
216220
is_verbose = options.verbose
217221
sources = options.sources
222+
223+
if options.root is not None:
224+
os.chdir(options.root)
225+
218226
if options.directory is not None:
219227
js_files = utils.SearchFiles(options.directory, 'js')
220228
mjs_files = utils.SearchFiles(options.directory, 'mjs')
@@ -225,7 +233,8 @@ def main():
225233
# Should have exactly 3 types: `.js`, `.mjs` and `.gypi`
226234
assert len(source_files) == 3
227235
# Currently config.gypi is the only `.gypi` file allowed
228-
assert source_files['.gypi'] == ['config.gypi']
236+
assert len(source_files['.gypi']) == 1
237+
assert os.path.basename(source_files['.gypi'][0]) == 'config.gypi'
229238
source_files['config.gypi'] = source_files.pop('.gypi')[0]
230239
JS2C(source_files, options.target)
231240

0 commit comments

Comments
 (0)