diff --git a/scripts/_clone_or_pull.sh b/scripts/_clone_or_pull.sh new file mode 100755 index 0000000..c2aedee --- /dev/null +++ b/scripts/_clone_or_pull.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# exit on error +# echo commands +set -ev + +GIT_URL=$1 +REPO_DIR=$2 + +_usage() { + echo "Usage: $0 GIT_URL REPO_DIR" + exit 1 +} + +if [[ -z $REPO_DIR ]]; then + _usage +fi + +if [[ -z $GIT_URL ]]; then + _usage +fi + +if [[ -d "$REPO_DIR" ]]; then + if [[ ! -d "$REPO_DIR/.git" ]]; then + echo "Error: $REPO_DIR exists but is not a git repository" + exit 1 + fi + git -C "$REPO_DIR" pull +else + git clone "$GIT_URL" "$REPO_DIR" --recurse-submodules +fi diff --git a/scripts/build_libsurvive.sh b/scripts/build_libsurvive.sh new file mode 100755 index 0000000..c3a8776 --- /dev/null +++ b/scripts/build_libsurvive.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -ev + +REPO_DIR=$1 + +"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR" + +cd "$REPO_DIR" +mkdir -p build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_api_example=OFF -DCMAKE_SKIP_INSTALL_RPATH=YES -Wno-dev .. +make clean +make -j$(nproc) diff --git a/scripts/build_monado.sh b/scripts/build_monado.sh index a59bce7..55b73b9 100755 --- a/scripts/build_monado.sh +++ b/scripts/build_monado.sh @@ -6,20 +6,7 @@ set -ev REPO_DIR=$1 -if [[ -z $REPO_DIR ]]; then - echo "Usage: $0 MONADO_REPO_DIR" - exit 1 -fi - -if [[ -d "$REPO_DIR" ]]; then - if [[ ! -d "$REPO_DIR/.git" ]]; then - echo "Error: $REPO_DIR exists but is not a git repository" - exit 1 - fi - git -C "$REPO_DIR" pull -else - git clone https://gitlab.freedesktop.org/monado/monado "$REPO_DIR" -fi +"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR" cd "$REPO_DIR" mkdir -p build