Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Generated coverage reports
# json/gcovr/
# json/gcovr-lcov/
# json/gcovr-output/

# Claude Code
.claude/

# Temp files
*.bak
48 changes: 42 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,51 @@ export REPONAME="json"
export ORGANIZATION="boostorg"
GCOVRFILTER=".*/$REPONAME/.*"

cd "$REPONAME"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/$REPONAME"
BOOST_CI_SRC_FOLDER=$(pwd)

cd ../boost-root

outputlocation="$BOOST_CI_SRC_FOLDER/gcovr"
outputlocation="/mnt/c/output"
rm -rf $outputlocation || true

mkdir -p $outputlocation

gcovr --merge-mode-functions separate -p --html-nested --html-template-dir=..\templates --exclude-unreachable-branches --exclude-throw-branches --exclude '.*/test/.*' --exclude '.*/extra/.*' --filter "$GCOVRFILTER" --html --output "$outputlocation/index.html"
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"

"$SCRIPT_DIR/scripts/gcovr_wrapper.py" \
--cobertura-add-tracefile "$TEMP_XML" \
--root "$SCRIPT_DIR" \
--html-nested \
--html-template-dir "$SCRIPT_DIR/templates/html" \
--output "$outputlocation/index.html"

# Generate tree.json for sidebar navigation
python3 "$SCRIPT_DIR/scripts/build_tree.py" "$outputlocation"
else
# CI/Linux: gcovr reads coverage data directly
cd ../boost-root
gcovr --merge-mode-functions separate -p \
--html-nested \
--html-template-dir=../templates/html \
--exclude-unreachable-branches \
--exclude-throw-branches \
--exclude '.*/test/.*' \
--exclude '.*/extra/.*' \
--filter "$GCOVRFILTER" \
--html \
--output "$outputlocation/index.html"

# Generate tree.json for sidebar navigation
python3 "../scripts/build_tree.py" "$outputlocation"
fi
Loading