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)