-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUberScript.sh
272 lines (234 loc) · 7.06 KB
/
UberScript.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
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
#!/bin/bash
Help()
{
echo "Syntax: UberScript [-c][-h|i|g|s|b|t|v|a]"
echo "options:"
echo "c Config"
echo "h Help"
echo "i Install dependencies"
echo "g Generate project"
echo "s Shaders compilation"
echo "b Build engine"
echo "t Tests"
echo "v VisualStudio"
echo "a All-in-one"
echo
}
InstallDependencies()
{
git submodule update --init --recursive
if [[ "$platform" == "linux" ]]; then
sudo apt-get install -y cmake gcc-9 g++-9 build-essential mercurial make autoconf automake libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev
fi
}
GenerateProject()
{
mkdir -p tmp
mkdir -p build
cmake -S . -B build
}
CompileShaders()
{
path_shaderc=""
if [[ "$platform" == "windows" ]]; then
path_shaderc="./build/src/EnlivengineThirdParty/bgfx/Debug/shaderc.exe"
else
path_shaderc="./build/src/EnlivengineThirdParty/bgfx/shaderc"
fi
if [ ! -x "$path_shaderc" ]; then
cmake --build build --target shaderc --config Debug
fi
output_path="build/Shaders"
path_bgfx_include="src/EnlivengineThirdParty/bgfx/bgfx/src"
mkdir -p "$output_path"
mkdir -p "$output_path/dx9"
mkdir -p "$output_path/dx11"
mkdir -p "$output_path/essl"
mkdir -p "$output_path/glsl"
mkdir -p "$output_path/metal"
mkdir -p "$output_path/pssl"
mkdir -p "$output_path/spirv"
all_vertex_shaders="`find src/Enlivengine/Shaders -name *.vs`"
for vertex_shader in $all_vertex_shaders
do
basename="`basename $vertex_shader`"
basenamewoext="`echo $basename | cut -f 1 -d '.'`"
#TODO: platform asm.js ?
# DX9
$path_shaderc -f "${vertex_shader}" -o "${output_path}/dx9/${basenamewoext}.vs.bin" --platform windows -p vs_3_0 -O 3 --type vertex --verbose -i $path_bgfx_include
# DX11
$path_shaderc -f "${vertex_shader}" -o "${output_path}/dx11/${basenamewoext}.vs.bin" --platform windows -p vs_5_0 -O 3 --type vertex --verbose -i $path_bgfx_include
# NACL
$path_shaderc -f "${vertex_shader}" -o "${output_path}/essl/${basenamewoext}.vs.bin" --platform nacl --type vertex --verbose -i $path_bgfx_include
# Android
$path_shaderc -f "${vertex_shader}" -o "${output_path}/essl/${basenamewoext}.vs.bin" --platform android --type vertex --verbose -i $path_bgfx_include
# GLSL
$path_shaderc -f "${vertex_shader}" -o "${output_path}/glsl/${basenamewoext}.vs.bin" --platform linux -p 120 --type vertex --verbose -i $path_bgfx_include
# Metal
$path_shaderc -f "${vertex_shader}" -o "${output_path}/metal/${basenamewoext}.vs.bin" --platform osx -p metal --type vertex --verbose -i $path_bgfx_include
# PSSL
$path_shaderc -f "${vertex_shader}" -o "${output_path}/pssl/${basenamewoext}.vs.bin" --platform orbis -p pssl --type vertex --verbose -i $path_bgfx_include
# Spirv
$path_shaderc -f "${vertex_shader}" -o "${output_path}/spirv/${basenamewoext}.vs.bin" --platform linux -p spirv --type vertex --verbose -i $path_bgfx_include
done
all_fragment_shaders="`find src/Enlivengine/Shaders -name *.fs`"
for fragment_shader in $all_fragment_shaders
do
basename="`basename $fragment_shader`"
basenamewoext="`echo $basename | cut -f 1 -d '.'`"
#TODO: platform asm.js ?
# DX9
$path_shaderc -f "${fragment_shader}" -o "${output_path}/dx9/${basenamewoext}.fs.bin" --platform windows -p ps_3_0 -O 3 --type fragment --verbose -i $path_bgfx_include
# DX11
$path_shaderc -f "${fragment_shader}" -o "${output_path}/dx11/${basenamewoext}.fs.bin" --platform windows -p ps_5_0 -O 3 --type fragment --verbose -i $path_bgfx_include
# NACL
$path_shaderc -f "${fragment_shader}" -o "${output_path}/essl/${basenamewoext}.fs.bin" --platform nacl --type fragment --verbose -i $path_bgfx_include
# Android
$path_shaderc -f "${fragment_shader}" -o "${output_path}/essl/${basenamewoext}.fs.bin" --platform android --type fragment --verbose -i $path_bgfx_include
# GLSL
$path_shaderc -f "${fragment_shader}" -o "${output_path}/glsl/${basenamewoext}.fs.bin" --platform linux -p 120 --type fragment --verbose -i $path_bgfx_include
# Metal
$path_shaderc -f "${fragment_shader}" -o "${output_path}/metal/${basenamewoext}.fs.bin" --platform osx -p metal --type fragment --verbose -i $path_bgfx_include
# PSSL
$path_shaderc -f "${fragment_shader}" -o "${output_path}/pssl/${basenamewoext}.fs.bin" --platform orbis -p pssl --type fragment --verbose -i $path_bgfx_include
# Spirv
$path_shaderc -f "${fragment_shader}" -o "${output_path}/spirv/${basenamewoext}.fs.bin" --platform linux -p spirv --type fragment --verbose -i $path_bgfx_include
done
}
BuildEnlivengine()
{
cmake --build build --target Enlivengine --config $config
cmake --build build --target EnlivengineTests --config $config
cmake --build build --target PlatformExample --config $config
cmake --build build --target 3DSceneExample --config $config
}
Tests()
{
# Ensures they are both up to date
cmake --build build --target EnlivengineTests --config $config
cmake --build build --target PlatformExample --config $config
if [[ "$platform" == "windows" ]]; then
./build/examples/$config/PlatformExample.exe # default path for Visual Studio users
./build/tests/$config/EnlivengineTests.exe # default path for Visual Studio users
else
./build/examples/PlatformExample.exe # for Linux/Unix GCC users
./build/tests/EnlivengineTests # for Linux/Unix GCC users
fi
}
VisualStudio()
{
if [[ "$platform" == "windows" ]]; then
all_solutions="`find build -maxdepth 1 -name *.sln`"
for solution in $all_solutions
do
start $solution
done
fi
}
# Platform detection
platform='unknown'
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
platform='linux'
elif [[ "$OSTYPE" == "freebsd"* ]]; then
platform='bsd'
elif [[ "$OSTYPE" == "darwin"* ]]; then
platform='mac'
elif [[ "$OSTYPE" == "cygwin" ]]; then
platform='windows'
elif [[ "$OSTYPE" == "msys" ]]; then
platform='windows'
elif [[ "$OSTYPE" == "win32" ]]; then
platform='windows'
else
echo "OSTYPE == ${OSTYPE} not reconized, assuming it's windows"
platform='windows'
fi
# Options
config="Debug"
help=false
install=false
generate=false
shaders=false
build=false
tests=false
visual=false
default=true
# Options parsing
while getopts c:higsbtva option
do
case $option in
c)
default=false
config=$OPTARG
;;
h)
default=false
help=true
;;
i)
default=false
install=true
;;
g)
default=false
generate=true
;;
s)
default=false
shaders=true
;;
b)
default=false
build=true
;;
t)
default=false
tests=true
;;
v)
default=false
visual=true
;;
a)
default=false
install=true
generate=true
shaders=true
build=true
tests=true
;;
esac
done
#echo "=> $config"
# If no arguments, consider it as -a
if $default; then
install=true
generate=true
shaders=true
build=true
tests=true
fi
# Handle options
if $help; then
Help
fi
if $install; then
InstallDependencies
fi
if $generate; then
GenerateProject
fi
if $shaders; then
CompileShaders
GenerateProject
fi
if $build; then
BuildEnlivengine
fi
if $tests; then
Tests
fi
if $visual; then
VisualStudio
fi
echo