feat(tpc): 翻译进度日志带源文件路径与耗时——并行时不再只有 sha1
- 用户反馈并行分支日志只有 -> xxx.ll(sha1 无文件名无耗时),看不到进度 - _translate_file 加计时,打印改为 '-> xxx.ll <源文件相对路径> (Xs)'(含仅声明分支)
This commit is contained in:
1 parent
ebfaacf7bf
commit
7b04b72d4b
1 file changed
+3
-2
@@ -1372,6 +1372,7 @@ class Phase2Translator:
|
|||||||
|
|
||||||
def _translate_file(self, src_path: str, out_path: str, prebuilt_ModuleSha1Map: dict[str, str] | None = None) -> None:
|
def _translate_file(self, src_path: str, out_path: str, prebuilt_ModuleSha1Map: dict[str, str] | None = None) -> None:
|
||||||
"""翻译单个源文件,嵌入相关 .stub.ll 声明"""
|
"""翻译单个源文件,嵌入相关 .stub.ll 声明"""
|
||||||
|
_t0: float = time.time()
|
||||||
with open(src_path, 'r', encoding='utf-8') as f:
|
with open(src_path, 'r', encoding='utf-8') as f:
|
||||||
code = f.read()
|
code = f.read()
|
||||||
|
|
||||||
@@ -1593,7 +1594,7 @@ class Phase2Translator:
|
|||||||
f.write(text_content)
|
f.write(text_content)
|
||||||
self._save_deps(sha1, ModuleSha1Map)
|
self._save_deps(sha1, ModuleSha1Map)
|
||||||
|
|
||||||
_vlog().info(f" -> {os.path.basename(out_path)}")
|
_vlog().info(f" -> {os.path.basename(out_path)} {os.path.relpath(src_path, self.src_root) if src_path else ''} ({time.time() - _t0:.1f}s)")
|
||||||
else:
|
else:
|
||||||
stub_path = self.stub_files.get(sha1)
|
stub_path = self.stub_files.get(sha1)
|
||||||
if stub_path and os.path.exists(stub_path):
|
if stub_path and os.path.exists(stub_path):
|
||||||
@@ -1604,7 +1605,7 @@ class Phase2Translator:
|
|||||||
stub_content = f.read()
|
stub_content = f.read()
|
||||||
with open(out_path, 'w', encoding='utf-8', newline='\n') as f:
|
with open(out_path, 'w', encoding='utf-8', newline='\n') as f:
|
||||||
f.write(stub_content)
|
f.write(stub_content)
|
||||||
_vlog().info(f" -> {os.path.basename(out_path)} (仅声明)")
|
_vlog().info(f" -> {os.path.basename(out_path)} {os.path.relpath(src_path, self.src_root) if src_path else ''} (仅声明, {time.time() - _t0:.1f}s)")
|
||||||
|
|
||||||
def _register_package_reexports(self, trans, init_pyi_path: str, package_name: str) -> None:
|
def _register_package_reexports(self, trans, init_pyi_path: str, package_name: str) -> None:
|
||||||
"""解析 __init__.pyi 中的 from .xxx import yyy 或 from __xxx import yyy,在包级别注册导出符号"""
|
"""解析 __init__.pyi 中的 from .xxx import yyy 或 from __xxx import yyy,在包级别注册导出符号"""
|
||||||
|
|||||||
Reference in new issue
Block a user