使用 Microsoft nmake 时如何获取命令的输出?
通过 Linux 上的 make
,我们可以执行以下操作:
foo=$(shell /bin/bar)
运行命令 bar
并将输出分配给 foo
。稍后可以通过引用 $(foo)
在 makefile 中使用它。
但现在我手上有一个 Microsoft 项目,它是用 Microsoft nmake.exe
编译和链接的。 nmake 是否有等效的东西可以让我运行命令并将输出分配给变量?
With make
on linux, we can do things like:
foo=$(shell /bin/bar)
which runs the command bar
and assigns the output to foo
. This can later be used in the makefile by referencing $(foo)
.
But now I have a Microsoft project on my hands that is compiled and linked with the Microsoft nmake.exe
. Is there an equivalent thing for nmake that would allow me to run a command and assign the output to a variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然这是一个老问题,但有一种方法可以做到所要求的;它只是很复杂,就像批处理文件中的所有内容一样!
人们必须使用 make 导入环境变量和预处理器可以调用命令的组合机制,然后递归地调用 Makefile。它假设 Makefile 名为 Makefile(没有扩展名,这是默认的)。
是的,我知道这很糟糕,但它确实演示了如何执行该技术,该技术可以使用任何 shell 命令来完成,而不仅仅是
主机名
。Although this is an old question, there is a method of doing what is asked; its just convoluted, like everything in batch files!
One has to use the combined mechanisms of the fact that make imports environmental variables and that the preprocessor can invoke commands, and then call the Makefile recursively. It assume the Makefile is called Makefile (with no extension, which is the default).
Yes, I know its horrible, but it does demonstrate how to do the technique, which can be done with any shell command and not just
hostname
.我认为答案是“不”。没有同等的。
如果可能的话,我建议您转换为 MSBuild。
I think the answer is "no." There is no equivalent.
I'd recommend that you convert to MSBuild if possible.