forked from KhronosGroup/MoltenVK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchDependencies
executable file
·282 lines (215 loc) · 6.65 KB
/
fetchDependencies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/usr/bin/env bash
#
# Copyright (c) 2016-2019 The Brenwill Workshop Ltd.
#
# fetchDependencies - Retrieves the correct versions of all dependencies
#
# macOS usage: ./fetchDependencies [-v] [--debug] [--v-headers-root path] [--spirv-cross-root path] [--glslang-root path]
#
# --v-headers-root path
# "path" specifies a directory path to a
# KhronosGroup/Vulkan-Headers repository.
# This repository does not have to be built.
#
# --spirv-cross-root path
# "path" specifies a directory path to a
# KhronosGroup/SPIRV-Cross 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.
#
# -v verbose output
#
# --debug
# Build the external libraries in Debug mode, which may be useful
# when debugging and tracing calls into those libraries.
#
set -o errexit
# ----------------- Functions -------------------
XC_SCHEME_SFX=""
XC_BUILD_VERBOSITY="-quiet"
V_HEADERS_ROOT=""
SPIRV_CROSS_ROOT=""
GLSLANG_ROOT=""
while (( "$#" )); do
case "$1" in
--debug)
XC_SCHEME_SFX=" (Debug)"
shift 1
;;
-v)
XC_BUILD_VERBOSITY=""
shift 1
;;
--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
;;
-*|--*=)
echo "Error: Unsupported flag $1" >&2
exit 1
;;
esac
done
# 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 - > /dev/null
else
rm -rf $1
git clone $2 $1
cd $1
git checkout $3
cd - > /dev/null
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 -j $(sysctl -n hw.activecpu)
fi
cd - > /dev/null
}
# ----------------- Main -------------------
EXT_DIR=External
EXT_REV_DIR=../ExternalRevisions
echo
echo ========== Retrieving MoltenVK dependencies into ${EXT_DIR} ==========
mkdir -p ${EXT_DIR}
cd ${EXT_DIR}
# ----------------- Cereal -------------------
echo
echo ========== Cereal ==========
echo
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 -------------------
echo
echo ========== Vulkan-Headers ==========
echo
# When MoltenVK is built by something that already has
# a copy of this repo, use it by creating a symlink.
REPO_NAME=Vulkan-Headers
if [ ! "$V_HEADERS_ROOT" = "" ]; then
rm -rf ${REPO_NAME}
ln -sfn ${V_HEADERS_ROOT} ${REPO_NAME}
else
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
# ----------------- Vulkan-Portability -------------------
echo
echo ========== Vulkan-Portability ==========
echo
REPO_NAME=Vulkan-Portability
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 -------------------
echo
echo ========== SPIRV-Cross ==========
echo
# When MoltenVK is built by something that already has
# a copy of this repo, use it by creating a symlink.
REPO_NAME=SPIRV-Cross
if [ ! "$SPIRV_CROSS_ROOT" = "" ]; then
rm -rf ${REPO_NAME}
ln -sfn ${SPIRV_CROSS_ROOT} ${REPO_NAME}
else
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
# Record the SPIRV-Cross revision as a derived header file suitable for including in a build
HDR_FILE=${REPO_NAME}/mvkSpirvCrossRevisionDerived.h
echo "// Auto-generated by MoltenVK" > ${HDR_FILE}
echo "static const char* spirvCrossRevisionString = \"${REPO_REV}\";" >> ${HDR_FILE}
# ----------------- glslang -------------------
echo
echo ========== glslang and SPIRV-Tools ==========
echo
# When MoltenVK is built by something that already has
# a copy of this repo, use it by creating a symlink.
REPO_NAME=glslang
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")
update_repo ${REPO_NAME} ${REPO_URL} ${REPO_REV}
cd ${REPO_NAME}
./update_glslang_sources.py
cd - > /dev/null
fi
#Make sure the embedded spirv-tools is built
build_repo "${REPO_NAME}/External/spirv-tools"
# ----------------- Vulkan-Tools -------------------
echo
echo ========== Vulkan-Tools ==========
echo
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 -------------------
echo
echo ========== VulkanSamples ==========
echo
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}
# Generate dispatch files needed for Hologram demo
cd "${REPO_NAME}/Sample-Programs/Hologram"
./generate-dispatch-table HelpersDispatchTable.h
./generate-dispatch-table HelpersDispatchTable.cpp
cd - > /dev/null
# ----------------- Cleanup -------------------
cd ..
# -------------- Build MoltenVK dependencies -----------------
echo
echo ========== Building dependency libraries quietly. Please be patient on first build. ==========
echo
EXT_DEPS=ExternalDependencies
XC_PROJ="${EXT_DEPS}.xcodeproj"
XC_SCHEME="${EXT_DEPS}${XC_SCHEME_SFX}"
XC_DD_PATH="${EXT_DIR}/build"
xcodebuild \
-project "${XC_PROJ}" \
-scheme "${XC_SCHEME}" \
-derivedDataPath "${XC_DD_PATH}" \
${XC_BUILD_VERBOSITY} \
build
echo ========== Done! ==========