【发布时间】:2015-06-18 12:32:12
【问题描述】:
我正在使用生成文件来运行测试。我不确定.PHONY 的使用。我读过这篇文章:What is the purpose of .PHONY in a makefile?,但我仍然不确定。
我有以下生成文件:
```
test:
@# 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 还是不使用?但更重要的是,为什么? (或者为什么不呢?)
谢谢!
马尔科姆·金德曼斯
【问题讨论】:
-
以
@#开头的那些行是“奇数”。 -
@trojanfoe 并非如此,通过在这些注释行前面加上
@,它们在输出中不可见,仅在 makefile 中可见。 -
它们是 cmets,因此无论如何都会被忽略。正如我所说的“奇怪”。
-
@trojanfoe 这有点奇怪,因为当我没有在这些行之前加上
@时,它们会打印在输出中。 -
如果您删除了它们之前的选项卡,它们也不会显示 - 那么它们将是
makecmets 而不是 shell cmets。无论如何,这个问题似乎在您发布的链接后面得到了相当广泛的回答。test应该是假的,这样touch test; make test就不会声称test是最新的。究竟是什么还不清楚?
标签: makefile