From 5ba5fb5ff3811c41d0eee90ebe980685e40c1c4a Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 1 Sep 2026 20:16:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(linker):=20include=20=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=AB=E6=8F=8F=E6=94=AF=E6=8C=81=20.no=5F?= =?UTF-8?q?autobuild=20=E6=A0=87=E8=AE=B0=E4=B8=8E=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=8E=92=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _scan_dir_for_libs:模块目录含 .no_autobuild 时跳过 C 源编译与库文件自动发现 - 递归时跳过 build/cmake-build*/.git/__pycache__/. 开头目录 - 防止 fltk 等内嵌完整第三方源码的 include 模块被误编译 --- lib/Projectrans/Phase2Translator.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Projectrans/Phase2Translator.py b/lib/Projectrans/Phase2Translator.py index 629b630..014cd1a 100644 --- a/lib/Projectrans/Phase2Translator.py +++ b/lib/Projectrans/Phase2Translator.py @@ -2263,8 +2263,22 @@ class Phase2Translator: _vlog().info(f"[includes] 需要编译的源文件: {len(self.extra_compile_files)} 个") def _scan_dir_for_libs(self, directory: str, module_name: str) -> None: - """递归扫描目录中的库文件和源文件""" + """递归扫描目录中的库文件和源文件 + + 模块目录含 `.no_autobuild` 标记时直接跳过:该模块的 C/C++ 源码 + 与库文件由 project.vpj linker.static_libs 显式链接(如 fltk 内嵌 + 完整 FLTK/C 源码树,避免误编译整个第三方库)。递归时跳过常见 + 构建/缓存目录(build、cmake-build*、.git、__pycache__、. 开头)。 + """ + if _CachedIsFile(os.path.join(directory, '.no_autobuild')): + return for root, dirs, files in os.walk(directory): + dirs[:] = [ + d for d in dirs + if d not in ('.git', '__pycache__', 'build', 'cmake-build') + and not d.startswith('cmake-build-') + and not d.startswith('.') + ] for fname in files: fpath = os.path.join(root, fname) _, ext = os.path.splitext(fname)