当 make 不需要做任何事情时,我该如何关闭它?
如何阻止 make 说 make: Nothing to be do for 'all'.
或 make: 'file' is up to date
?我希望我的构建在不执行任何操作时保持沉默 - 还有其他地方调用 echo 来跟踪构建进度,因此此消息只是让事情变得混乱。我目前正在这样沉默:
all: dependency1 dependency2
@:
有件事告诉我一定有更好的方法。有什么想法吗?
编辑:
但是,当命令 echo 确实需要构建某些东西时,我希望保持命令 echo 工作。我所希望的一个很好的例子是 --no-print-directory
,但我找不到任何其他标志来关闭选定的消息。
How I stop make from saying make: Nothing to be done for 'all'.
or make: 'file' is up to date
? I'd like my build to be silent when it's not doing anything - there are other places where echo
is called to track build progress, so this message is just cluttering things up. I am currently silencing it like this:
all: dependency1 dependency2
@:
Something tells me there must be a better way. Any ideas?
Edit:
I would like to keep command echo working when it does need to build something, however. A good example of what I'm hoping for is along the lines of --no-print-directory
, but I can't find any other flags to shut up selected messages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
也许
make -s
?Maybe
make -s
?因此,在网上阅读了几天之后,看起来没有比我正在做的更好的方法了。有些人建议的内容大致如下:
也就是说,仅依靠
silent
目标就足以让事情平静下来。由于我没有提出任何其他可行的解决方案,因此我将采用我所拥有的解决方案。So after a couple days of reading around the web, it looks like there isn't any better way than what I'm doing. Some people recommended something along the lines of:
That is, just depending on the
silent
target would be enough to quiet things down. Since I didn't come up with any other workable solutions, I'm going with what I have.你可以尝试...
这样做的好处是,当没有什么可做的时候,什么也不会打印,但是当确实需要继续时, make 会产生正常的输出...
You might try...
The advantage of doing it this way is that nothing is printed when there is nothing to do but make produces the normal output when it does need to proceed...
引用(凭记忆)旧的 make(1) 手册页的 BUGS 部分:有些事情你不能让 make 闭嘴。同时,-s 或 --silent 选项可能会有所帮助。
To quote (from memory) from the old make(1) man page, BUGS section: There are some things you can't get make to shut up about. Meanwhile, the -s or --silent option may help.
您可以通过设置 MAKEFLAGS 在 makefile 本身中设置
-s
命令行参数。除非明确打印,否则不会打印任何内容,因此我使用以下 makefile 来回显调用的命令。删除 MAKEFLAGS 变量将打印所有调用的命令。 Makefile 编译任何 C++ 项目,其中源文件(扩展名为 .cc)放入
src
目录,头文件放入include
目录。You can set the
-s
commandline argument to make in the makefile itself, by setting MAKEFLAGS. Nothing is printed unless you explicitely print it, so I use the following makefile to echo invoked commands.Removing the MAKEFLAGS variable will print all invoked commands. The Makefile compiles any c++ project where source files (with .cc extension) are put into the
src
directory and header files are put into theinclude
directory.使 2>&1 | egrep -v '无事可做|最新'
make 2>&1 | egrep -v 'Nothing to be done|up to date'