Skip to content

Commit 38186d1

Browse files
authored
Use diagnostics helpers in file_packager.py. NFC (#24805)
1 parent fce364a commit 38186d1

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tools/file_packager.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
__rootdir__ = os.path.dirname(__scriptdir__)
8484
sys.path.insert(0, __rootdir__)
8585

86-
from tools import shared, utils, js_manipulation
86+
from tools import shared, utils, js_manipulation, diagnostics
8787
from tools.response_file import substitute_response_files
8888

8989

@@ -398,7 +398,7 @@ def main(): # noqa: C901, PLR0912, PLR0915
398398
options.indexeddb_name = arg.split('=', 1)[1] if '=' in arg else None
399399
leading = ''
400400
elif arg == '--no-heap-copy':
401-
err('ignoring legacy flag --no-heap-copy (that is the only mode supported now)')
401+
diagnostics.warn('ignoring legacy flag --no-heap-copy (that is the only mode supported now)')
402402
leading = ''
403403
elif arg == '--separate-metadata':
404404
options.separate_metadata = True
@@ -455,12 +455,12 @@ def main(): # noqa: C901, PLR0912, PLR0915
455455
data_files.append(DataFile(srcpath=srcpath, dstpath=dstpath, mode=mode,
456456
explicit_dst_path=uses_at_notation))
457457
else:
458-
err('error: ' + arg + ' does not exist')
458+
diagnostics.error(f'${arg} does not exist')
459459
return 1
460460
elif leading == 'exclude':
461461
excluded_patterns.append(arg)
462462
else:
463-
err('Unknown parameter:', arg)
463+
diagnostics.error('Unknown parameter:', arg)
464464
return 1
465465

466466
options.has_preloaded = any(f.mode == 'preload' for f in data_files)
@@ -473,11 +473,11 @@ def main(): # noqa: C901, PLR0912, PLR0915
473473
return 1
474474

475475
if not options.from_emcc and not options.quiet:
476-
err('Remember to build the main file with `-sFORCE_FILESYSTEM` '
476+
diagnostics.warn('Remember to build the main file with `-sFORCE_FILESYSTEM` '
477477
'so that it includes support for loading this file package')
478478

479479
if options.jsoutput and os.path.abspath(options.jsoutput) == os.path.abspath(data_target):
480-
err('error: TARGET should not be the same value of --js-output')
480+
diagnostics.error('TARGET should not be the same value of --js-output')
481481
return 1
482482

483483
walked.append(__file__)
@@ -491,7 +491,7 @@ def main(): # noqa: C901, PLR0912, PLR0915
491491
data_files = [file_ for file_ in new_data_files
492492
if not os.path.isdir(file_.srcpath)]
493493
if len(data_files) == 0:
494-
err('Nothing to do!')
494+
diagnostics.error('Nothing to do!')
495495
sys.exit(1)
496496

497497
# Absolutize paths, and check that they make sense
@@ -519,7 +519,7 @@ def main(): # noqa: C901, PLR0912, PLR0915
519519
sys.exit(1)
520520
file_.dstpath = abspath[len(curr_abspath) + 1:]
521521
if os.path.isabs(path):
522-
err('Warning: Embedding an absolute file/directory name "%s" to the '
522+
diagnostics.warn('Embedding an absolute file/directory name "%s" to the '
523523
'virtual filesystem. The file will be made available in the '
524524
'relative path "%s". You can use the `--preload-file srcpath@dstpath` '
525525
'syntax to explicitly specify the target location the absolute source '
@@ -564,7 +564,7 @@ def was_seen(name):
564564

565565
if options.obj_output:
566566
if not options.has_embedded:
567-
err('--obj-output is only applicable when embedding files')
567+
diagnostics.error('--obj-output is only applicable when embedding files')
568568
return 1
569569
generate_object_file(data_files)
570570
if not options.has_preloaded:
@@ -666,7 +666,7 @@ def generate_js(data_target, data_files, metadata):
666666
data.write(curr)
667667

668668
if start > 256 * 1024 * 1024:
669-
err('warning: file packager is creating an asset bundle of %d MB. '
669+
diagnostics.warn('file packager is creating an asset bundle of %d MB. '
670670
'this is very large, and browsers might have trouble loading it. '
671671
'see https://hacks.mozilla.org/2015/02/synchronous-execution-and-filesystem-access-in-emscripten/'
672672
% (start / (1024 * 1024)))
@@ -715,7 +715,7 @@ def generate_js(data_target, data_files, metadata):
715715
}\n''' % (create_preloaded if options.use_preload_plugins else create_data)
716716

717717
if options.has_embedded and not options.obj_output:
718-
err('--obj-output is recommended when using --embed. This outputs an object file for linking directly into your application is more efficient than JS encoding')
718+
diagnostics.warn('--obj-output is recommended when using --embed. This outputs an object file for linking directly into your application is more efficient than JS encoding')
719719

720720
for counter, file_ in enumerate(data_files):
721721
filename = file_.dstpath

0 commit comments

Comments
 (0)