【问题标题】:Caching Dependencies缓存依赖
【发布时间】:2021-10-02 22:02:30
【问题描述】:

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

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

现在我必须做这样的事情:

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

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

【问题讨论】:

    标签: scons


    【解决方案1】:

    如果您使用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.
    

    或者你的意思是别的什么?

    【讨论】:

    • “如果你使用 Depends(),你可能做错了什么”。是的,大概。我正在尝试添加对 scons 不知道如何扫描的语言的支持。也许我的问题应该是:“如何向 scons 添加扫描仪?”
    • 我相信我回答了如何添加扫描仪(或至少将您指向文档).. 在您的其他问题中:stackoverflow.com/questions/69418646/scons-for-cobol
    • 在此处发布该答案,我会接受。让我们将另一个问题留给 cobol 特定的答案。另一个人有一些很好的 cobol 具体答案。然后我们就可以删除这些cmets了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-20
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-07
    • 2016-03-13
    相关资源
    最近更新 更多