Enable linux netlink event monitoring for Android OS platform services
[libusb.git] / .private / ci-build.sh
blob33dfb3b9835e4f05b9a912205760222423df4799
1 #!/bin/bash
3 set -e
5 builddir=
6 scriptdir=$(dirname $(readlink -f "$0"))
7 install=no
8 test=yes
9 asan=yes
11 while [ $# -gt 0 ]; do
12 case "$1" in
13 --build-dir)
14 if [ $# -lt 2 ]; then
15 echo "ERROR: missing argument for --build-dir option" >&2
16 exit 1
18 builddir=$2
19 shift 2
21 --install)
22 install=yes
23 shift
25 --no-test)
26 test=no
27 shift
29 --no-asan)
30 asan=no
31 shift
33 --)
34 shift
35 break;
38 echo "ERROR: Unexpected argument: $1" >&2
39 exit 1
40 esac
41 done
43 if [ -z "${builddir}" ]; then
44 echo "ERROR: --build-dir option not specified" >&2
45 exit 1
48 if [ -e "${builddir}" ]; then
49 echo "ERROR: directory entry named '${builddir}' already exists" >&2
50 exit 1
53 mkdir "${builddir}"
54 cd "${builddir}"
56 cflags="-O2"
58 # enable extra warnings
59 cflags+=" -Winline"
60 cflags+=" -Wmissing-include-dirs"
61 cflags+=" -Wnested-externs"
62 cflags+=" -Wpointer-arith"
63 cflags+=" -Wredundant-decls"
64 cflags+=" -Wswitch-enum"
66 # enable address sanitizer
67 if [ "${asan}" = "yes" ]; then
68 cflags+=" -fsanitize=address"
71 echo ""
72 echo "Configuring ..."
73 CFLAGS="${cflags}" CXXFLAGS="${cflags}" ../configure --enable-examples-build --enable-tests-build "$@"
75 echo ""
76 echo "Building ..."
77 make -j4 -k
79 if [ "${test}" = "yes" ]; then
80 # Load custom shim for WebUSB tests that simulates Web environment.
81 export NODE_OPTIONS="--require ${scriptdir}/../tests/webusb-test-shim/"
82 if ! make check ; then
83 cat tests/test-suite.log
84 exit 1
88 if [ "${install}" = "yes" ]; then
89 echo ""
90 echo "Installing ..."
91 make install