#!/bin/bash
#
# Build docs and choke on gi-docgen warnings

DIR="${1:-_build}"
LOG="${DIR}/docs/doc-build.log"

meson compile -C "${DIR}" docs/phosh-doc |& tee "${LOG}"

if grep -vE  '('\
'src/dbus/phosh-[a-z\-]+-dbus.h:[0-9]+: Warning: Phosh: Unknown namespace for identifier .pending.'\
'|src/settings/audio-devices.h:[0-9]+: Warning: Phosh: phosh_audio_devices_new: argument mixer: Unresolved type: .GvcMixerControl'\
')' "${LOG}" | grep -i 'warning:'; then
    exit 1
fi
