自定义生成规则始终触发 [英] Custom Build rule Always fires

查看:76
本文介绍了自定义生成规则始终触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义构建规则,该规则从我的* .FOO输入文件生成一个* .CPP和一个* .H文件.一切正常,除了规则始终会触发,即使* .FOO输入文件没有更改,并且* .CPP和* .H文件都比* .FOO文件新.

这使我的工具在每次构建时都写入新的* .CPP和* .H文件.由于生成的标头经常包含在我的项目中,因此最终会在不需要时导致大量冗长的构建.

我如何制定仅在输出文件较新时才触发的自定义构建规则

.B ekiM

I have a custom build rule which generates a *.CPP and a *.H file from my *.FOO input file. Everything works great, except that the rule always fires, even when there haven't been changes to the *.FOO input file and the *.CPP and *.H files are both newer than the *.FOO file.

This causes my tool to write new *.CPP and *.H files at each build. Since the header generated is included often in my project, it ends up causing lots of lengthy builds when it doesn't need to.

How do I make a custom build rule that only fires when the output files are newer than the input file?

.B ekiM

推荐答案

此行为是设计使然吗?

注意构建进一步的依赖关系时,不会考虑我的程序生成的任何内容.

请说CustomTool从Basic.FOO构建Basic.H和Basic.CPP. Main.CPP包含Basic.H,因此对Basic.H的任何更改都应重建Main.OBJ.因此,对Baisc.FOO的任何更改都应导致重建Main.OBJ.

但这不会发生.当Basic.FOO更改时,第一个版本将运行CustomTool,创建新的Basic.CPP和Basic.H.但这结束了构建;没有建立Main.CPP.另一个版本将再次调用CustomTool,并且仅在那时才构建Main.CPP.

Visual C ++是否仅在调用它时分析依赖项和时间戳?

.B ekiM
Is this behaviour by design?

I'm further noticing that anything my program generates is not considered when building further dependencies.

Say CustomTool builds Basic.H and Basic.CPP from Basic.FOO. Main.CPP includes Basic.H, so any change to Basic.H should rebuild Main.OBJ. And therefore, any change to Baisc.FOO should cause a rebuild of Main.OBJ.

But that doesn't happen. When Basic.FOO changes, the first build will run CustomTool, creating a new Basic.CPP and Basic.H. But that ends the build; Main.CPP isn't built. Another build will invoke CustomTool again, and only at that time is Main.CPP built.

Does Visual C++ only analyze the dependencies and time stamps when it is invoked? Is there a way to force it to check the time stamps as it goes, so that files chagned by the build process itself are rebuilt as expected?

.B ekiM


这篇关于自定义生成规则始终触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆