3

make输出log以及dry run

 1 year ago
source link: https://www.cnblogs.com/cane/p/3914502.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

make输出log以及dry run

一.输出log

如何获得Linux下make的log?
如何保存控制台对话?
如何将编译过程的信息保存成日志?

编译的过程可能会出错,导致编译过程无法继续进行。详细分析出错信息,有助于解决源码中的语法错误。
那么如何保存配置编译过程的信息?这些信息量很大,都可能超出Shell向上翻滚查看的范围。最好是把编译过程的信息保存成日志文件,方便后面的分析。
举例说明保存编译信息的行命令,它把make过程打印的所有信息都保存在xxx.log中。
$make 2>&1|tee xxx.log
这条命令是编译并保存打印信息。在Linux Shell的设备定义中,“0”表示标准输入,“1”表示标准输出,“2”表示标准出错信息输出。2>&1表示把2设备的信息重定向到1设 备;“|”是管道符号,把标准输出的信息直接传递给后面的命令;tee是创建文件并保存信息的工具;xxx.log是文件名。
这种管道的用法在Linux Shell命令中使用非常普遍。编译过程中都可以使用这个方法,生成日志文件,保存到buildlogs目录下。

二.dry run

http://www.cs.northwestern.edu/academics/courses/211/html/make.html

When debugging Makefile's, the following two flags can be handy:

  • -n -- this causes make to only print the actions it would do, but not actually do them
  • -B -- this forces make to run all the actions that apply, whether or not files have changed

Therefore, an easy way to "dry run" a Makefile is to type:

make -B -n

This will show the commands that the Makefile will do to build a project from scratch.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK