#!/bin/sh # # Automatically build labwc # builddir=build g_asan= g_wlroots= 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: -w install wlroots as subproject --asan run with ASAN and UBSAN --clang run with clang -h, --help show help" exit 0 } wlroots_subproject () { if ! [ -e subprojects/wlroots ]; then git clone https://github.com/swaywm/wlroots subprojects/wlroots fi } 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 "$@"