3 # Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
5 # Main cross-compiling build script for Skate Rift
6 # Supports Linux and Windows building from a Linux Host
8 # vg must be "ln -s"'d into this src folder as the only dependency
11 # ==============================================================================
13 _linux_compiler
="clang -std=c99 -D_REENTRANT"
14 _linux_linkgraphics
="-lGL -lglfw3 -lX11 -lXxf86vm -lXrandr -lm -pthread -lXi -ldl"
15 _linux_asan
="-fsanitize=address"
16 _linux_linksteam
="-lsteam_api"
17 _linux_folder
="bin/linux"
18 _linux_server_folder
="bin/linux_server"
20 _windows_compiler
="i686-w64-mingw32-gcc"
21 _windows_linkgraphics
="-lglfw3dll -lopengl32 -lm -pthread -static -mwindows"
23 _windows_linksteam
="vg/dep/steam/steam_api.dll"
24 _windows_folder
="bin/win32"
26 _options_debugmode
="-O0 -ggdb3 -fno-omit-frame-pointer -rdynamic"
27 _options_release
="-O3 -DVG_RELEASE"
30 # ==============================================================================
32 _warnings
="-Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unused-but-set-variable"
33 _include
="-I. -I./vg/dep -I./vg/src"
34 _library
="-L. -L./vg/dep/glfw -L./vg/dep/steam"
35 _epilogue
="-Wl,-rpath=./"
39 # ==============================================================================
43 temp_options
=$_options
48 _src
="-c vg/dep/dr_soft/miniaudio_impl.c"
49 _dst
="vg/dep/dr_soft/miniaudio_$1"
53 _options
=$temp_options
56 # Again, these are not cross platform currently
60 .
/skaterift
--samples=4
65 cd $_linux_server_folder
80 ln -srf bin
/content
/textures
$1/textures
81 ln -srf bin
/content
/models
$1/models
82 ln -srf bin
/content
/sound
$1/sound
85 TIMESTAMP
=`date +%Y-%m-%d_%H-%M-%S`
90 _linux_options
=$_options_release
91 _windows_options
=$_options_release
94 _linux_options
="$_linux_asan $_options_debugmode"
95 _windows_options
="$_windows_asan $_options_debugmode"
98 _compiler
=$_linux_compiler
99 _options
=$_linux_options
100 _folder
=$_linux_folder
106 titleit
"Creating Linux build"
107 mkdir
-p $_linux_folder/cfg
110 cp vg
/dep
/steam
/libsteam_api.so
$_linux_folder
111 link_content
$_linux_folder
113 _compiler
=$_linux_compiler
114 _options
=$_linux_options
116 compile_miniaudio linux
119 _folder
=$_linux_folder
124 _link
="$_linux_linkgraphics $_linux_linksteam"
125 _src
="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_linux.o"
130 titleit
"Creating Windows build"
131 mkdir
-p $_windows_folder/cfg
134 cp vg
/dep
/steam
/steam_api.dll
$_windows_folder
135 link_content
$_windows_folder
137 _compiler
=$_windows_compiler
138 _options
=$_windows_options
140 compile_miniaudio windows
144 _folder
=$_windows_folder
148 _link
="$_windows_linkgraphics $_windows_linksteam"
149 _src
="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_windows.o"
154 titleit
"Creating Server build"
155 mkdir
-p $_linux_server_folder/cfg
158 cp vg
/dep
/steam
/steamclient.so bin
/linux_server
/
159 cp vg
/dep
/steam
/libsteam_api.so bin
/linux_server
/
160 cp vg
/dep
/steam
/libsdkencryptedappticket.so bin
/linux_server
/
162 _compiler
=$_linux_compiler
163 _options
=$_linux_options
164 _link
="-pthread -lm -lsdkencryptedappticket $_linux_linksteam"
166 _folder
=$_linux_server_folder
167 _dst
="skaterift_server"
174 mkdir
-p bin
/aatest
/cfg
176 _compiler
=$_linux_compiler
177 _options
=$_linux_options
187 #TODO: These are not cross platform in the build script, a full build
188 # from source is therefore not possible on windows, only a linux
191 titleit
"Compiling textures"
192 mkdir
-p .
/bin
/content
/textures
193 for f
in .
/textures_src
/*.png
;
194 do logit
" qoiconv: $f";
195 dest
=.
/bin
/content
/textures
/"$(basename "$f" .png).qoi"
196 .
/bin
/linux
/tools
/qoiconv
$f $dest
200 titleit
"Compiling sounds"
201 mkdir
-p .
/bin
/content
/textures
203 for f
in .
/sound_src
/*.wav
205 dest
=.
/bin
/content
/sounds
/"$(basename "$f" .wav).44100.ima_adpcm"
206 .
/bin
/linux
/tools
/audcomp
$f $dest
211 logit
"Copying content"
212 mkdir
-p .
/bin
/content
/models
213 mkdir
-p .
/bin
/content
/sound
215 cp .
/models_src
/* .
/bin
/content
/models
/
216 #cp ./sound_src/* ./bin/content/sound/
236 titleit
"Compressing distributions"
238 tar -chzvf dist
/skaterift_linux__
$TIMESTAMP.
tar.gz bin
/linux
/
240 tar -chzvf dist
/skaterift_server__
$TIMESTAMP.
tar.gz bin
/linux_server
242 tar -chzvf dist
/skaterift_win32__
$TIMESTAMP.
tar.gz bin
/win32
/
243 zip -r9 dist
/skaterift_win32__
$TIMESTAMP.
zip bin
/win32
/
246 # ========================================================================
270 echo "Unrecognised command $1"
274 lsan_file
=$
(realpath
".lsan_suppress.txt")
275 export LSAN_OPTIONS
="suppressions=$lsan_file"
278 source vg
/vg_build.sh