[英]How to measure the percentage of files that were compiled successfully?
我正在努力将大量软件移植到新平台上,基本上,在这一点上,我所要做的只是修复偶然发现的编译错误。 我的管理者正在问我“你有多远?” -我该如何衡量我能够成功编译多少代码以及还剩下多少?
这仅是c来源,而我从“ make”获得的日志是如此疯狂,以至于我什至都不知道该如何查找。
我天真地比较了.cpp文件和.o文件的数量:
#!/bin/bash
number_of_sources=$(find . -name \*.cpp | wc -l)
number_of_objects=$(find . -name \*.o | wc -l)
progress=$(echo "${number_of_objects} * 100 / ${number_of_sources}" | bc)
echo "${progress}% of translation units successfully compiled."
这将需要与您的上下文相关的适应(某些子路径不要看起来像.git/
,某些重命名,...)
假设您有将c ++文件编译为目标文件的通用目标,则可以对makefile进行一些调整,以使它可以为您计算编译次数:
SHELL=/bin/bash
[...]
COMPILED_FILES=0
all:
#whatever you do to compile object files together
echo "Total number of compiled files: " $(COMPILED_FILES)
%.o:%.cpp
#whatever you do to compile to object file
$(eval COMPILED_FILES=$(shell echo $$(($(COMPILED_FILES)+1))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.