Add optional coverage flags to build
This CL allows generating coverage information for the source files. By adding
use_coverage=true to the GN build settings clang will generate .gcno files for
each source file and executing the binary will generate a .gcda file for
each source file.
Those files can then be processed by llvm-cov to generate .gcov reports for each
source file.
i.e. (assuming use_coverage=true is set for out/coverage)
* ninja -C out/coverage pdfium_unittests
* cd out/coverage
* find obj -name "*.o" -exec llvm-cov -af -stats {} > d.out \;
There should now be .gcov files for each source file in the out/coverage
directory.
Note, llvm-gcov may have a different name or syntax on your machine.
Change-Id: I7379579f5f20a5b8b2f3a3b409b868bba4b4d74d
Reviewed-on: https://pdfium-review.googlesource.com/2216
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index fbede10..fccc6d7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -42,6 +42,7 @@
config("pdfium_core_config") {
cflags = []
+ ldflags = []
configs = [ ":pdfium_common_config" ]
defines = [ "V8_DEPRECATION_WARNINGS" ]
if (is_linux) {
@@ -55,6 +56,14 @@
if (is_win) {
cflags += [ "/wd4267" ]
}
+ if (use_coverage && is_clang) {
+ cflags += [
+ "--coverage",
+ "-g",
+ "-O0",
+ ]
+ ldflags += [ "--coverage" ]
+ }
}
config("xfa_warnings") {
diff --git a/pdfium.gni b/pdfium.gni
index df051ec..5737224 100644
--- a/pdfium.gni
+++ b/pdfium.gni
@@ -28,4 +28,7 @@
# Build PDFium standalone
pdf_is_standalone = false
+
+ # Enable coverage information
+ use_coverage = false
}