mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
c60fdd29ab
commit
efc5755d78
File diff suppressed because one or more lines are too long
15
prebuild.py
15
prebuild.py
@ -6,10 +6,17 @@ def generate_python_sources():
|
||||
if not file.endswith(".py"):
|
||||
continue
|
||||
key = file.split(".")[0]
|
||||
const_char_array = []
|
||||
with open("python/" + file) as f:
|
||||
value = f.read()
|
||||
const_array = ','.join([str(b) for b in value.encode('utf-8')])
|
||||
sources[key] = '(const char[]){' + const_array + '}'
|
||||
# convert to char array (signed)
|
||||
for c in f.read().encode('utf-8'):
|
||||
if c < 128:
|
||||
const_char_array.append(str(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[]){' + const_char_array + '}'
|
||||
|
||||
header = '''#pragma once
|
||||
// generated by prebuild.py
|
||||
@ -18,7 +25,7 @@ def generate_python_sources():
|
||||
#include <string>
|
||||
|
||||
namespace pkpy{
|
||||
inline const std::map<std::string, const char*> kPythonLibs = {
|
||||
inline std::map<std::string, const char*> kPythonLibs = {
|
||||
'''
|
||||
for key, value in sources.items():
|
||||
header += f' {{ "{key}", {value} }},\n'
|
||||
|
Loading…
x
Reference in New Issue
Block a user