ci: sync CI scripts with NFD

Notable changes include:
  - support WAF_JOBS env var
  - use two parallel build jobs on Travis-CI
  - use "limited builds" for code-coverage and Travis-CI
  - upgrade Travis-CI osx from xcode8.2 to xcode8.3
  - enable ASan on Travis-CI

Change-Id: I4101499ebc590478d67ec8134c0395c4aafb8fb6
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..358251d
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+set -e
+
+JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+source "$JDIR"/util.sh
+
+set -x
+
+git submodule init
+git submodule sync
+git submodule update
+
+# Cleanup
+sudo env "PATH=$PATH" ./waf --color=yes distclean
+
+if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
+  # Configure/build in debug mode with tests
+  ./waf --color=yes configure --with-tests --debug
+  ./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 optimized mode with tests
+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 --with-tests $COVERAGE $ASAN
+./waf --color=yes build -j${WAF_JOBS:-1}
+
+# (tests will be run against optimized version)
+
+# Install
+sudo env "PATH=$PATH" ./waf --color=yes install