2018-03-12 10:02:13 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Copyright (c) 2016-2018 The Brenwill Workshop Ltd.
|
|
|
|
#
|
|
|
|
# fetchDependencies - Retrieves the correct versions of all dependencies
|
|
|
|
#
|
2018-04-02 15:02:00 -06:00
|
|
|
# macOS usage: ./fetchDependencies [--v-lvl-root path] [--glslang-root path]
|
2018-03-12 10:02:13 -04:00
|
|
|
#
|
2018-04-02 15:02:00 -06:00
|
|
|
# --v-lvl-root path
|
|
|
|
# "path" specifies a directory path to a
|
|
|
|
# KhronosGroup/Vulkan-LoaderAndValidationLayers repository.
|
|
|
|
# This repository does not have to be built.
|
|
|
|
# --glslang-root path
|
|
|
|
# "path" specifies a directory path to a KhronosGroup/glslang
|
|
|
|
# repository. This repository does need to be built and the
|
|
|
|
# build directory must be in the specified directory.
|
|
|
|
# It should be built the same way this script builds it.
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
# ----------------- Functions -------------------
|
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
# Update a repository. If it exists, fetch it, if not clone it.
|
2018-03-12 10:02:13 -04:00
|
|
|
# $1 repo name
|
|
|
|
# $2 repo url
|
|
|
|
# $3 repo revision (commit SHA)
|
2018-03-30 22:16:27 -04:00
|
|
|
update_repo() {
|
2018-03-12 10:02:13 -04:00
|
|
|
echo "$1 repo: $2"
|
|
|
|
echo "$1 revision: $3"
|
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
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
|
2018-03-12 10:02:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Build a repository
|
|
|
|
# $1 repo name
|
|
|
|
build_repo() {
|
|
|
|
echo "Building $1"
|
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
mkdir -p $1/build
|
2018-03-12 10:02:13 -04:00
|
|
|
cd $1/build
|
2018-04-04 20:48:21 +02:00
|
|
|
if type ninja >/dev/null 2>&1 ; then
|
|
|
|
cmake .. -G Ninja
|
|
|
|
ninja
|
|
|
|
else
|
|
|
|
cmake ..
|
|
|
|
make
|
|
|
|
fi
|
2018-03-12 10:02:13 -04:00
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
# ----------------- Main -------------------
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
EXT_DIR=External
|
|
|
|
EXT_REV_DIR=ExternalRevisions
|
2018-03-12 10:02:13 -04:00
|
|
|
V_LVL_NAME=Vulkan-LoaderAndValidationLayers
|
|
|
|
GLSLANG_NAME=glslang
|
2018-04-02 15:02:00 -06:00
|
|
|
V_LVL_ROOT=""
|
|
|
|
GLSLANG_ROOT=""
|
|
|
|
|
|
|
|
while (( "$#" )); do
|
|
|
|
case "$1" in
|
|
|
|
--v-lvl-root)
|
|
|
|
V_LVL_ROOT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--glslang-root)
|
|
|
|
GLSLANG_ROOT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-*|--*=)
|
|
|
|
echo "Error: Unsupported flag $1" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
echo
|
|
|
|
echo Retrieving MoltenVK dependencies into ${EXT_DIR}.
|
|
|
|
echo
|
|
|
|
|
|
|
|
mkdir -p ${EXT_DIR}
|
|
|
|
cd ${EXT_DIR}
|
|
|
|
|
2018-03-30 12:13:50 -04:00
|
|
|
# ----------------- Cereal -------------------
|
|
|
|
|
|
|
|
REPO_NAME=cereal
|
|
|
|
REPO_URL="https://github.com/USCiLab/${REPO_NAME}.git"
|
2018-03-30 22:16:27 -04:00
|
|
|
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-03-30 12:13:50 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-03-30 12:13:50 -04:00
|
|
|
|
|
|
|
|
2018-03-12 10:02:13 -04:00
|
|
|
# ----------------- SPIRV-Cross -------------------
|
|
|
|
|
|
|
|
REPO_NAME=SPIRV-Cross
|
|
|
|
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
|
2018-03-30 22:16:27 -04:00
|
|
|
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
# ----------------- VulkanSamples -------------------
|
|
|
|
|
|
|
|
REPO_NAME=VulkanSamples
|
2018-04-18 11:06:47 -04:00
|
|
|
REPO_URL="https://github.com/LunarG/${REPO_NAME}.git"
|
2018-03-30 22:16:27 -04:00
|
|
|
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
|
2018-04-02 15:02:00 -06:00
|
|
|
# ----------------- Vulkan-LoaderAndValidationLayers -------------------
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-04-02 15:02:00 -06:00
|
|
|
# When MoltenVK is built by something that already has a copy of the
|
|
|
|
# Vulkan-LoaderAndValidationLayers repo, use it by creating a symlink.
|
|
|
|
if [ ! "$V_LVL_ROOT" = "" ]; then
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
REPO_NAME=${V_LVL_NAME}
|
|
|
|
rm -rf ${REPO_NAME}
|
2018-04-02 15:02:00 -06:00
|
|
|
ln -sfn ${V_LVL_ROOT} ${REPO_NAME}
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
REPO_NAME=${V_LVL_NAME}
|
|
|
|
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
|
2018-03-30 22:16:27 -04:00
|
|
|
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
cd ${REPO_NAME}
|
2018-04-16 16:26:34 -04:00
|
|
|
./update_external_sources.sh -g
|
2018-03-12 10:02:13 -04:00
|
|
|
cd -
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
cd ..
|
|
|
|
|