If the ninja build system is installed, ask CMake to generate Ninja build files and use it for the build.
170 lines
3.6 KiB
Bash
Executable File
170 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2016-2018 The Brenwill Workshop Ltd.
|
|
#
|
|
# fetchDependencies - Retrieves the correct versions of all dependencies
|
|
#
|
|
# macOS usage: ./fetchDependencies [--v-lvl-root path] [--glslang-root path]
|
|
#
|
|
# --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.
|
|
|
|
|
|
# ----------------- 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
|
|
ninja
|
|
else
|
|
cmake ..
|
|
make
|
|
fi
|
|
cd -
|
|
}
|
|
|
|
|
|
# ----------------- Main -------------------
|
|
|
|
EXT_DIR=External
|
|
EXT_REV_DIR=ExternalRevisions
|
|
V_LVL_NAME=Vulkan-LoaderAndValidationLayers
|
|
GLSLANG_NAME=glslang
|
|
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
|
|
|
|
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}
|
|
|
|
|
|
# ----------------- 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}
|
|
|
|
|
|
# ----------------- VulkanSamples -------------------
|
|
|
|
REPO_NAME=VulkanSamples
|
|
REPO_URL="https://github.com/brenwill/${REPO_NAME}.git"
|
|
REPO_REV=$(cat "../${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
|
|
|
|
|
# ----------------- Vulkan-LoaderAndValidationLayers -------------------
|
|
|
|
# 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
|
|
|
|
REPO_NAME=${V_LVL_NAME}
|
|
rm -rf ${REPO_NAME}
|
|
ln -sfn ${V_LVL_ROOT} ${REPO_NAME}
|
|
|
|
else
|
|
|
|
REPO_NAME=${V_LVL_NAME}
|
|
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}
|
|
|
|
fi
|
|
|
|
# ----------------- glslang, SPIRV-Tools & SPIRV-Headers -------------------
|
|
|
|
# When MoltenVK is built by something that already has a copy of the
|
|
# glslang repo, use it by creating a symlink.
|
|
if [ ! "$GLSLANG_ROOT" = "" ]; then
|
|
|
|
REPO_NAME=${GLSLANG_NAME}
|
|
rm -rf ${REPO_NAME}
|
|
ln -sfn ${GLSLANG_ROOT} ${REPO_NAME}
|
|
|
|
else
|
|
|
|
REPO_NAME=${GLSLANG_NAME}
|
|
REPO_URL=$(cat "${V_LVL_NAME}/external_revisions/glslang_giturl")
|
|
REPO_REV=$(cat "${V_LVL_NAME}/external_revisions/glslang_revision")
|
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
|
|
|
cd ${REPO_NAME}
|
|
./update_glslang_sources.py
|
|
cd -
|
|
|
|
build_repo ${REPO_NAME}
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|