缓存依赖项

  • 本文关键字:依赖 缓存 scons
  • 更新时间 :
  • 英文 :


scons如何缓存C代码扫描的依赖关系?

问题的上下文是我想在其他语言中使用相同的技术。

现在我必须这样做:

env.Depends(target = 'lib/PROG1.so', dependency = getDependencies('src/PROG1.xxx'))

,其中getDependencies()返回依赖项列表。但这将在每次运行时扫描依赖项。我想缓存这些结果,只在源文件更改时重新扫描。

如果你使用Depends()你可能做错了什么……(这通常意味着您没有指定目标或源,或者构建器的扫描程序缺少文件)

SCons的构建器定义扫描器,扫描源代码寻找包含的文件并保存该信息。

另外,你要为所有的构建器指定它们所构建的目标的源代码。

一般来说,只有当文件发生变化时才会重新扫描。

SCons的一些命令行标志可能会影响源文件的扫描(从手册:https://scons.org/doc/production/HTML/scons-man.html)

--implicit-cache
Cache implicit dependencies. This causes scons to use the implicit (scanned) dependencies from the last time it was run instead of scanning the files for implicit dependencies. This can significantly speed up SCons, but with the following limitations:
scons will not detect changes to implicit dependency search paths (e.g. CPPPATH, LIBPATH) that would ordinarily cause different versions of same-named files to be used.
scons will miss changes in the implicit dependencies in cases where a new implicit dependency is added earlier in the implicit dependency search path (e.g. CPPPATH, LIBPATH) than a current implicit dependency with the same name.
--implicit-deps-changed
Forces SCons to ignore the cached implicit dependencies. This causes the implicit dependencies to be rescanned and recached. This implies --implicit-cache.
--implicit-deps-unchanged
Force SCons to ignore changes in the implicit dependencies. This causes cached implicit dependencies to always be used. This implies --implicit-cache.

还是你另有所指?

最新更新