| #!/usr/bin/env bash |
| # |
| # Copyright (c) 2016-2018 The Brenwill Workshop Ltd. |
| # |
| # fetchDependencies - Retrieves the correct versions of all dependencies |
| # |
| # macOS usage: ./fetchDependencies [-sdk] |
| # |
| # -sdk = Load for the LunarG SDK, using symlinks to repos in SDK instead of fetching |
| # Vulkan-LoaderAndValidationLayers and glslang repositories. |
| |
| |
| # ----------------- 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 |
| cmake .. |
| make |
| cd - |
| } |
| |
| |
| # ----------------- Main ------------------- |
| |
| EXT_DIR=External |
| EXT_REV_DIR=ExternalRevisions |
| V_LVL_NAME=Vulkan-LoaderAndValidationLayers |
| GLSLANG_NAME=glslang |
| |
| 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, glslang, SPIRV-Tools & SPIRV-Headers ------------------- |
| |
| # When MoltenVK is loaded as a dependency of the LunarG SDK, the LunarG SDK already |
| # has Vulkan-LoaderAndValidationLayers & glslang, so create simlinks instead. |
| if [ "$1" = "-sdk" ]; then |
| |
| REPO_NAME=${V_LVL_NAME} |
| rm -rf ${REPO_NAME} |
| ln -sfn ../../.. ${REPO_NAME} |
| |
| REPO_NAME=${GLSLANG_NAME} |
| rm -rf ${REPO_NAME} |
| ln -sfn ../../${REPO_NAME} ${REPO_NAME} |
| |
| else |
| |
| # ----------------- Vulkan-LoaderAndValidationLayers ------------------- |
| |
| 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} |
| |
| |
| # ----------------- glslang, SPIRV-Tools & SPIRV-Headers --------------- |
| |
| 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 .. |
| |