2020-04-12 12:53:17 -04:00
|
|
|
#!/bin/bash
|
2018-03-12 10:02:13 -04:00
|
|
|
#
|
2023-01-13 12:19:37 -05:00
|
|
|
# Copyright (c) 2016-2023 The Brenwill Workshop Ltd.
|
2018-03-12 10:02:13 -04:00
|
|
|
#
|
|
|
|
# fetchDependencies - Retrieves the correct versions of all dependencies
|
|
|
|
#
|
2020-09-01 14:39:46 -04:00
|
|
|
# macOS usage: ./fetchDependencies [--macos] [--ios] [--iossim] [--tvos] [--tvossim] [--all] [--none]
|
2020-06-17 19:10:33 -04:00
|
|
|
# [-v] [--debug] [--build-spirv-tools]
|
2019-06-16 12:00:22 -04:00
|
|
|
# [--v-headers-root path] [--spirv-cross-root path] [--glslang-root path]
|
2018-06-21 15:37:27 -06:00
|
|
|
#
|
2020-09-01 14:39:46 -04:00
|
|
|
# --macos
|
|
|
|
# Build the external libraries for the macOS platform.
|
|
|
|
#
|
2020-06-17 19:10:33 -04:00
|
|
|
# --ios
|
|
|
|
# Build the external libraries for the iOS platform.
|
|
|
|
#
|
2020-09-01 14:39:46 -04:00
|
|
|
# --iossim
|
|
|
|
# Build the external libraries for the iOS Simulator platform.
|
2020-06-17 19:10:33 -04:00
|
|
|
#
|
2020-11-30 18:52:34 -05:00
|
|
|
# --maccat
|
|
|
|
# Build the external libraries for the Mac Catalyst platform.
|
|
|
|
#
|
2020-06-19 15:05:43 -04:00
|
|
|
# --tvos
|
|
|
|
# Build the external libraries for the tvOS platform.
|
|
|
|
#
|
2020-09-01 14:39:46 -04:00
|
|
|
# --tvossim
|
|
|
|
# Build the external libraries for the tvOS Simulator platform.
|
2020-06-17 19:10:33 -04:00
|
|
|
#
|
|
|
|
# --all
|
2020-11-30 18:52:34 -05:00
|
|
|
# Equivalent to specifying [--macos --ios --iossim --maccat --tvos --tvossim].
|
2020-09-01 14:39:46 -04:00
|
|
|
# Results in one XCFramework for each external library, each containing
|
|
|
|
# binaries for all supported platforms.
|
2020-06-17 19:10:33 -04:00
|
|
|
#
|
2020-07-27 22:25:44 -04:00
|
|
|
# --none
|
2021-02-22 19:14:00 -05:00
|
|
|
# Don't build the external libraries for any platform (this is the default).
|
2020-07-27 22:25:44 -04:00
|
|
|
#
|
2020-06-19 15:05:43 -04:00
|
|
|
# Multiple platform options may be specified. At least one platform option must be specified.
|
2020-06-17 19:10:33 -04:00
|
|
|
#
|
2020-10-07 20:59:18 -05:00
|
|
|
# --asan
|
|
|
|
# Build the external libraries against Address Sanitizer, which may be useful when debugging
|
|
|
|
# and tracing calls into those libraries.
|
|
|
|
#
|
|
|
|
# --tsan
|
|
|
|
# Build the external libraries against Thread Sanitizer, which may be useful when debugging
|
|
|
|
# and tracing calls into those libraries.
|
|
|
|
#
|
|
|
|
# --ubsan
|
|
|
|
# Build the external libraries against Undefined Behavior Sanitizer, which may be useful when debugging
|
|
|
|
# and tracing calls into those libraries.
|
|
|
|
#
|
2019-06-16 12:00:22 -04:00
|
|
|
# --debug
|
|
|
|
# Build the external libraries in Debug mode, which may be useful when debugging
|
|
|
|
# and tracing calls into those libraries.
|
|
|
|
#
|
2020-09-23 14:55:13 -04:00
|
|
|
# --parallel-build
|
|
|
|
# Build the external libraries in parallel using background processes.
|
|
|
|
#
|
2020-06-22 00:00:00 -04:00
|
|
|
# --no-parallel-build
|
2020-09-23 14:55:13 -04:00
|
|
|
# Build the external libraries serially instead of in parallel. This is the default.
|
2020-06-22 00:00:00 -04:00
|
|
|
#
|
2019-06-16 12:00:22 -04:00
|
|
|
# --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.
|
|
|
|
#
|
2020-06-02 13:30:52 -04:00
|
|
|
# --build-spirv-tools
|
|
|
|
# Build the full spirv-tools distribution. Normally this is not needed, because
|
|
|
|
# MoltenVK includes a template of pre-generated SPIRV-Tools header files, which
|
|
|
|
# is all that is needed. Avoiding the spirv-tools build saves significant time
|
|
|
|
# during the running of this script, and is necessary during CI because Travis CI
|
|
|
|
# cannot support the required use of Python3 by the spirv-tools build. This flag
|
|
|
|
# is used by the packagePregenSpirvToolsHeaders script which regenerates the
|
|
|
|
# spirv-tools header files and repackages the Templates/spirv-tools/build.zip
|
|
|
|
# file when the spirv-tools library version is upgraded.
|
2018-06-21 15:37:27 -06:00
|
|
|
#
|
|
|
|
# --spirv-cross-root path
|
2019-06-16 12:00:22 -04:00
|
|
|
# "path" specifies a directory path to a KhronosGroup/SPIRV-Cross repository.
|
2018-06-21 15:37:27 -06:00
|
|
|
# This repository does not have to be built.
|
|
|
|
#
|
2018-12-24 22:15:23 -05:00
|
|
|
# -v verbose output
|
2018-03-12 10:02:13 -04:00
|
|
|
#
|
2019-06-16 12:00:22 -04:00
|
|
|
# --v-headers-root path
|
|
|
|
# "path" specifies a directory path to a KhronosGroup/Vulkan-Headers repository.
|
|
|
|
# This repository does not have to be built.
|
2019-04-18 15:08:39 -04:00
|
|
|
#
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2020-04-12 12:53:17 -04:00
|
|
|
set -e
|
2018-03-12 10:02:13 -04:00
|
|
|
|
|
|
|
# ----------------- Functions -------------------
|
|
|
|
|
2020-07-27 22:25:44 -04:00
|
|
|
BLD_NONE=""
|
2020-06-17 19:10:33 -04:00
|
|
|
BLD_IOS=""
|
|
|
|
BLD_IOS_SIM=""
|
2020-11-30 18:52:34 -05:00
|
|
|
BLD_MAC_CAT=""
|
2020-06-19 15:05:43 -04:00
|
|
|
BLD_TVOS=""
|
|
|
|
BLD_TVOS_SIM=""
|
2020-06-17 19:10:33 -04:00
|
|
|
BLD_MACOS=""
|
|
|
|
BLD_SPECIFIED=""
|
|
|
|
XC_CONFIG="Release"
|
2018-12-24 22:15:23 -05:00
|
|
|
XC_BUILD_VERBOSITY="-quiet"
|
2020-09-23 14:55:13 -04:00
|
|
|
XC_USE_BCKGND=""
|
2020-10-07 20:59:18 -05:00
|
|
|
XC_USE_ASAN="NO"
|
|
|
|
XC_USE_TSAN="NO"
|
|
|
|
XC_USE_UBSAN="NO"
|
2018-06-21 15:37:27 -06:00
|
|
|
V_HEADERS_ROOT=""
|
|
|
|
SPIRV_CROSS_ROOT=""
|
|
|
|
GLSLANG_ROOT=""
|
2020-06-02 13:30:52 -04:00
|
|
|
BLD_SPV_TLS=""
|
2018-06-21 15:37:27 -06:00
|
|
|
|
|
|
|
while (( "$#" )); do
|
|
|
|
case "$1" in
|
2020-06-17 19:10:33 -04:00
|
|
|
--ios)
|
|
|
|
BLD_IOS="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-09-01 14:39:46 -04:00
|
|
|
--iossim)
|
2020-06-17 19:10:33 -04:00
|
|
|
BLD_IOS_SIM="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-11-30 18:52:34 -05:00
|
|
|
--maccat)
|
|
|
|
BLD_MAC_CAT="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-06-19 15:05:43 -04:00
|
|
|
--tvos)
|
|
|
|
BLD_TVOS="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-09-01 14:39:46 -04:00
|
|
|
--tvossim)
|
2020-06-19 15:05:43 -04:00
|
|
|
BLD_TVOS_SIM="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-06-17 19:10:33 -04:00
|
|
|
--macos)
|
|
|
|
BLD_MACOS="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
--all)
|
|
|
|
BLD_IOS="Y"
|
|
|
|
BLD_IOS_SIM="Y"
|
2020-11-30 18:52:34 -05:00
|
|
|
BLD_MAC_CAT="Y"
|
2020-06-19 15:05:43 -04:00
|
|
|
BLD_TVOS="Y"
|
|
|
|
BLD_TVOS_SIM="Y"
|
2020-06-17 19:10:33 -04:00
|
|
|
BLD_MACOS="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-07-27 22:25:44 -04:00
|
|
|
--none)
|
|
|
|
BLD_NONE="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2019-04-18 15:08:39 -04:00
|
|
|
--debug)
|
2020-06-17 19:10:33 -04:00
|
|
|
XC_CONFIG="Debug"
|
2019-04-18 15:08:39 -04:00
|
|
|
shift 1
|
|
|
|
;;
|
2020-10-07 20:59:18 -05:00
|
|
|
--asan)
|
|
|
|
XC_USE_ASAN="YES"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
--tsan)
|
|
|
|
XC_USE_TSAN="YES"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
--ubsan)
|
|
|
|
XC_USE_UBSAN="YES"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-09-23 14:55:13 -04:00
|
|
|
--parallel-build)
|
|
|
|
XC_USE_BCKGND="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-06-22 00:00:00 -04:00
|
|
|
--no-parallel-build)
|
|
|
|
XC_USE_BCKGND=""
|
|
|
|
shift 1
|
|
|
|
;;
|
2018-12-24 22:15:23 -05:00
|
|
|
-v)
|
|
|
|
XC_BUILD_VERBOSITY=""
|
|
|
|
shift 1
|
|
|
|
;;
|
2020-06-02 13:30:52 -04:00
|
|
|
--build-spirv-tools)
|
|
|
|
BLD_SPV_TLS="Y"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
--skip-spirv-tools-build) #deprecated
|
|
|
|
BLD_SPV_TLS=""
|
2019-06-16 12:00:22 -04:00
|
|
|
shift 1
|
|
|
|
;;
|
2018-06-21 15:37:27 -06:00
|
|
|
--v-headers-root)
|
|
|
|
V_HEADERS_ROOT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--spirv-cross-root)
|
|
|
|
SPIRV_CROSS_ROOT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--glslang-root)
|
|
|
|
GLSLANG_ROOT=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-*|--*=)
|
2020-07-27 22:25:44 -04:00
|
|
|
echo "Error: Unsupported option $1" >&2
|
2018-06-21 15:37:27 -06:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2018-08-21 10:04:37 -05: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)
|
2020-07-27 22:25:44 -04:00
|
|
|
function 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
|
2019-05-10 18:24:19 -04:00
|
|
|
cd - > /dev/null
|
2018-03-30 22:16:27 -04:00
|
|
|
else
|
|
|
|
rm -rf $1
|
|
|
|
git clone $2 $1
|
|
|
|
cd $1
|
|
|
|
git checkout $3
|
2019-05-10 18:24:19 -04:00
|
|
|
cd - > /dev/null
|
2018-03-30 22:16:27 -04:00
|
|
|
fi
|
2018-03-12 10:02:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Build a repository
|
|
|
|
# $1 repo name
|
2020-07-27 22:25:44 -04:00
|
|
|
function build_repo() {
|
2018-03-12 10:02:13 -04:00
|
|
|
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
|
2018-05-28 09:43:11 -04:00
|
|
|
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install ..
|
2018-04-04 20:48:21 +02:00
|
|
|
ninja
|
|
|
|
else
|
2018-05-28 09:43:11 -04:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install ..
|
2018-12-20 20:08:54 -06:00
|
|
|
make -j $(sysctl -n hw.activecpu)
|
2018-04-04 20:48:21 +02:00
|
|
|
fi
|
2018-05-28 09:43:11 -04:00
|
|
|
|
2019-05-10 18:24:19 -04:00
|
|
|
cd - > /dev/null
|
2018-03-12 10:02:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2018-12-24 19:11:15 -05:00
|
|
|
EXT_REV_DIR=../ExternalRevisions
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
echo
|
2018-11-06 16:01:36 -05:00
|
|
|
echo ========== Retrieving MoltenVK dependencies into ${EXT_DIR} ==========
|
2018-03-30 22:16:27 -04:00
|
|
|
|
|
|
|
mkdir -p ${EXT_DIR}
|
|
|
|
cd ${EXT_DIR}
|
|
|
|
|
2018-10-02 15:14:33 -04:00
|
|
|
|
2018-03-30 12:13:50 -04:00
|
|
|
# ----------------- Cereal -------------------
|
|
|
|
|
2018-11-06 16:01:36 -05:00
|
|
|
echo
|
|
|
|
echo ========== Cereal ==========
|
|
|
|
echo
|
|
|
|
|
2018-03-30 12:13:50 -04:00
|
|
|
REPO_NAME=cereal
|
|
|
|
REPO_URL="https://github.com/USCiLab/${REPO_NAME}.git"
|
2018-12-24 19:11:15 -05: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-05-28 08:33:46 -04:00
|
|
|
# ----------------- Vulkan-Headers -------------------
|
|
|
|
|
2018-11-06 16:01:36 -05:00
|
|
|
echo
|
|
|
|
echo ========== Vulkan-Headers ==========
|
|
|
|
echo
|
|
|
|
|
2018-10-02 15:14:33 -04:00
|
|
|
# When MoltenVK is built by something that already has
|
|
|
|
# a copy of this repo, use it by creating a symlink.
|
2019-01-27 20:34:41 -05:00
|
|
|
|
|
|
|
REPO_NAME=Vulkan-Headers
|
|
|
|
|
2018-06-21 15:37:27 -06:00
|
|
|
if [ ! "$V_HEADERS_ROOT" = "" ]; then
|
2019-01-27 20:34:41 -05:00
|
|
|
rm -rf ${REPO_NAME}
|
|
|
|
ln -sfn ${V_HEADERS_ROOT} ${REPO_NAME}
|
2018-06-21 15:37:27 -06:00
|
|
|
else
|
2019-01-27 20:34:41 -05:00
|
|
|
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
|
|
|
|
REPO_REV=$(cat "${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-05-28 08:33:46 -04:00
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-06-21 15:37:27 -06:00
|
|
|
fi
|
2018-05-28 08:33:46 -04:00
|
|
|
|
|
|
|
|
2018-03-12 10:02:13 -04:00
|
|
|
# ----------------- SPIRV-Cross -------------------
|
|
|
|
|
2018-11-06 16:01:36 -05:00
|
|
|
echo
|
|
|
|
echo ========== SPIRV-Cross ==========
|
|
|
|
echo
|
|
|
|
|
2018-10-02 15:14:33 -04:00
|
|
|
# When MoltenVK is built by something that already has
|
|
|
|
# a copy of this repo, use it by creating a symlink.
|
2019-01-27 20:34:41 -05:00
|
|
|
|
|
|
|
REPO_NAME=SPIRV-Cross
|
|
|
|
|
2018-06-21 15:37:27 -06:00
|
|
|
if [ ! "$SPIRV_CROSS_ROOT" = "" ]; then
|
2019-01-27 20:34:41 -05:00
|
|
|
rm -rf ${REPO_NAME}
|
|
|
|
ln -sfn ${SPIRV_CROSS_ROOT} ${REPO_NAME}
|
2018-06-21 15:37:27 -06:00
|
|
|
else
|
2019-01-27 20:34:41 -05:00
|
|
|
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
|
|
|
|
REPO_REV=$(cat "${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-06-21 15:37:27 -06:00
|
|
|
fi
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2019-05-10 18:24:19 -04:00
|
|
|
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-05-28 08:33:46 -04:00
|
|
|
# ----------------- glslang -------------------
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-11-06 16:01:36 -05:00
|
|
|
echo
|
|
|
|
echo ========== glslang and SPIRV-Tools ==========
|
|
|
|
echo
|
|
|
|
|
2018-10-02 15:14:33 -04:00
|
|
|
# When MoltenVK is built by something that already has
|
|
|
|
# a copy of this repo, use it by creating a symlink.
|
2019-01-25 10:21:07 -07:00
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
REPO_NAME=glslang
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
if [ ! "$GLSLANG_ROOT" = "" ]; then
|
|
|
|
rm -rf ${REPO_NAME}
|
|
|
|
ln -sfn ${GLSLANG_ROOT} ${REPO_NAME}
|
|
|
|
else
|
|
|
|
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
|
|
|
|
REPO_REV=$(cat "${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
cd ${REPO_NAME}
|
|
|
|
./update_glslang_sources.py
|
2020-07-27 22:25:44 -04:00
|
|
|
rm -rf build
|
|
|
|
./build_info.py . \
|
|
|
|
-i build_info.h.tmpl \
|
|
|
|
-o build/include/glslang/build_info.h
|
2019-05-10 18:24:19 -04:00
|
|
|
cd - > /dev/null
|
2018-06-21 15:37:27 -06:00
|
|
|
fi
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2019-06-16 12:00:22 -04:00
|
|
|
# Build the embedded spirv-tools, or use option of pre-generated headers
|
|
|
|
SPV_TLS_DIR="${REPO_NAME}/External/spirv-tools"
|
2020-06-02 13:30:52 -04:00
|
|
|
if [ "$BLD_SPV_TLS" = "Y" ]; then
|
|
|
|
build_repo "${SPV_TLS_DIR}"
|
|
|
|
else
|
2019-06-16 12:00:22 -04:00
|
|
|
unzip -o -q -d "${SPV_TLS_DIR}" ../Templates/spirv-tools/build.zip
|
|
|
|
rm -rf "${SPV_TLS_DIR}/__MACOSX"
|
|
|
|
fi
|
|
|
|
|
2019-01-27 20:34:41 -05:00
|
|
|
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-05-28 08:33:46 -04:00
|
|
|
# ----------------- Vulkan-Tools -------------------
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-11-06 16:01:36 -05:00
|
|
|
echo
|
|
|
|
echo ========== Vulkan-Tools ==========
|
|
|
|
echo
|
|
|
|
|
2018-05-28 08:33:46 -04:00
|
|
|
REPO_NAME=Vulkan-Tools
|
|
|
|
REPO_URL="https://github.com/KhronosGroup/${REPO_NAME}.git"
|
2018-12-24 19:11:15 -05:00
|
|
|
REPO_REV=$(cat "${EXT_REV_DIR}/${REPO_NAME}_repo_revision")
|
2018-05-28 08:33:46 -04:00
|
|
|
|
|
|
|
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
|
2018-03-12 10:02:13 -04:00
|
|
|
|
2018-10-02 15:14:33 -04:00
|
|
|
|
|
|
|
# ----------------- Cleanup -------------------
|
|
|
|
|
2018-03-30 22:16:27 -04:00
|
|
|
cd ..
|
|
|
|
|
2018-12-24 19:11:15 -05:00
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
# -------------- Build MoltenVK external library dependencies -----------------
|
2020-07-27 22:25:44 -04:00
|
|
|
|
2018-12-24 19:11:15 -05:00
|
|
|
echo
|
2020-06-22 00:00:00 -04:00
|
|
|
echo ========== Started building dependency libraries at `date +"%r"` ==========
|
|
|
|
echo Please be patient on first build
|
|
|
|
|
2020-12-09 10:24:36 -05:00
|
|
|
function execute_xcodebuild_command () {
|
|
|
|
if [ -n "${XCPRETTY}" ]; then
|
|
|
|
set -o pipefail && xcodebuild "$@" | tee -a "dependenciesbuild.log" | ${XCPRETTY}
|
|
|
|
else
|
|
|
|
xcodebuild "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
# Build an Xcode scheme for an OS and platform
|
|
|
|
# 1 - OS
|
2020-11-30 18:52:34 -05:00
|
|
|
# 2 - Platform
|
|
|
|
# 3 - Destination (Optional. Defaults to same as platform)
|
2020-06-22 00:00:00 -04:00
|
|
|
function build_impl() {
|
2020-09-28 19:03:00 -04:00
|
|
|
BLD_SPECIFIED="Y"
|
2020-06-22 00:00:00 -04:00
|
|
|
XC_OS=${1}
|
|
|
|
XC_PLTFM=${2}
|
2020-11-30 18:52:34 -05:00
|
|
|
if [ "${3}" != "" ]; then
|
|
|
|
XC_DEST=${3};
|
|
|
|
else
|
|
|
|
XC_DEST=${XC_PLTFM};
|
|
|
|
fi
|
2020-06-22 00:00:00 -04:00
|
|
|
|
|
|
|
XC_SCHEME="${EXT_DEPS}-${XC_OS}"
|
2020-09-01 14:39:46 -04:00
|
|
|
XC_LCL_DD_PATH="${XC_DD_PATH}/Intermediates/${XC_PLTFM}"
|
2018-12-24 19:11:15 -05:00
|
|
|
|
2020-11-30 18:52:34 -05:00
|
|
|
echo Building external libraries for platform ${XC_PLTFM} and destination ${XC_DEST}
|
2020-06-22 00:00:00 -04:00
|
|
|
|
2020-12-09 10:24:36 -05:00
|
|
|
execute_xcodebuild_command \
|
2020-10-07 20:59:18 -05:00
|
|
|
-project "${XC_PROJ}" \
|
|
|
|
-scheme "${XC_SCHEME}" \
|
2020-11-30 18:52:34 -05:00
|
|
|
-destination "generic/platform=${XC_DEST}" \
|
2020-10-07 20:59:18 -05:00
|
|
|
-configuration "${XC_CONFIG}" \
|
|
|
|
-enableAddressSanitizer "${XC_USE_ASAN}" \
|
|
|
|
-enableThreadSanitizer "${XC_USE_TSAN}" \
|
|
|
|
-enableUndefinedBehaviorSanitizer "${XC_USE_UBSAN}" \
|
|
|
|
-derivedDataPath "${XC_LCL_DD_PATH}" \
|
|
|
|
${XC_BUILD_VERBOSITY} \
|
2020-06-17 19:10:33 -04:00
|
|
|
build
|
2020-06-22 00:00:00 -04:00
|
|
|
|
|
|
|
echo Completed building external libraries for ${XC_PLTFM}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Select whether or not to run the build in parallel.
|
|
|
|
# 1 - OS
|
|
|
|
# 2 - platform
|
|
|
|
function build() {
|
|
|
|
if [ "$XC_USE_BCKGND" != "" ]; then
|
2020-11-30 18:52:34 -05:00
|
|
|
build_impl "${1}" "${2}" "${3}" &
|
2020-06-22 00:00:00 -04:00
|
|
|
else
|
2020-11-30 18:52:34 -05:00
|
|
|
build_impl "${1}" "${2}" "${3}"
|
2020-06-22 00:00:00 -04:00
|
|
|
fi
|
2020-06-17 19:10:33 -04:00
|
|
|
}
|
|
|
|
|
2018-12-24 19:11:15 -05:00
|
|
|
EXT_DEPS=ExternalDependencies
|
2019-04-18 15:08:39 -04:00
|
|
|
XC_PROJ="${EXT_DEPS}.xcodeproj"
|
|
|
|
XC_DD_PATH="${EXT_DIR}/build"
|
|
|
|
|
2020-12-09 10:24:36 -05:00
|
|
|
# Determine if xcpretty is present
|
|
|
|
XCPRETTY_PATH=$(command -v xcpretty 2> /dev/null || true) # ignore failures
|
|
|
|
|
|
|
|
# If xcpretty is present, use it to format xcodebuild output
|
|
|
|
XCPRETTY=""
|
|
|
|
if [ -n "$XCPRETTY_PATH" ]; then
|
|
|
|
XCPRETTY="xcpretty -c"
|
|
|
|
fi
|
|
|
|
if [ "$XC_USE_BCKGND" != "" ]; then
|
|
|
|
# For now, avoid using xcpretty if parallel background tasks are being used
|
|
|
|
XCPRETTY=""
|
|
|
|
fi
|
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
# Structure build tasks by platform so they can be built in parallel per platform.
|
|
|
|
# Content for each platform must be built in series to avoid
|
2020-07-27 22:25:44 -04:00
|
|
|
if [ "$XC_USE_BCKGND" != "" ]; then
|
|
|
|
trap "exit" INT TERM ERR
|
|
|
|
trap "kill 0" EXIT
|
|
|
|
fi
|
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
if [ "$BLD_MACOS" != "" ]; then
|
|
|
|
build "macOS" "macOS"
|
2020-06-17 19:10:33 -04:00
|
|
|
fi
|
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
if [ "$BLD_IOS" != "" ]; then
|
2020-09-01 14:39:46 -04:00
|
|
|
build "iOS" "iOS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BLD_IOS_SIM" != "" ]; then
|
|
|
|
build "iOS" "iOS Simulator"
|
2020-06-19 15:05:43 -04:00
|
|
|
fi
|
|
|
|
|
2020-11-30 18:52:34 -05:00
|
|
|
if [ "$BLD_MAC_CAT" != "" ]; then
|
|
|
|
build "iOS" "Mac Catalyst" "macOS,variant=Mac Catalyst"
|
|
|
|
fi
|
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
if [ "$BLD_TVOS" != "" ]; then
|
2020-09-01 14:39:46 -04:00
|
|
|
build "tvOS" "tvOS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BLD_TVOS_SIM" != "" ]; then
|
|
|
|
build "tvOS" "tvOS Simulator"
|
2020-06-19 15:05:43 -04:00
|
|
|
fi
|
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
# Wait for any background process (if selected) to finish
|
2020-07-27 22:25:44 -04:00
|
|
|
if [ "$XC_USE_BCKGND" != "" ]; then
|
|
|
|
wait
|
|
|
|
fi
|
2018-12-24 19:11:15 -05:00
|
|
|
|
2020-09-28 19:03:00 -04:00
|
|
|
if [ "$BLD_SPECIFIED" != "" ]; then
|
|
|
|
# Build XCFrameworks, update latest symlink, and clean MoltenVK for rebuild
|
|
|
|
PROJECT_DIR="."
|
|
|
|
CONFIGURATION=${XC_CONFIG}
|
|
|
|
. "./Scripts/create_ext_lib_xcframeworks.sh"
|
|
|
|
. "./Scripts/package_ext_libs_finish.sh"
|
|
|
|
else
|
|
|
|
if [ "$BLD_NONE" != "" ]; then
|
|
|
|
echo Not building any platforms
|
|
|
|
else
|
|
|
|
echo "WARNING: You did not specify a platform to build."
|
|
|
|
echo "To build the external libraries, include one or"
|
|
|
|
echo "more of the following platform options:"
|
2020-12-08 21:31:39 -05:00
|
|
|
echo " --macos --ios --iossim --maccat --tvos --tvossim --all"
|
2020-09-28 19:03:00 -04:00
|
|
|
echo "See the instructions in the fetchDependencies script for more info."
|
|
|
|
fi
|
|
|
|
fi
|
2018-12-24 19:11:15 -05:00
|
|
|
|
2020-06-22 00:00:00 -04:00
|
|
|
echo ========== Finished at `date +"%r"` ==========
|
2020-07-27 22:25:44 -04:00
|
|
|
exit 0
|