Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: make js2c.py usable for other build systems #46930

Merged
merged 1 commit into from Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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