소스 검색

optimize compile time

blueloveTH 1 년 전
부모
커밋
1d32d2b42a
3개의 변경된 파일26개의 추가작업 그리고 9개의 파일을 삭제
  1. 0 1
      include/pocketpy/_generated.h
  2. 21 8
      prebuild.py
  3. 5 0
      src/_generated.cpp

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 1
include/pocketpy/_generated.h


+ 21 - 8
prebuild.py

@@ -1,6 +1,6 @@
 import os
 
-def generate_python_sources():
+def get_sources():
     sources = {}
     for file in sorted(os.listdir("python")):
         if not file.endswith(".py"):
@@ -17,18 +17,31 @@ def generate_python_sources():
         const_char_array.append('0')
         const_char_array = ','.join(const_char_array)
         sources[key] = '{' + const_char_array + '}'
+    return sources
 
-    header = '''#pragma once
+sources = get_sources()
+
+# use LF line endings instead of CRLF
+with open("include/pocketpy/_generated.h", "wt", encoding='utf-8', newline='\n') as f:
+    data = '''#pragma once
 // generated by prebuild.py
 
 namespace pkpy{
 '''
     for key in sorted(sources.keys()):
         value = sources[key]
-        header += f'    inline const char kPythonLibs_{key}[] = {value};\n'
-    header += '}\n'
-    return header
+        data += f'    extern const char kPythonLibs_{key}[];\n'
+    data += '}    // namespace pkpy\n'
+    f.write(data)
 
-# use LF line endings instead of CRLF
-with open("include/pocketpy/_generated.h", "wt", encoding='utf-8', newline='\n') as f:
-    f.write(generate_python_sources())
+with open("src/_generated.cpp", "wt", encoding='utf-8', newline='\n') as f:
+    data = '''// generated by prebuild.py
+#include "pocketpy/_generated.h"
+
+namespace pkpy{
+'''
+    for key in sorted(sources.keys()):
+        value = sources[key]
+        data += f'    const char kPythonLibs_{key}[] = {value};\n'
+    data += '}    // namespace pkpy\n'
+    f.write(data)

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 5 - 0
src/_generated.cpp


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.