#! /bin/bash

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

if [[ ! -d "builds/cli/" ]]
then
	mkdir -p builds/cli
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 builds/cli
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
popd