tool/metrics: add label header to metrics.tsv

This commit is contained in:
Matthias Ringwald 2024-05-14 10:17:17 +02:00
parent 8fb780d83e
commit cfc3484e52
2 changed files with 10 additions and 4 deletions

View File

@ -48,7 +48,10 @@ SRCS = \
all: metrics.md metrics.html metrics.txt
metrics.tsv: ${SRCS}
ccsm --disable-file --disable-global --exclude-std-headers --exclude-file=.h$$ --output-format=tsv --output-metrics=HIS_.* $^ -- -DuECC_NO_DEFAULT_RNG -isystem ${C_HEADERS}/c90 -isystem ${C_HEADERS}/c99 ${INCLUDES} > $@
ccsm --disable-file --disable-global --exclude-std-headers --exclude-file=.h$$ --output-format=tsv --output-metrics=HIS_.* $^ -- -DuECC_NO_DEFAULT_RNG -isystem ${C_HEADERS}/c90 -isystem ${C_HEADERS}/c99 ${INCLUDES} > metrics_raw.tsv
echo "# file\tfunction\tGOTO\tRETURN\t_\tSTMT \t_\tCCN\tPATH\tCALLS\tPARAM\tLEVEL\t_\t_\t_" > metrics_header.tsv
cat metrics_header.tsv metrics_raw.tsv > $@
rm metrics_header.tsv metrics_raw.tsv
metrics.md: metrics.tsv metrics_ccsm.py
./metrics_ccsm.py > metrics.md
@ -57,8 +60,7 @@ metrics.html: metrics.md
pandoc --from markdown --to html -o metrics.html metrics.md
metrics.txt: metrics.tsv
echo "file\tfunction\tGOTO\tRETURN\t_\tSTMT \t_\tCCN\tPATH\tCALLS\tPARAM\tLEVEL\t_\t_\t_" > metrics_header.tsv
cat metrics_header.tsv metrics.tsv | expand -t 70,160,170,180,190,210,220,230,240,250,260,270,280,290,300 > metrics.txt
expand -t 70,160,170,180,190,210,220,230,240,250,260,270,280,290,300 metrics.tsv > metrics.txt
clean:
rm -f metrics.tsv metrics.md metrics.txt metrics.html metrics_header.tsv
rm -f metrics.tsv metrics.md metrics.txt metrics.html metrics_header.tsv metrics_raw.tsv

View File

@ -102,6 +102,10 @@ def analyze_folders(btstack_root, folders, metrics_file):
for row in rd:
file = ''
function_metrics = {}
# skip optional header
if row[0].startswith('#'):
continue
for key, value in zip(fields, row):
if key == 'file':
# get rid of directory traversal on buildbot