forked from LunarG/VulkanTools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_external_sources.sh
executable file
·192 lines (168 loc) · 5.45 KB
/
update_external_sources.sh
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
#!/bin/bash
# Update source for glslang, spirv-tools
set -e
if [[ $(uname) == "Linux" ]]; then
CURRENT_DIR="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
CORE_COUNT=$(nproc || echo 4)
elif [[ $(uname) == "Darwin" ]]; then
CURRENT_DIR="$(dirname "$(python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE[0]})")"
CORE_COUNT=$(sysctl -n hw.ncpu || echo 4)
fi
echo CORE_COUNT=$CORE_COUNT
REVISION_DIR="$CURRENT_DIR/external_revisions"
GLSLANG_GITURL=$(cat "${REVISION_DIR}/glslang_giturl")
GLSLANG_REVISION=$(cat "${REVISION_DIR}/glslang_revision")
SPIRV_TOOLS_GITURL=$(cat "${REVISION_DIR}/spirv-tools_giturl")
SPIRV_TOOLS_REVISION=$(cat "${REVISION_DIR}/spirv-tools_revision")
SPIRV_HEADERS_GITURL=$(cat "${REVISION_DIR}/spirv-headers_giturl")
SPIRV_HEADERS_REVISION=$(cat "${REVISION_DIR}/spirv-headers_revision")
JSONCPP_REVISION=$(cat "${REVISION_DIR}/jsoncpp_revision")
echo "GLSLANG_GITURL=${GLSLANG_GITURL}"
echo "GLSLANG_REVISION=${GLSLANG_REVISION}"
echo "SPIRV_TOOLS_GITURL=${SPIRV_TOOLS_GITURL}"
echo "SPIRV_TOOLS_REVISION=${SPIRV_TOOLS_REVISION}"
echo "SPIRV_HEADERS_GITURL=${SPIRV_HEADERS_GITURL}"
echo "SPIRV_HEADERS_REVISION=${SPIRV_HEADERS_REVISION}"
echo "JSONCPP_REVISION=${JSONCPP_REVISION}"
BUILDDIR=${CURRENT_DIR}
BASEDIR="$BUILDDIR/external"
function create_glslang () {
rm -rf "${BASEDIR}"/glslang
echo "Creating local glslang repository (${BASEDIR}/glslang)."
mkdir -p "${BASEDIR}"/glslang
cd "${BASEDIR}"/glslang
git clone ${GLSLANG_GITURL} .
git checkout ${GLSLANG_REVISION}
}
function update_glslang () {
echo "Updating ${BASEDIR}/glslang"
cd "${BASEDIR}"/glslang
git fetch --all
git checkout --force ${GLSLANG_REVISION}
}
function create_spirv-tools () {
rm -rf "${BASEDIR}"/spirv-tools
echo "Creating local spirv-tools repository (${BASEDIR}/spirv-tools)."
mkdir -p "${BASEDIR}"/spirv-tools
cd "${BASEDIR}"/spirv-tools
git clone ${SPIRV_TOOLS_GITURL} .
git checkout ${SPIRV_TOOLS_REVISION}
mkdir -p "${BASEDIR}"/spirv-tools/external/spirv-headers
cd "${BASEDIR}"/spirv-tools/external/spirv-headers
git clone ${SPIRV_HEADERS_GITURL} .
git checkout ${SPIRV_HEADERS_REVISION}
}
function update_spirv-tools () {
echo "Updating ${BASEDIR}/spirv-tools"
cd "${BASEDIR}"/spirv-tools
git fetch --all
git checkout ${SPIRV_TOOLS_REVISION}
if [ ! -d "${BASEDIR}/spirv-tools/external/spirv-headers" -o ! -d "${BASEDIR}/spirv-tools/external/spirv-headers/.git" ]; then
mkdir -p "${BASEDIR}"/spirv-tools/external/spirv-headers
cd "${BASEDIR}"/spirv-tools/external/spirv-headers
git clone ${SPIRV_HEADERS_GITURL} .
else
cd "${BASEDIR}"/spirv-tools/external/spirv-headers
git fetch --all
fi
git checkout ${SPIRV_HEADERS_REVISION}
}
function build_glslang () {
echo "Building ${BASEDIR}/glslang"
cd "${BASEDIR}"/glslang
mkdir -p build
cd build
cmake -D CMAKE_BUILD_TYPE=Release ..
make -j $CORE_COUNT
make install
}
function build_spirv-tools () {
echo "Building ${BASEDIR}/spirv-tools"
cd "${BASEDIR}"/spirv-tools
mkdir -p build
cd build
cmake -D CMAKE_BUILD_TYPE=Release ..
make -j $CORE_COUNT
}
function create_jsoncpp () {
rm -rf ${BASEDIR}/jsoncpp
echo "Creating local jsoncpp repository (${BASEDIR}/jsoncpp)."
mkdir -p ${BASEDIR}/jsoncpp
cd ${BASEDIR}/jsoncpp
git clone https://github.com/open-source-parsers/jsoncpp.git .
git checkout ${JSONCPP_REVISION}
}
function update_jsoncpp () {
echo "Updating ${BASEDIR}/jsoncpp"
cd ${BASEDIR}/jsoncpp
git fetch --all
git checkout ${JSONCPP_REVISION}
}
function build_jsoncpp () {
echo "Building ${BASEDIR}/jsoncpp"
cd ${BASEDIR}/jsoncpp
python amalgamate.py
}
INCLUDE_GLSLANG=false
INCLUDE_SPIRV_TOOLS=false
INCLUDE_JSONCPP=false
if [ "$#" == 0 ]; then
# If no options are provided, build everything
echo "Building glslang, spirv-tools, and jsoncpp"
INCLUDE_GLSLANG=true
INCLUDE_SPIRV_TOOLS=true
INCLUDE_JSONCPP=true
else
# If any options are provided, just compile those tools
while [[ $# > 0 ]]
do
option="$1"
case $option in
# options to specify build of glslang components
-g|--glslang)
INCLUDE_GLSLANG=true
echo "Building glslang ($option)"
;;
# options to specify build of spirv-tools components
-s|--spirv-tools)
INCLUDE_SPIRV_TOOLS=true
echo "Building spirv-tools ($option)"
;;
# options to specify build of jsoncpp components
-j|--jsoncpp)
INCLUDE_JSONCPP=true
echo "Building jsoncpp ($option)"
;;
*)
echo "Unrecognized option: $option"
echo "Try the following:"
echo " -g | --glslang # enable glslang"
echo " -s | --spirv-tools # enable spirv-tools"
echo " -j | --jsoncpp # enable jsoncpp"
exit 1
;;
esac
shift
done
fi
if [ ${INCLUDE_GLSLANG} == "true" ]; then
if [ ! -d "${BASEDIR}/glslang" -o ! -d "${BASEDIR}/glslang/.git" -o -d "${BASEDIR}/glslang/.svn" ]; then
create_glslang
fi
update_glslang
build_glslang
fi
if [ ${INCLUDE_SPIRV_TOOLS} == "true" ]; then
if [ ! -d "${BASEDIR}/spirv-tools" -o ! -d "${BASEDIR}/spirv-tools/.git" ]; then
create_spirv-tools
fi
update_spirv-tools
build_spirv-tools
fi
if [ ${INCLUDE_JSONCPP} == "true" ]; then
if [ ! -d "${BASEDIR}/jsoncpp" -o ! -d "${BASEDIR}/jsoncpp/.git" ]; then
create_jsoncpp
fi
update_jsoncpp
build_jsoncpp
fi