This commit is contained in:
blueloveTH 2024-06-15 13:39:32 +08:00
parent 2d0db3dc71
commit 3bd794f2fb
7 changed files with 62 additions and 53 deletions

View File

@ -0,0 +1,27 @@
#pragma once
// generated by prebuild.py
#ifdef __cplusplus
extern "C" {
#endif
extern const char kPythonLibs__enum[];
extern const char kPythonLibs__long[];
extern const char kPythonLibs__set[];
extern const char kPythonLibs_bisect[];
extern const char kPythonLibs_builtins[];
extern const char kPythonLibs_cmath[];
extern const char kPythonLibs_collections[];
extern const char kPythonLibs_colorsys[];
extern const char kPythonLibs_datetime[];
extern const char kPythonLibs_functools[];
extern const char kPythonLibs_heapq[];
extern const char kPythonLibs_itertools[];
extern const char kPythonLibs_operator[];
extern const char kPythonLibs_pickle[];
extern const char kPythonLibs_this[];
extern const char kPythonLibs_typing[];
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -1,21 +0,0 @@
#pragma once
// generated by prebuild.py
namespace pkpy{
extern const char kPythonLibs__enum[];
extern const char kPythonLibs__long[];
extern const char kPythonLibs__set[];
extern const char kPythonLibs_bisect[];
extern const char kPythonLibs_builtins[];
extern const char kPythonLibs_cmath[];
extern const char kPythonLibs_collections[];
extern const char kPythonLibs_colorsys[];
extern const char kPythonLibs_datetime[];
extern const char kPythonLibs_functools[];
extern const char kPythonLibs_heapq[];
extern const char kPythonLibs_itertools[];
extern const char kPythonLibs_operator[];
extern const char kPythonLibs_pickle[];
extern const char kPythonLibs_this[];
extern const char kPythonLibs_typing[];
} // namespace pkpy

View File

@ -23,26 +23,31 @@ def get_sources():
sources = get_sources() sources = get_sources()
# use LF line endings instead of CRLF # use LF line endings instead of CRLF
with open("include/pocketpy/common/_generated.hpp", "wt", encoding='utf-8', newline='\n') as f: with open("include/pocketpy/common/_generated.h", "wt", encoding='utf-8', newline='\n') as f:
data = '''#pragma once data = '''#pragma once
// generated by prebuild.py // generated by prebuild.py
namespace pkpy{ #ifdef __cplusplus
extern "C" {
#endif
''' '''
for key in sorted(sources.keys()): for key in sorted(sources.keys()):
value = sources[key] value = sources[key]
data += f' extern const char kPythonLibs_{key}[];\n' data += f'extern const char kPythonLibs_{key}[];\n'
data += '} // namespace pkpy\n' data += '''
#ifdef __cplusplus
} // extern "C"
#endif
'''
f.write(data) f.write(data)
with open("src/common/_generated.cpp", "wt", encoding='utf-8', newline='\n') as f: with open("src/common/_generated.c", "wt", encoding='utf-8', newline='\n') as f:
data = '''// generated by prebuild.py data = '''// generated by prebuild.py
#include "pocketpy/common/_generated.hpp" #include "pocketpy/common/_generated.h"
namespace pkpy{
''' '''
for key in sorted(sources.keys()): for key in sorted(sources.keys()):
value = sources[key] value = sources[key]
data += f' const char kPythonLibs_{key}[] = {value};\n' data += f'const char kPythonLibs_{key}[] = {value};\n'
data += '} // namespace pkpy\n'
f.write(data) f.write(data)

19
src/common/_generated.c Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
#include "pocketpy/common/version.h" #include "pocketpy/common/version.h"
#include "pocketpy/common/export.h" #include "pocketpy/common/export.h"
#include "pocketpy/common/_generated.hpp" #include "pocketpy/common/_generated.h"
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>

View File

@ -1,6 +1,6 @@
#include "pocketpy/pocketpy.hpp" #include "pocketpy/pocketpy.hpp"
#include "pocketpy/common/_generated.hpp" #include "pocketpy/common/_generated.h"
#include "pocketpy/modules/array2d.hpp" #include "pocketpy/modules/array2d.hpp"
#include "pocketpy/modules/base64.hpp" #include "pocketpy/modules/base64.hpp"