From da489976371eb928d8b4d004744667fdf82b90d4 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 17 Jan 2017 10:12:55 -0500 Subject: 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 Reviewed-by: Tom Sepez --- BUILD.gn | 9 +++++++++ pdfium.gni | 3 +++ 2 files changed, 12 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index fbede10eb0..fccc6d7900 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -42,6 +42,7 @@ config("pdfium_common_config") { config("pdfium_core_config") { cflags = [] + ldflags = [] configs = [ ":pdfium_common_config" ] defines = [ "V8_DEPRECATION_WARNINGS" ] if (is_linux) { @@ -55,6 +56,14 @@ config("pdfium_core_config") { 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 df051eca81..5737224f70 100644 --- a/pdfium.gni +++ b/pdfium.gni @@ -28,4 +28,7 @@ declare_args() { # Build PDFium standalone pdf_is_standalone = false + + # Enable coverage information + use_coverage = false } -- cgit v1.2.3