#!/bin/sh

set -e

REPO_URL="https://git.alnyan.me/yggdrasil/doomgeneric.git"
REPO_BRANCH="alnyan/yggdrasil"

build_dir=$3

mkdir -p "$build_dir"

if [ ! -f "$build_dir/.source-ready" ]; then
    cd "$build_dir"
    git clone --branch="$REPO_BRANCH" "$REPO_URL"
    ln -s "$Y_WORKSPACE_ROOT" "$build_dir/doomgeneric/doomgeneric/doomgeneric-yggdrasil/yggdrasil-root"
    touch "$build_dir/.source-ready"
fi
