#!/bin/bash -e
# Highly opinionated wrapper for Arch Linux packaging

# Find the argument referencing the source directory
for arg in "$@" .; do
    if [[ $arg == [^-]* && -d $arg && -f $arg/meson.build ]]; then
        arch-meson-check-wraps "$arg"
        break;
    fi
done

set -x
exec meson setup \
  --prefix        /usr \
  --libexecdir    lib \
  --sbindir       bin \
  --buildtype     plain \
  --auto-features enabled \
  --wrap-mode     nodownload \
  -D              b_pie=true \
  -D              python.bytecompile=1 \
  "$@"
