#!/bin/bash
# Copyright © 2019 Collabora Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# (See debian/copyright)

set -e
set -u
set -x

# Test that we can compile a simple project using SDL3.

echo "1..1"

tmpdir="$(mktemp -d)"
cleanup () {
    if [ -z "${TEST_KEEP_RESULTS-}" ]; then
        rm -fr "$tmpdir"
    fi
}
trap cleanup 0 INT QUIT ABRT PIPE TERM

# Meson wants a real locale
export LC_ALL=C.UTF-8

meson setup "$tmpdir" "$(pwd)/examples/sdl3"
ninja -v -C "$tmpdir"

"$tmpdir/hello"

# /usr/share/pixmaps/debian-logo.png is part of the debconf package,
# which is installed by the SDK
xvfb-run -a "$tmpdir/showimage" -save "$tmpdir/out.bmp" -quit /usr/share/pixmaps/debian-logo.png

# Part of fonts-dejavu-core. --dump outputs to the current working directory,
# so cd into "$tmpdir" to run this.
env --chdir="$tmpdir" xvfb-run -a "$tmpdir/showfont" --dump /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf

ninja -v -C "$tmpdir" clean

echo "ok 1"

# vim:set sw=4 sts=4 et ft=sh:
