build+ci: update scripts

Change-Id: Ica98e8b64c26cfeb0c45f18b086ae87c28ca3dbc
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..08d2d53
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+# Cleanup
+sudo env "PATH=$PATH" ./waf --color=yes distclean
+
+if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
+  # Configure/build in optimized mode with tests
+  ./waf --color=yes configure --with-tests
+  ./waf --color=yes build -j${WAF_JOBS:-1}
+
+  # Cleanup
+  sudo env "PATH=$PATH" ./waf --color=yes distclean
+
+  # Configure/build in optimized mode without tests
+  ./waf --color=yes configure
+  ./waf --color=yes build -j${WAF_JOBS:-1}
+
+  # Cleanup
+  sudo env "PATH=$PATH" ./waf --color=yes distclean
+fi
+
+# Configure/build in debug mode with tests and without precompiled headers
+if [[ $JOB_NAME == *"code-coverage" ]]; then
+    COVERAGE="--with-coverage"
+elif [[ -n $BUILD_WITH_ASAN || -z $TRAVIS ]]; then
+    ASAN="--with-sanitizer=address"
+fi
+./waf --color=yes configure --debug --with-tests --without-pch $COVERAGE $ASAN
+./waf --color=yes build -j${WAF_JOBS:-1}
+
+# (tests will be run against debug version)
+
+# Install
+sudo env "PATH=$PATH" ./waf --color=yes install
+
+if has Linux $NODE_LABELS; then
+    sudo ldconfig
+elif has FreeBSD $NODE_LABELS; then
+    sudo ldconfig -a
+fi