代码拉取完成,页面将自动刷新
#!/usr/bin/env python3
# Copyright 2019 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.
"""Size helper script
This script acts as a frontend replacement for `size` that supports combining
JS and wasm output from emscripten.
The traditional size utility reports the size of each section in a binary
and the total. This replacement adds another pseudo-section, "JS" which
shows the size of the JavaScript loader file.
Currently there are many limitations; basically this tool is enough to
be used by the LLVM testsuite runner code to analyze size output.
Currently this tool only supports sysv output format (it accepts but ignores
any '-format' argument). It does not accept any other arguments aside from the
input file, which is expected to be a JS file. The wasm file is expected to be
in the same directory, and have the same basename with a '.wasm' extension.
"""
import argparse
import os
import subprocess
import sys
from tools import shared
LLVM_SIZE = os.path.expanduser(shared.build_llvm_tool_path(shared.exe_suffix('llvm-size')))
def error(text):
print(text, file=sys.stderr, flush=True)
return 1
def parse_args(argv):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-format', '--format')
parser.add_argument('file')
args = parser.parse_args(argv)
return args.file
def print_sizes(js_file):
if not os.path.isfile(js_file):
return error('Input JS file %s not foune' % js_file)
if not js_file.endswith('.js'):
return error('Input file %s does not have a JS extension' % js_file)
basename = js_file[:-3]
# Find the JS file size
st = os.stat(js_file)
js_size = st.st_size
# Find the rest of the sizes
wasm_file = basename + '.wasm'
if not os.path.isfile(wasm_file):
return error('Wasm file %s not found' % wasm_file)
sizes = shared.check_call([LLVM_SIZE, '--format=sysv', wasm_file],
stdout=subprocess.PIPE).stdout
# llvm-size may emit some number of blank lines (after the total), ignore them
lines = [line for line in sizes.splitlines() if line]
# Last line is the total. Add the JS size.
total = int(lines[-1].split()[-1])
total += js_size
for line in lines[:-1]:
print(line)
print('JS\t\t%s\t0' % js_size)
print('Total\t\t%s' % total)
if __name__ == '__main__':
sys.exit(print_sizes(parse_args(sys.argv[1:])))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。