简体   繁体   English

编译时如何更改 makefile 诊断消息 [ GNU ARM GCC, Eclipse make.exe]

[英]How to change makefile diagnostic message when compiling [ GNU ARM GCC, Eclipse make.exe]

I'm building a program for STM32F4 by using GNU-ARM-Gcc and Eclipse_make.exe to build the project.我正在使用GNU-ARM-Gcc和 Eclipse_make.exe 为 STM32F4 构建程序来构建项目。 Everything works fine but the diagnostic message show on the terminal when compiling is too long and very hard to see.一切正常,但编译时终端上显示的诊断消息太长且很难看到。 When each *.c file is compiled, the Terminal gives me a diagnostic message (see the paragraph below) can anyone give me the advice to show just a file name [delete gcc directory path, dependencies, header file path].当编译每个 *.c 文件时,终端会给我一条诊断消息(请参阅下面的段落),任何人都可以建议我只显示文件名 [删除 gcc 目录路径、依赖项、头文件路径]。 The makefile is generated by CubeMX.生成文件由 CubeMX 生成。 Here is makefile: https://github.com/loiefy/STM32-makefile/blob/main/Makefile这是生成文件: https : //github.com/loiefy/STM32-makefile/blob/main/Makefile

The example diagnostic message:示例诊断消息:

C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/arm-none-eabi-gcc -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32F407xx -IEngine/Src/website_c -IEngine/Inc -ILWIP/Target -IMiddlewares/Third_Party/LwIP/src/include -IMiddlewares/Third_Party/LwIP/system -IDrivers/STM32F4xx_HAL_Driver/Inc -IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy -IMiddlewares/Third_Party/LwIP/src/include/netif/ppp -IMiddlewares/Third_Party/LwIP/src/apps/httpd -IDrivers/CMSIS/Device/ST/STM32F4xx/Include -IMiddlewares/Third_Party/LwIP/src/include/lwip -IMiddlewares/Third_Party/LwIP/src/include/lwip/apps -IMiddlewares/Third_Party/LwIP/src/include/lwip/priv -IMiddlewares/Third_Party/LwIP/src/include/lwip/prot -IMiddlewares/Third_Party/LwIP/src/include/netif -IMiddlewares/Third_Party/LwIP/src/include/posix -IMiddlewares/Third_Party/LwIP/src/include/posix/sys -IMiddlewares/Third_Party/LwIP/system/arch -IDrivers/CMSIS/Include -IDrivers/CMSIS/Include -IEngine/Inc -ILWIP/Target  -Og -Wall -fdata-sections -ffunction-sections -fdiagnostics-show-location=every-line -g -gdwarf-2 -MMD -MP -MF"build/mqtt.d"  -Wa,-a,-ad,-alms=build/mqtt.lst Middlewares/Third_Party/LwIP/src/apps/mqtt/mqtt.c -o build/mqtt.o

The message I want to show: Middlewares/Third_Party/LwIP/src/apps/mqtt/mqtt.c was compiled我想显示的消息: Middlewares/Third_Party/LwIP/src/apps/mqtt/mqtt.c已编译

I had spent a day finding the echo command or another command has the same purpose to show the message inside the makefile.我花了一天时间发现 echo 命令或另一个命令具有相同的目的来显示 makefile 中的消息。 But I found nothing.但我什么也没发现。
Thank you for your help感谢您的帮助

So make by default echo's each line it runs - your compiler line in the makefile:因此,默认情况下,make 会运行它运行的每一行 - 您在 makefile 中的编译器行:

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

Will output the execution line what you can do is:将输出执行行你可以做的是:

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
    @echo "compiling $<"
    @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

Note: the @ prefix in make means dont print the command that is being executed.注意:make 中的@前缀表示不打印正在执行的命令。 Hence even the echo line needs the @ otherwise you would get the echo comping... getting printed as well as compiling ...因此,即使是回声线也需要@ 否则你会得到echo comping...打印和compiling ...

You may or may not want to do similar for all of your outputs.您可能想也可能不想对所有输出都做类似的事情。 I some times conditionally do one or other based on a verbosity flag that can be passed in so that when you really want to see the actual compile line you can....有时我会根据可以传入的详细标志有条件地执行一项或多项操作,以便当您真的想查看实际的编译行时可以....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM