blob: 7a5e60c5c6921d1ef7bb3343ddd87a84b489b04e [file] [log] [blame]
#!/usr/bin/env bash
#
# Copyright (c) 2016-2018 The Brenwill Workshop Ltd.
#
# fetchDependencies - Retrieves the correct versions of all dependencies
#
# macOS usage: ./fetchDependencies
#
# ----------------- Functions -------------------
# Update a repository. If it exists, fetch it, if not clone it.
# $1 repo name
# $2 repo url
# $3 repo revision (commit SHA)
update_repo() {
echo "$1 repo: $2"
echo "$1 revision: $3"
if [ -d $1 -a -d $1/.git ]; then
cd $1
git fetch --all
git checkout --force $3
cd -
else
rm -rf $1
git clone $2 $1
cd $1
git checkout $3
cd -
fi
}
# Build a repository
# $1 repo name
build_repo() {
echo "Building $1"
mkdir -p $1/build
cd $1/build
if type ninja >/dev/null 2>&1 ; then
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install ..
ninja
else
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install ..
make
fi
make install
cd -
}
# ----------------- Main -------------------
EXT_DIR=External
EXT_REV_DIR=ExternalRevisions
echo
echo Retrieving MoltenVK dependencies into ${EXT_DIR}.
echo
mkdir -p ${EXT_DIR}
cd ${EXT_DIR}
# ----------------- Cereal -------------------
REPO_NAME=cereal
REPO_URL="https://github.com/USCiLab/${REPO_NAME}.git"
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
# ----------------- Vulkan-Headers -------------------
REPO_NAME=Vulkan-Headers
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
# ----------------- SPIRV-Cross -------------------
REPO_NAME=SPIRV-Cross
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
# ----------------- glslang -------------------
REPO_NAME=glslang
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
cd ${REPO_NAME}
./update_glslang_sources.py
cd -
build_repo ${REPO_NAME}
# ----------------- Vulkan-Tools -------------------
REPO_NAME=Vulkan-Tools
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
# ----------------- VulkanSamples -------------------
REPO_NAME=VulkanSamples
REPO_URL="https://github.com/LunarG/${REPO_NAME}.git"
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
cd ..