-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·108 lines (88 loc) · 4 KB
/
build.sh
File metadata and controls
executable file
·108 lines (88 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# This script will "rebuild" html files based on the templates.
set -xe
export REPONAME="json"
export ORGANIZATION="boostorg"
GCOVRFILTER=".*/$REPONAME/.*"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/$REPONAME"
BOOST_CI_SRC_FOLDER=$(pwd)
outputlocation="$BOOST_CI_SRC_FOLDER/gcovr"
rm -rf $outputlocation || true
mkdir -p $outputlocation
if [[ -f "$BOOST_CI_SRC_FOLDER/coverage_filtered.info" ]]; then
# Local/macOS workaround: gcovr cannot read .gcda coverage files directly on macOS,
# so we convert the .info file (from lcov) to Cobertura XML format instead.
# The .info file contains absolute paths from the original build environment,
# which we auto-detect and rewrite to match the local machine's paths.
# Use 'boost-root' as anchor since it's consistently named across all builds
ORIGINAL_PATH=$(grep -m1 "^SF:" "$BOOST_CI_SRC_FOLDER/coverage_filtered.info" | sed 's|^SF:||' | sed 's|/boost-root/.*||')
TEMP_COVERAGE="/tmp/coverage_local.info"
TEMP_XML="/tmp/coverage.xml"
sed "s|$ORIGINAL_PATH|$SCRIPT_DIR|g" "$BOOST_CI_SRC_FOLDER/coverage_filtered.info" > "$TEMP_COVERAGE"
lcov_cobertura "$TEMP_COVERAGE" -o "$TEMP_XML"
sed -i.bak "s|filename=\"\.\./boost-root/|filename=\"$SCRIPT_DIR/boost-root/|g" "$TEMP_XML"
# Pass 1: Collect raw coverage as JSON
"$SCRIPT_DIR/scripts/gcovr_wrapper.py" \
--cobertura-add-tracefile "$TEMP_XML" \
--root "$SCRIPT_DIR" \
--merge-lines \
--json "$outputlocation/coverage-raw.json"
# Fix paths in JSON
python3 "$SCRIPT_DIR/scripts/fix_paths.py" \
"$outputlocation/coverage-raw.json" \
"$outputlocation/coverage-fixed.json" \
--repo "$REPONAME"
# Pass 2: Generate HTML from fixed JSON
"$SCRIPT_DIR/scripts/gcovr_wrapper.py" \
-a "$outputlocation/coverage-fixed.json" \
--html-nested \
--no-html-self-contained \
--html-template-dir "$SCRIPT_DIR/templates/html" \
--html-title "$REPONAME" \
--output "$outputlocation/index.html" \
--json-summary-pretty \
--json-summary "$outputlocation/summary.json"
# Copy font files to output directory
cp "$SCRIPT_DIR/templates/html/"*.woff2 "$outputlocation/"
# Generate tree.json for sidebar navigation
python3 "$SCRIPT_DIR/scripts/build_tree.py" "$outputlocation"
# Generate coverage badges
python3 "$SCRIPT_DIR/scripts/generate_badges.py" "$outputlocation" --json "$outputlocation/summary.json"
else
# CI/Linux: gcovr reads coverage data directly
cd ../boost-root
# Pass 1: Collect raw coverage as JSON
gcovr --merge-mode-functions separate -p \
--merge-lines \
--exclude-unreachable-branches \
--exclude-throw-branches \
--exclude '.*/test/.*' \
--exclude '.*/extra/.*' \
--filter "$GCOVRFILTER" \
--json "$outputlocation/coverage-raw.json"
# Fix paths in JSON
python3 "../scripts/fix_paths.py" \
"$outputlocation/coverage-raw.json" \
"$outputlocation/coverage-fixed.json" \
--repo "$REPONAME"
# Create symlinks so gcovr can find source files at repo-relative paths
ln -sfn "$BOOST_CI_SRC_FOLDER/include" "$(pwd)/include" 2>/dev/null || true
ln -sfn "$BOOST_CI_SRC_FOLDER/src" "$(pwd)/src" 2>/dev/null || true
# Pass 2: Generate HTML from fixed JSON
gcovr -a "$outputlocation/coverage-fixed.json" \
--html-nested \
--no-html-self-contained \
--html-template-dir=../templates/html \
--html-title "$REPONAME" \
--html \
--output "$outputlocation/index.html" \
--json-summary-pretty \
--json-summary "$outputlocation/summary.json"
# Copy font files to output directory
cp ../templates/html/*.woff2 "$outputlocation/"
# Generate tree.json for sidebar navigation
python3 "../scripts/build_tree.py" "$outputlocation"
# Generate coverage badges
python3 "../scripts/generate_badges.py" "$outputlocation" --json "$outputlocation/summary.json"
fi