[英]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.