mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
minify _generated.cpp
This commit is contained in:
parent
707a880c2e
commit
41e84e52a2
15
prebuild.py
15
prebuild.py
@ -8,15 +8,16 @@ def get_sources():
|
||||
key = file.split(".")[0]
|
||||
const_char_array = []
|
||||
with open("python/" + file) as f:
|
||||
# convert to char array (signed)
|
||||
specials = { 10: '\\n', 34: '\\"' }
|
||||
for c in f.read().encode('utf-8'):
|
||||
if c < 128:
|
||||
const_char_array.append(str(c))
|
||||
if c in specials:
|
||||
const_char_array.append(specials[c])
|
||||
elif c >= 32 and c <= 126 and c != 92:
|
||||
const_char_array.append(chr(c))
|
||||
else:
|
||||
const_char_array.append(str(c - 256))
|
||||
const_char_array.append('0')
|
||||
const_char_array = ','.join(const_char_array)
|
||||
sources[key] = '{' + const_char_array + '}'
|
||||
const_char_array.append(f'\\x{c:02x}')
|
||||
const_char_array = ''.join(const_char_array)
|
||||
sources[key] = '"' + const_char_array + '"'
|
||||
return sources
|
||||
|
||||
sources = get_sources()
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user