2020-01-28 07:20:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DATA_DIR=$HOME/.local/share/MangoHud
|
2020-01-29 10:35:42 +00:00
|
|
|
LAYER=build/release/usr/share/vulkan/implicit_layer.d/mangohud.json
|
2020-02-02 22:40:06 +00:00
|
|
|
INSTALL_DIR=build/package/MangoHud/.local/share
|
2020-01-28 07:20:23 +00:00
|
|
|
IMPLICIT_LAYER_DIR=$HOME/.local/share/vulkan/implicit_layer.d
|
2020-02-02 04:50:36 +00:00
|
|
|
DISTRO=$(sed 1q /etc/os-release | sed 's/NAME=//g' | sed 's/"//g')
|
2020-02-04 19:29:39 +00:00
|
|
|
VERSION=$(git describe --long --tags --always | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//')
|
2020-01-28 07:20:23 +00:00
|
|
|
|
2020-02-01 18:52:37 +00:00
|
|
|
dependencies() {
|
|
|
|
if [[ ! -f build/release/usr/lib64/libMangoHud.so ]]; then
|
|
|
|
missing_deps() {
|
|
|
|
echo "# Missing dependencies!"
|
|
|
|
echo "# Attempting to install '$INSTALL'"
|
|
|
|
}
|
2020-02-02 05:29:49 +00:00
|
|
|
install() {
|
|
|
|
for i in $(eval echo $DEPS); do
|
|
|
|
$MANAGER_QUERY $i &> /dev/null
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
INSTALL=$INSTALL" "$i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ! -z "$INSTALL" ]]; then
|
|
|
|
missing_deps
|
|
|
|
sudo $MANAGER_INSTALL $INSTALL
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
echo "# Checking Dependencies"
|
|
|
|
|
2020-02-01 18:52:37 +00:00
|
|
|
case $DISTRO in
|
|
|
|
"Arch Linux"|"Manjaro")
|
2020-02-02 05:29:49 +00:00
|
|
|
MANAGER_QUERY="pacman -Q"
|
|
|
|
MANAGER_INSTALL="pacman -S"
|
|
|
|
DEPS="{gcc,meson,pkgconf,python-mako,glslang,libglvnd,lib32-libglvnd}"
|
|
|
|
install
|
2020-02-03 10:09:24 +00:00
|
|
|
;;
|
2020-02-01 18:52:37 +00:00
|
|
|
"Fedora")
|
2020-02-02 05:29:49 +00:00
|
|
|
MANAGER_QUERY="dnf list installed"
|
|
|
|
MANAGER_INSTALL="dnf install"
|
|
|
|
DEPS="{meson,gcc,g++,libX11-devel,glslang,python-mako,mesa-libGL-devel}"
|
|
|
|
install
|
|
|
|
|
2020-02-02 04:50:36 +00:00
|
|
|
unset INSTALL
|
2020-02-02 05:29:49 +00:00
|
|
|
DEPS="{glibc-devel.i686,libstdc++-devel.i686,libX11-devel.i686}"
|
|
|
|
install
|
2020-02-03 10:09:24 +00:00
|
|
|
;;
|
2020-02-08 12:52:51 +00:00
|
|
|
*"buntu"|"Linux Mint"|"Debian"|"Zorin OS")
|
2020-02-08 12:47:41 +00:00
|
|
|
MANAGER_QUERY="dpkg-query -s"
|
2020-02-02 05:29:49 +00:00
|
|
|
MANAGER_INSTALL="apt install"
|
|
|
|
DEPS="{gcc,g++,gcc-multilib,g++-multilib,ninja-build,python3-pip,python3-setuptools,python3-wheel,pkg-config,mesa-common-dev,libx11-dev:i386}"
|
|
|
|
install
|
|
|
|
|
2020-02-05 18:27:49 +00:00
|
|
|
if [[ $(sudo pip3 show meson; echo $?) == 1 || $(sudo pip3 show mako; echo $?) == 1 ]]; then
|
2020-02-01 18:52:37 +00:00
|
|
|
sudo pip3 install meson mako
|
|
|
|
fi
|
|
|
|
if [[ ! -f /usr/local/bin/glslangValidator ]]; then
|
|
|
|
wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
|
|
|
|
unzip glslang-master-linux-Release.zip bin/glslangValidator
|
|
|
|
sudo install -m755 bin/glslangValidator /usr/local/bin/
|
|
|
|
rm bin/glslangValidator glslang-master-linux-Release.zip
|
|
|
|
fi
|
2020-02-03 10:09:24 +00:00
|
|
|
;;
|
2020-02-01 18:52:37 +00:00
|
|
|
*)
|
|
|
|
echo "# Unable to find distro information!"
|
|
|
|
echo "# Attempting to build regardless"
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-01-28 07:20:23 +00:00
|
|
|
configure() {
|
2020-02-01 18:52:37 +00:00
|
|
|
dependencies
|
|
|
|
git submodule update --init --depth 50
|
2020-02-05 20:01:28 +00:00
|
|
|
if [[ ! -f build/meson64/build.ninja ]]; then
|
2020-01-29 10:35:42 +00:00
|
|
|
meson build/meson64 --libdir lib64 --prefix $PWD/build/release/usr
|
2020-02-05 20:01:28 +00:00
|
|
|
fi
|
|
|
|
if [[ ! -f build/meson32/build.ninja ]]; then
|
2020-02-01 23:45:45 +00:00
|
|
|
export CC="gcc -m32"
|
|
|
|
export CXX="g++ -m32"
|
2020-02-02 04:50:36 +00:00
|
|
|
export PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:${PKG_CONFIG_PATH_32}"
|
2020-02-01 23:45:45 +00:00
|
|
|
export LLVM_CONFIG="/usr/bin/llvm-config32"
|
2020-01-29 10:35:42 +00:00
|
|
|
meson build/meson32 --libdir lib32 --prefix $PWD/build/release/usr
|
2020-01-28 07:20:23 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
2020-02-05 20:01:28 +00:00
|
|
|
if [[ ! -f build/meson64/build.ninja ]]; then
|
2020-02-03 10:09:24 +00:00
|
|
|
configure
|
|
|
|
fi
|
2020-01-28 07:20:23 +00:00
|
|
|
ninja -C build/meson32 install
|
|
|
|
ninja -C build/meson64 install
|
|
|
|
}
|
|
|
|
|
2020-02-02 22:40:06 +00:00
|
|
|
package() {
|
2020-02-05 20:01:28 +00:00
|
|
|
LIB=build/release/usr/lib64/libMangoHud.so
|
|
|
|
LIB32=build/release/usr/lib32/libMangoHud.so
|
|
|
|
if [[ ! -f "$LIB" || "$LIB" -ot build/meson64/src/libMangoHud.so ]]; then
|
2020-02-03 10:09:24 +00:00
|
|
|
build
|
|
|
|
fi
|
2020-02-02 22:40:06 +00:00
|
|
|
mkdir -p $INSTALL_DIR/{MangoHud,vulkan/implicit_layer.d}
|
2020-01-28 07:20:23 +00:00
|
|
|
|
2020-02-05 20:01:28 +00:00
|
|
|
cp $LIB32 $INSTALL_DIR/MangoHud/libMangoHud32.so
|
|
|
|
cp $LIB $INSTALL_DIR/MangoHud/libMangoHud.so
|
2020-02-02 22:40:06 +00:00
|
|
|
cp $LAYER $INSTALL_DIR/vulkan/implicit_layer.d/mangohud64.json
|
|
|
|
cp $LAYER $INSTALL_DIR/vulkan/implicit_layer.d/mangohud32.json
|
|
|
|
cp --preserve=mode bin/install.sh build/package/MangoHud/install.sh
|
|
|
|
sed -i "s|64bit|32bit|g" $INSTALL_DIR/vulkan/implicit_layer.d/mangohud32.json
|
2020-01-28 07:20:23 +00:00
|
|
|
|
2020-02-05 20:01:28 +00:00
|
|
|
tar -C build/package -cpzf build/MangoHud-$VERSION.tar.gz .
|
2020-01-28 07:20:23 +00:00
|
|
|
}
|
|
|
|
|
2020-02-02 22:40:06 +00:00
|
|
|
install() {
|
2020-02-05 20:01:28 +00:00
|
|
|
PKG=build/MangoHud-$VERSION.tar.gz
|
|
|
|
if [[ ! -f "$PKG" || "$PKG" -ot build/meson64/src/libMangoHud.so ]]; then
|
2020-02-03 22:03:21 +00:00
|
|
|
package
|
|
|
|
fi
|
2020-02-02 22:40:06 +00:00
|
|
|
tar xzf build/MangoHud-$VERSION.tar.gz --exclude='install.sh' --strip-components=2 -C $HOME/
|
|
|
|
sed -i "s|libMangoHud.so|$HOME/.local/share/MangoHud/libMangoHud32.so|g" $HOME/.local/share/vulkan/implicit_layer.d/mangohud32.json
|
|
|
|
sed -i "s|libMangoHud.so|$HOME/.local/share/MangoHud/libMangoHud.so|g" $HOME/.local/share/vulkan/implicit_layer.d/mangohud64.json
|
2020-01-29 10:35:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-28 07:20:23 +00:00
|
|
|
clean() {
|
2020-02-01 18:52:37 +00:00
|
|
|
rm -rf build
|
2020-01-28 07:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uninstall() {
|
|
|
|
rm -r $HOME/.local/share/MangoHud
|
|
|
|
rm $IMPLICIT_LAYER_DIR/{mangohud64,mangohud32}.json
|
|
|
|
}
|
|
|
|
|
2020-02-03 10:09:24 +00:00
|
|
|
for a in $@; do
|
|
|
|
case $a in
|
2020-02-03 22:03:21 +00:00
|
|
|
"") build;;
|
2020-02-03 10:09:24 +00:00
|
|
|
"pull") git pull;;
|
|
|
|
"configure") configure;;
|
2020-02-03 22:03:21 +00:00
|
|
|
"build") build;;
|
2020-02-03 10:09:24 +00:00
|
|
|
"package") package;;
|
2020-02-03 22:03:21 +00:00
|
|
|
"install") install;;
|
2020-02-03 10:09:24 +00:00
|
|
|
"clean") clean;;
|
|
|
|
"uninstall") uninstall;;
|
|
|
|
*)
|
|
|
|
echo "Unrecognized command argument: $a"
|
|
|
|
echo 'Accepted arguments: "pull", "configure", "build", "package", "install", "clean", "uninstall".'
|
|
|
|
esac
|
|
|
|
done
|