]> git.mdlowis.com Git - proto/labwc.git/commitdiff
tools/build: add some options
authorJohan Malm <jgm323@gmail.com>
Fri, 14 Aug 2020 21:39:23 +0000 (22:39 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 14 Aug 2020 21:39:23 +0000 (22:39 +0100)
tools/asan_suppressions.txt
tools/build

index 8ed61702a8d7fa2bd475fc763f42caac2054bba9..0e14a2054f4d8863850c01b7851217604b54f69c 100644 (file)
@@ -1,3 +1,3 @@
 leak:libfontconfig
 leak:libglib-2.0
-
+leak:libxcb*
index 0a23dc90773e6410bcdfc00c131e30a7ad7d436a..97c081f01fad3eb6abff49e3d0959eb2817957a5 100755 (executable)
@@ -3,17 +3,57 @@
 # Automatically build labwc
 #
 
-builddir=build-clang
+builddir=build
+g_asan=
+g_wlroots=
 
-if ! [ -e subprojects/wlroots ]; then
-       git clone https://github.com/swaywm/wlroots subprojects/wlroots
-fi
+die () { printf '\033[31mfatal:\033[m %b\n' "$@" >&2 ; exit 1 ; }
+warn () { printf '\033[31mwarn:\033[m %b\n' "$@" >&2 ; }
+say () { printf '\033[32m%s\033[m' "$@" ; }
 
+usage () {
+       printf "%s\n" \
+"Usage: ./tools/build [<options>]
+Options:
+-w             install wlroots as subproject
+--asan         run with ASAN and UBSAN
+--clang        run with clang
+-h, --help     show help"
+       exit 0
+}
 
-if ! [ -e ${builddir} ]; then
-       CC=clang meson -Dwlroots:default_library=static ${builddir}
-       # To enable ASAN and UBSAN, run meson with
-       # `-Db_sanitize=address,undefined`
-fi
+wlroots_subproject () {
+       if ! [ -e subprojects/wlroots ]; then
+               git clone https://github.com/swaywm/wlroots subprojects/wlroots
+       fi
+}
 
-ninja -C ${builddir}
+main () {
+       [[ -e src/main.c ]] || die "must be run from top-level directory"
+
+       for arg
+       do
+               opt=${arg%%=*}
+               var=${arg#*=}
+               case "$opt" in
+               -w)
+                       wlroots_subproject
+                       g_wlroots="-Dwlroots:default_library=static"
+                       ;;
+               --asan)
+                       g_asan="-Db_sanitize=address,undefined" ;;
+               --clang)
+                       export CC=clang
+                       ;;
+               -h|--help)
+                       usage ;;
+               esac
+       done
+
+       [ -e ${builddir} ] && die "build directory already exists - delete and run again"
+       meson ${g_asan} ${g_wlroots} ${builddir}
+       ninja -C ${builddir}
+       LSAN_OPTIONS=suppressions=../tools/asan_suppressions.txt ninja -C ${builddir} test
+}
+
+main "$@"