Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use llvm-cov gcov in coverage #92

Merged
merged 1 commit into from
Sep 29, 2024
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
3 changes: 2 additions & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
USE_BAZEL_VERSION=7.3.0
# https://github.com/bazelbuild/bazel/issues/23247
USE_BAZEL_VERSION=7.1.2
28 changes: 28 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build --curses=yes
build --incompatible_strict_action_env
build --ui_actions_shown=20
build --progress_in_terminal_title
build --enable_platform_specific_config

build --@bazel_clang_format//:binary=@llvm19_toolchain//:clang-format
build --@bazel_clang_format//:config=//:format-config
Expand All @@ -32,4 +33,31 @@ coverage --combined_report=lcov
coverage --experimental_generate_llvm_lcov
coverage --instrumentation_filter=//rigid_geometric_algebra

# generate gcov format with llvm
#
# https://github.com/bazelbuild/bazel/issues/23247
# this currently requires Bazel < 7.2
#
# https://github.com/bazelbuild/bazel/blob/master/tools/test/collect_coverage.sh
# https://github.com/bazelbuild/bazel/blob/master/tools/test/collect_cc_coverage.sh
#
# disable use of llvm profdata
coverage:gcov --experimental_generate_llvm_lcov=false
# replace default coverage flags to generate gcov instead of profdata
#
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#compiling-with-coverage-enabled
# https://llvm.org/docs/CommandGuide/llvm-cov.html#id1
# https://github.com/bazel-contrib/toolchains_llvm/blob/4ab573b1b87a57791ef2f9ccee71cbad80a2abb9/toolchain/cc_toolchain_config.bzl#L264-L266
coverage:gcov --features=-coverage
coverage:gcov --copt=--coverage
coverage:gcov --linkopt=--coverage
coverage:gcov --test_env=COVERAGE_GCOV_PATH=./external/llvm19_toolchain_llvm/bin/llvm-cov
# https://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov
coverage:gcov --test_env=COVERAGE_GCOV_OPTIONS="-a -b -c -m -f"

# https://github.com/bazelbuild/bazel/issues/23719
coverage:macos --test_env=GCOV_PREFIX_STRIP=10

coverage --config=gcov

try-import %workspace%/user.bazelrc