相当于“触摸”。在斯康斯?
scons 使用 MD5 哈希值而不是文件修改时间来确定是否需要构建依赖项。
我希望这是默认行为。但是,除了编辑文件以使其不同之外,还有什么方法可以强制它假定特定文件已过期(相当于“touch”)?
编辑:用例:
二进制文件 F 用于使用工具 X 创建另一个文件 G。由于某种原因,文件 G 已更改(它已损坏,或者我对其进行了编辑)或工具 X 已更改,我想重新创建文件 G 及其下游的所有内容。
编辑:这仅供偶尔使用。我不希望这种情况总是发生,只希望在我要求的那几次发生。另外我可能不提前知道特定的文件。因此,我不想修改 SConscript/SConstruct 文件来构建特定文件。我想要的是在命令提示符下执行此操作:
scons {something to specify file foobar.h}
这将强制 scons 构建依赖于 foobar.h 的所有文件,而只需输入 scons 就会使用 MD5 哈希值进行依赖项检查来进行常规构建。我不介意提前编辑 SConscript/SConstruct 文件以允许这样做(我猜是自定义决策者),如果有办法这样做不会显着增加构建时间。
scons uses MD5 hashes rather than file mod times to determine if a dependency needs to be built.
I want this to be the default behavior. But is there any way to force it to assume a particular file is out of date (the equivalent of "touch"), besides editing the file to make it different?
edit: use case:
binary file F is used to create another file G using a tool X. For some reason file G has changed (it got corrupted, or I edited it) or tool X has changed, and I want to recreate file G and everything downstream of it.
edit: This is for occasional use only. I do not want this to happen always, only those few times when I ask for it. Also I may not know the particular file ahead of time. For this reason I do not want to modify the SConscript/SConstruct files to build a particular file. What I would like is to do this at a command prompt:
scons {something to specify file foobar.h}
and that would force scons to build all files depending on foobar.h, whereas just typing scons
would do the regular build using MD5 hashes for dependency checking. I don't mind editing the SConscript/SConstruct files ahead of time to allow this (custom Decider, I guess), if there's a way to do so that doesn't significantly increase the build times.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否看过 Scons 的 --interactive 选项,您可以在其中清理和构建特定目标。
描述此内容的手册页。
Have you had a a look at the --interactive option of Scons, there you can clean and build specific targets.
man page describing this.
我认为没有办法直接做到这一点。如果相关源文件有一个明显的输出,例如从
test.c
创建的test.o
,则删除test.o
将强制重新编译源文件。相反,如果您想接触来自多个不同源文件的
test.h
,那么您最好清理整个项目以确保所有内容都得到重建。话虽如此,您可能想阅读< code>Decider() 函数,它允许您选择如何处理文件依赖项。您甚至可以为项目中的特定文件选择自定义决策函数,因此,如果您有一些希望能够
触摸
并重建的全局头文件,您可以这样做。更新:要回答您的最新问题,只需删除文件 G。Scons 将在您下次构建时通过运行 X 来从 F 重新创建它。
I don't think there is a way to directly do that. If the source file in question has one obvious output, such as
test.o
created fromtest.c
, then removingtest.o
would force a recompile of the source file.If instead you want to touch
test.h
which is included from multiple different source files, you may be better off doing a clean of your whole project to ensure that everything gets rebuilt.Having said that, you may want to read about the
Decider()
function which lets you choose how file dependencies will be treated. You can even choose a custom decider function for particular files in your project, so if you have some global header file that you'd like to be able totouch
and rebuild, you can do that.Update: To answer your latest question, simply delete the file G. Scons will recreate it from F by running X the next time you build.
我创建了一个虚拟目标文件,其中包含完整日期,一直到小时、分钟和秒。然后我的其他步骤取决于这个虚拟目标文件。这将在每次构建步骤重新编译时更改 md5 值,并导致后续步骤重新编译。或者,您可以删除虚拟目标,这也会级联重新编译。
就我个人而言,我发现这非常有用,因为我无法预测 EDA 构建流程中每个步骤的所有输出。由于维护成本,我也不想尝试预测每个构建步骤的所有输出。
我确信 Decider() 函数,正如 Greg 提到的,更像 scons,但我个人喜欢有时间戳文件。
I create a dummy target file with a full date all the way to the hour minute and second. Then I have the other steps depend on this dummy target file. This will change the md5 value every time the build step recompiles and cause the subsequent steps to recompile. Alternatively you can remove the dummy target and that too will cascade a re-compile.
Personally, I find this very useful because I can't predict all the output from every single step in my EDA build flow. Nor do I want to try to predict all output of every build step because of the maintenance cost.
I'm sure the Decider() function, as Greg has mentioned, is more scons-like, but I personally like to have the timestamp files.
在您的 SConstruct 文件中提取代表您的文件的节点。之后,您应该能够使用 Node.always_build(true) 来确保它已构建,我认为这将迫使其依赖项也被重建。
In your SConstruct file extract the Node that represents your file. After this you should be able to use the Node.always_build(true) to make sure that it is built, I think this will force its dependents to be rebuilt also.