Changeset 249095 in webkit for trunk/Source/JavaScriptCore/Scripts/make-js-file-arrays.py
- Timestamp:
- Aug 26, 2019, 7:36:47 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/Scripts/make-js-file-arrays.py
r236321 r249095 27 27 from optparse import OptionParser 28 28 import sys 29 if sys.version_info.major == 2: 30 from StringIO import StringIO 31 else: 32 from io import StringIO 33 from jsmin import JavascriptMinify 29 from jsmin import jsmin 30 is_3 = sys.version_info >= (3, 0) 34 31 35 32 … … 72 69 print('namespace {0:s} {{'.format(namespace), file=sourceFile) 73 70 74 jsm = JavascriptMinify()71 for inputFileName in inputPaths: 75 72 76 for inputFileName in inputPaths: 77 inputStream = io.FileIO(inputFileName) 78 outputStream = StringIO() 73 if is_3: 74 inputStream = io.open(inputFileName, encoding='utf-8') 75 else: 76 inputStream = io.FileIO(inputFileName) 77 78 data = inputStream.read() 79 79 80 80 if not options.no_minify: 81 jsm.minify(inputStream, outputStream) 82 characters = outputStream.getvalue() 81 characters = jsmin(data) 83 82 else: 84 characters = inputStream.read()83 characters = data 85 84 86 size = len(characters) 85 if is_3: 86 codepoints = bytearray(characters, encoding='utf-8') 87 else: 88 codepoints = list(map(ord, characters)) 89 90 # Use the size of codepoints instead of the characters 91 # because UTF-8 characters may need more than one byte. 92 size = len(codepoints) 93 87 94 variableName = os.path.splitext(os.path.basename(inputFileName))[0] 88 95 … … 90 97 print('const char {0:s}JavaScript[{1:d}] = {{'.format(variableName, size), file=sourceFile) 91 98 92 codepoints = list(map(ord, characters))93 99 for codepointChunk in chunk(codepoints, 16): 94 100 print(' {0:s},'.format(','.join(map(stringifyCodepoint, codepointChunk))), file=sourceFile)
Note:
See TracChangeset
for help on using the changeset viewer.