如何格式化/更改 qmake 构建输出

发布于 2024-08-06 00:49:58 字数 172 浏览 4 评论 0原文

如何格式化 make 输出(!!仅通过更改 qmake 项目文件!!)。 我的编译行继续增长,并且单行警告/错误几乎在它们之间消失。

我正在考虑诸如

$(CC) in.ext -o out.ext

感谢之类的事情

how can I format the make output (!!by only changing the qmake project file!!).
My compilation lines continue growing, and the one-line-warnings/errors almost disappear between them.

I am thinking of something like

$(CC) in.ext -o out.ext

thanks in regard

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

明明#如月 2024-08-13 00:49:58

在 qmake 中,您可以添加一个静默配置选项:(

CONFIG += silent

注意:我认为这就是命令。它与此类似。)

它应该抑制大部分输出,并且仅打印诸如“compiling ao”之类的行”,以及您的警告和错误。我相信这类似于 make.SILENT. 指令(我认为这就是那个......)

但是,您可能需要小心这一点,因为它抑制错误解析器喜欢使用的大量信息。例如,如果您使用 SUBDIRS 配置进行编译,则当它更改为不同的目录时,它不会打印出来。

In qmake, you can add a silent configuration option:

CONFIG += silent

(note: I think that's the command. It's something similar to this.)

Which should suppress most of the output, and only print lines like "compiling a.o", along with your warnings and errors. I believe this is similar to make's .SILENT. directive (I think that's the one...)

You may want to be careful with this, however, because it suppresses a lot of information that error parsers like to use. For example, if you are compiling with a SUBDIRS configuration, it won't print out when it changes to the different directories.

挽梦忆笙歌 2024-08-13 00:49:58

有不同的方法。并且您可以使它们可配置。

  • 如果您在规则内的行前面添加@符号,则命令本身不会被打印,但其输出会被打印。
  • 如果您-Werror添加到您的CFLAGS变量中(您确实有一个,不是吗?这是一种常见的做法!),您肯定会不会错过任何警告——构建将在第一个警告之后停止。
  • 您可以将命令的标准输出重定向到/dev/null,只留下错误流(这不适用于您的特定情况,因为gcc通常不会产生输出,但是可能对其他命令有帮助)。

不幸的是,对于 qmake 仅适用第二种方法。添加到您的项目文件:

QMAKE_CFLAGS+=-Werror
QMAKE_CXXFLAGS+=-Werror

生成的 makefile 在调用编译器时将使用这些标志,因此构建将在每次警告时停止。


(一旦出现问题,本节将移至另一个问题)。

对于通常的制作,你可以使用它们——你可以将它们全部配置!示例如下:

trace?=short

ifeq ($(trace),short)
  suppress_echo=@
  redirect_to_null=1>/dev/null

else ifeq ($(trace),full)
  suppress_echo=
  redirect_to_null=

else ifeq ($(trace),werror)
  CFLAGS+=-Werror

else
  $(error Incorrect trace type "$(trace)"!)
endif

# Thanks to Martin York for the source of this copy-pasted code
out.ext:  $(OBJ)
    @echo $(CC) $(CFLAGS) -o out.ext $(redirect_to_null)
    $(suppress_echo)$(CC) $(CFLAGS) -o out.ext $(OBJ) $(redirect_to_null)

因此,如果您像这样调用 make

$ make trace=full

它将打印所有内容。如果您调用,则

$ make

默认情况下将使用 short 值(请注意 ?= 运算符而不是通常的 =!),并且规则将扩展为这样的版本

out.ext: out.o
    @echo cc  -o out.ext 1>/dev/null
    @cc  -o out.ext out.o 1>/dev/null

将满足您的需求。

这种带有配置的方法被用于生产代码中。例如,我在 Ubuntu 的 IcedTea makefile 中看到了它。

There are different approaches. And you can make them configurable.

  • If you add @ sign in front of the line within rule, the command itself won't be printed, but its output will.
  • If you add -Werror to your CFLAGS variable (you do have one, don't you? It's a common practice!), you definitely won't miss any warning--the build will stop after the first one.
  • You can redirect standard output of your command to /dev/null, leaving only error stream (this is not for your particular case, because gcc usually doesn't yield output but may be helpful for other commands).

Unfortunately, for qmake only the second approach applies. Add to your project file:

QMAKE_CFLAGS+=-Werror
QMAKE_CXXFLAGS+=-Werror

And the makefiles generated will use these flags when they invoke compiler, so the build will stop at every warning.


(this section will be moved to another question as soon an one appears).

For usual make you can use it all--you can make it all configurable! Here's the example:

trace?=short

ifeq ($(trace),short)
  suppress_echo=@
  redirect_to_null=1>/dev/null

else ifeq ($(trace),full)
  suppress_echo=
  redirect_to_null=

else ifeq ($(trace),werror)
  CFLAGS+=-Werror

else
  $(error Incorrect trace type "$(trace)"!)
endif

# Thanks to Martin York for the source of this copy-pasted code
out.ext:  $(OBJ)
    @echo $(CC) $(CFLAGS) -o out.ext $(redirect_to_null)
    $(suppress_echo)$(CC) $(CFLAGS) -o out.ext $(OBJ) $(redirect_to_null)

So, if you invoke make like this:

$ make trace=full

it will print everything. If you invoke

$ make

the short value will be used by default (note the ?= operator instead of usual =!) and the rules will expand to such version

out.ext: out.o
    @echo cc  -o out.ext 1>/dev/null
    @cc  -o out.ext out.o 1>/dev/null

what will give much as you need.

Such approach, with configuration, is used in production code. For example, I saw it in Ubuntu's IcedTea makefiles.

淡莣 2024-08-13 00:49:58

您可以使用“@”抑制打印输出并回显您想要看到的内容:

简单示例:

out.ext:  $(OBJ)
    @echo $(CC) -o out.ext
    @$(CC) -o out.ext $(OBJ) $(OTHER_FLAGS_ETC)

You can suppress the printout with '@' and echo what you want to see:

Simple Example:

out.ext:  $(OBJ)
    @echo $(CC) -o out.ext
    @$(CC) -o out.ext $(OBJ) $(OTHER_FLAGS_ETC)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文