catalog: add logging and fix bugs

* use user-friendly messages
* fix help output

refs: #3189

Change-Id: I33dcb1a9c806d01c6665e0ef941d5b4f1d64774f
diff --git a/.jenkins.d/20-build.sh b/.jenkins.d/20-build.sh
index 76f827e..1b0b972 100755
--- a/.jenkins.d/20-build.sh
+++ b/.jenkins.d/20-build.sh
@@ -2,6 +2,8 @@
 set -x
 set -e
 
+COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
+
 # Cleanup
 sudo ./waf -j1 --color=yes distclean
 
@@ -20,7 +22,7 @@
 sudo ./waf -j1 --color=yes distclean
 
 # Configure/build in optimized mode
-./waf -j1 --color=yes configure --with-tests
+./waf -j1 --color=yes configure --with-tests $COVERAGE
 ./waf -j1 --color=yes build
 
 # (tests will be run against optimized version)
diff --git a/.jenkins.d/40-coverage.sh b/.jenkins.d/40-coverage.sh
new file mode 100755
index 0000000..1c80a9c
--- /dev/null
+++ b/.jenkins.d/40-coverage.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+IS_COVR=$( python -c "print 'yes' if 'code-coverage' in '$JOB_NAME' else 'no'" )
+
+if [[ $IS_COVR == "yes" ]]; then
+  BASE="`pwd | sed -e 's|/|\\\/|g'`\\"
+  (cd build && gcovr -x -f $BASE/catalog/src -r ../ -o coverage.xml ./)
+fi