From f66a4e996ea8f4dcd6bafed4952b3cd99129d464 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 19 May 2016 20:23:20 +0200 Subject: [PATCH] feat(build): Add simple helper script --- build.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..34e069a0 --- /dev/null +++ b/build.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +function msg_err { + printf "\033[41;30m err \033[0m %s\n" "$@" + exit 1 +} + +function msg { + printf "\033[36;1m info \033[0m%s\n" "$@" +} + +function main +{ + [[ -d ./build ]] && msg_err "A build directory already exists" + [[ -d ./.git ]] && { + git submodule update --init --recursive || msg_err "Failed to clone submodules" + } + + mkdir ./build || msg_err "Failed to create build dir" + cd ./build || msg_err "Failed to enter build dir" + + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. || \ + msg_err "Failed to generate build... read output to get a hint of what went wrong" + + make || msg_err "Failed to build project" + + echo -e "\n" + + read -N1 -p "Do you want to execute \"sudo make install\"? [Y/n] " -r choice + + if [[ "${choice^^}" == "Y" ]]; then + sudo make install || msg_err "Failed to install executables..." + fi +} + +main "$@"