我正在使用makefile来运行测试。我对.PHONY的用法不是很确定。我读过这篇文章:What is the purpose of .PHONY in a makefile?,但我仍然不确定。
我有以下makefile:
```javascript测试:
@# Clear console log before we start.@clear# Make sure we are not having too much modules.@npm prune# Make sure we have the required modules.@npm install@# Clear the console, so we only see the test results.@clear# Run the test.@./node_modules/.bin/mocha-casperjs test.js --reporter=spec我的make test命令没有创建任何新文件。我是否应该使用.PHONY: test?但更重要的是,为什么?(或者为什么不呢?)
谢谢!
马尔科姆·金德曼斯
发布于 2015-04-13 17:04:29
感谢@Wintermute,我得到了我的问题的答案。他评论说:
如果您删除了它们前面的选项卡,它们也不会出现--然后它们将是make而不是shell comments。无论如何,这个问题似乎在你发布的链接后面得到了相当广泛的回答。test应该是doesn,这样touch test;make test就不会声明测试是最新的。究竟是什么还不清楚?
所以答案是:“是的,我需要将test添加到.PHONY中,因为执行命令touch test会破坏这个make命令。
https://stackoverflow.com/questions/29601240
复制相似问题