#! /bin/bash

CACHE=/tmp/fggl/
LOG=$CACHE/demo.log
EXE="../build/demo/FgglDemo"

if [[ ! -d "build/" ]]
then
	mkdir build
fi

if [ ! -x "$(command -v cmake)" ]; then
	sudo dnf install -y cmake extra-cmake-modules
	sudo dnf install -y wayland-devel libxkbcommon-devel wayland-protocols-devel
	sudo dnf install -y glew-devel glm-devel
fi

# if doing shader development, disable the cache to make sure changes take affect
rm -rf $CACHE

#
# build step
#
pushd build
cmake ..
make
popd

#
# additional stuff
#

# gamemoderun
if [ -x "$(command -v gamemoderun)" ]; then
	EXE="gamemoderun $EXE"
fi

# mangohud
if [ -x "$(command -v mangohud)" ]; then
	EXE="mangohud --dlsym $EXE"
fi

pushd demo
$EXE ../build/demo/FgglDemo
popd
