Skip to content

Commit

Permalink
tools: make js2c.py usable for other build systems
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Mar 8, 2023
1 parent 31156a7 commit 5f22737
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/js2c.py
Expand Up @@ -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')
Expand All @@ -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)

Expand Down

0 comments on commit 5f22737

Please sign in to comment.