Waf:如何输出生成的文件?
我有一个文件,在通过 python 脚本推送后,我想将其发送到构建目录。我该如何在 waf 中执行此操作?
例如,如果我有一个这样的文件:
VERSION=%%VERSION%%
DATADIR=%%DATADIR%%
在将其输出到 waf 构建目录之前想要替换 %%VERSION%% 和 %%DATADIR%%,我该怎么做?
我知道这大概是这样的:
ctx(rule='???'
source='versionfile.ver',
target='versionfile.out'
)
但我不知道规则是什么。
另外,一旦生成该文件,是否可以在其他任务中使用它?
I have a file I want to send to the build directory after it's been pushed through a python script. How would I do this in waf?
For example, if I had a file like this:
VERSION=%%VERSION%%
DATADIR=%%DATADIR%%
And wanted to replace %%VERSION%% and %%DATADIR%% before outputing that to the waf build directory, how would I do that?
I know it's something along the lines of:
ctx(rule='???'
source='versionfile.ver',
target='versionfile.out'
)
But I don't know what the rule would be.
Also, once that file is generated, is it possible to use it in other tasks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是想替换输入文件,则 versionfile.ver 应该如下所示
现在您可以使用以下任务,以便替换值
要能够从 bld 访问版本,您必须在配置期间定义它
您可以找到此 waf正在执行的任务此处 的输出文件这个任务可以是用作其他任务的输入。
但是,当您想通过 python 脚本或任何可用命令传递源文件时,您可以使用以下命令:
还有一个可用的示例 here 在这种情况下使用 g-ir-compiler 在你的情况下将是一个 python 脚本。
If you simply want to substitute an input file your versionfile.ver should look like this
Now you can use the following task so the values will be substituted
To be able to access version from bld you have to define it during configure
You can find this waf task in action here Output files of this tasks can than be used as input for other tasks.
However when you want to pass on your source file through a python script or any command available you can use the following:
There is also a sample available here where in this case g-ir-compiler is used what in your case would be a python script.