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
="gcc -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"
27 _options_release
="-O3 -DVG_RELEASE"
30 # ==============================================================================
32 _warnings
="-Wall -Wno-unused-function -Wno-unused-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
65 cd $_linux_server_folder
76 ln -sr bin
/content
/textures
/ $1/textures
77 ln -sr bin
/content
/models
/ $1/models
78 ln -sr bin
/content
/sound
/ $1/sound
81 TIMESTAMP
=`date +%Y-%m-%d_%H-%M-%S`
86 _linux_options
=$_options_release
87 _windows_options
=$_options_release
90 _linux_options
="$_linux_asan $_options_debugmode"
91 _windows_options
="$_windows_asan $_options_debugmode"
94 titleit
"Creating Linux build"
95 mkdir
-p $_linux_folder/cfg
98 cp vg
/dep
/steam
/libsteam_api.so
$_linux_folder
99 link_content
$_linux_folder
101 _compiler
=$_linux_compiler
102 _options
=$_linux_options
104 compile_miniaudio linux
107 _folder
=$_linux_folder
112 _link
="$_linux_linkgraphics $_linux_linksteam"
113 _src
="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_linux.o"
118 titleit
"Creating Windows build"
119 mkdir
-p $_windows_folder/cfg
122 cp vg
/dep
/steam
/steam_api.dll
$_windows_folder
123 link_content
$_windows_folder
125 _compiler
=$_windows_compiler
126 _options
=$_windows_options
128 compile_miniaudio windows
132 _folder
=$_windows_folder
136 _link
="$_windows_linkgraphics $_windows_linksteam"
137 _src
="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_windows.o"
142 titleit
"Creating Server build"
143 mkdir
-p $_linux_server_folder/cfg
146 cp vg
/dep
/steam
/steamclient.so bin
/linux_server
/
147 cp vg
/dep
/steam
/libsteam_api.so bin
/linux_server
/
148 cp vg
/dep
/steam
/libsdkencryptedappticket.so bin
/linux_server
/
150 _compiler
=$_linux_compiler
151 _options
=$_linux_options
152 _link
="-pthread -lm -lsdkencryptedappticket $_linux_linksteam"
154 _folder
=$_linux_server_folder
155 _dst
="skaterift_server"
162 mkdir
-p bin
/aatest
/cfg
164 _compiler
=$_linux_compiler
165 _options
=$_linux_options
175 #TODO: These are not cross platform in the build script, a full build
176 # from source is therefore not possible on windows, only a linux
179 titleit
"Compiling textures"
180 mkdir
-p .
/bin
/content
/textures
181 for f
in .
/textures_src
/*.png
;
182 do logit
" qoiconv: $f";
183 dest
=.
/bin
/content
/textures
/"$(basename "$f" .png).qoi"
184 .
/bin
/linux
/tools
/qoiconv
$f $dest
188 logit
"Copying content"
189 mkdir
-p .
/bin
/content
/models
190 mkdir
-p .
/bin
/content
/sound
192 cp .
/models_src
/* .
/bin
/content
/models
/
193 cp .
/sound_src
/* .
/bin
/content
/sound
/
211 titleit
"Compressing distributions"
213 tar -chzvf dist
/skaterift_linux__
$TIMESTAMP.
tar.gz bin
/linux
/
215 tar -chzvf dist
/skaterift_server__
$TIMESTAMP.
tar.gz bin
/linux_server
217 tar -chzvf dist
/skaterift_win32__
$TIMESTAMP.
tar.gz bin
/win32
/
220 # ========================================================================
239 echo "Unrecognised command $1"
243 lsan_file
=$
(realpath
".lsan_suppress.txt")
244 export LSAN_OPTIONS
="suppressions=$lsan_file"
247 source vg
/vg_build.sh