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

Add --quiet option to file_packager #21307

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3271,18 +3271,18 @@ def check(text):
self.fail('output contains more then one empty line in row')

# relative path must be within/below the current dir
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--preload', '../data1.txt'])
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../data1.txt'])
self.assertContained('which is not contained within the current directory', stderr)

# relative path that ends up under us is cool
proc = self.run_process([FILE_PACKAGER, 'test.data', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
self.assertNotContained('which is not contained within the current directory', proc.stderr)
proc = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
self.assertEqual(proc.stderr, '')
check(proc.stdout)

# direct path leads to the same code being generated - relative path does not make us do anything different
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
check(proc2.stdout)
self.assertNotContained('below the current directory', proc2.stderr)
self.assertEqual(proc2.stderr, '')

def clean(txt):
lines = txt.splitlines()
Expand All @@ -3294,15 +3294,15 @@ def clean(txt):
# verify '--separate-metadata' option produces separate metadata file
os.chdir('..')

self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
self.assertExists('immutable.js.metadata')
# verify js output JS file is not touched when the metadata is separated
orig_timestamp = os.path.getmtime('immutable.js')
orig_content = read_file('immutable.js')
# ensure some time passes before running the packager again so that if it does touch the
# js file it will end up with the different timestamp.
time.sleep(1.0)
self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
# assert both file content and timestamp are the same as reference copy
self.assertTextDataIdentical(orig_content, read_file('immutable.js'))
self.assertEqual(orig_timestamp, os.path.getmtime('immutable.js'))
Expand Down
9 changes: 7 additions & 2 deletions tools/file_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@

--no-node Whether to support Node.js. By default we do, which emits some extra code.

--quiet Suppress reminder about using `FORCE_FILESYSTEM`

Notes:

* The file packager generates unix-style file paths. So if you are on windows and a file is accessed at
Expand Down Expand Up @@ -110,6 +112,7 @@ def __init__(self):
self.obj_output = None
self.depfile = None
self.from_emcc = False
self.quiet = False
self.force = True
# If set to True, IndexedDB (IDBFS in library_idbfs.js) is used to locally
# cache VFS XHR so that subsequent page loads can read the data from the
Expand Down Expand Up @@ -411,9 +414,11 @@ def main():
if '=' in arg:
options.export_name = arg.split('=', 1)[1]
leading = ''
elif arg.startswith('--from-emcc'):
elif arg == '--from-emcc':
options.from_emcc = True
leading = ''
elif arg == '--quiet':
options.quiet = True
elif arg.startswith('--plugin'):
plugin = utils.read_file(arg.split('=', 1)[1])
eval(plugin) # should append itself to plugins
Expand Down Expand Up @@ -454,7 +459,7 @@ def main():
'and a specified --js-output')
return 1

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

Expand Down
Loading