2 # Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved
4 # Main cross-compiling build script for Skate Rift
5 # Supports Linux and Windows building from a Linux Host
7 # vg must be "ln -s"'d into this src folder as the only dependency
10 # ==============================================================================
12 _linux_compiler
="gcc -std=c99 -D_REENTRANT"
13 _linux_linkgraphics
="-lGL -lglfw3 -lX11 -lXxf86vm -lXrandr -lm -pthread -lXi -ldl"
14 _linux_asan
="-fsanitize=address"
15 _linux_linksteam
="-lsteam_api"
16 _linux_folder
="bin/linux"
17 _linux_server_folder
="bin/linux_server"
19 _windows_compiler
="i686-w64-mingw32-gcc"
20 _windows_linkgraphics
="-lglfw3dll -lopengl32 -lm -mwindows"
22 _windows_linksteam
="vg/dep/steam/steam_api.dll"
23 _windows_folder
="bin/win32"
25 _options_debugmode
="-O0 -ggdb3 -fno-omit-frame-pointer"
26 _options_release
="-O3 -DVG_RELEASE"
29 # ==============================================================================
31 _warnings
="-Wall -Wno-unused-function -Wno-unused-variable"
32 _include
="-I. -I./vg/dep -I./vg/src"
33 _library
="-L. -L./vg/dep/glfw -L./vg/dep/steam"
34 _epilogue
="-Wl,-rpath=./"
38 # ==============================================================================
42 temp_options
=$_options
47 _src
="-c vg/dep/dr_soft/miniaudio_impl.c"
48 _dst
="vg/dep/dr_soft/miniaudio_$1"
52 _options
=$temp_options
55 # Again, these are not cross platform currently
64 cd $_linux_server_folder
75 ln -sr bin
/content
/textures
/ $1/textures
76 ln -sr bin
/content
/models
/ $1/models
77 ln -sr bin
/content
/sound
/ $1/sound
80 TIMESTAMP
=`date +%Y-%m-%d_%H-%M-%S`
85 _linux_options
=$_options_release
86 _windows_options
=$_options_release
89 _linux_options
="$_linux_asan $_options_debugmode"
90 _windows_options
="$_windows_asan $_options_debugmode"
93 titleit
"Creating Linux build"
94 mkdir
-p $_linux_folder/cfg
97 cp vg
/dep
/steam
/libsteam_api.so
$_linux_folder
98 link_content
$_linux_folder
100 _compiler
=$_linux_compiler
101 _options
=$_linux_options
103 compile_miniaudio linux
106 _folder
=$_linux_folder
111 _link
="$_linux_linkgraphics $_linux_linksteam"
112 _src
="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_linux.o"
117 titleit
"Creating Windows build"
118 mkdir
-p $_windows_folder/cfg
121 cp vg
/dep
/steam
/steam_api.dll
$_windows_folder
122 link_content
$_windows_folder
124 _compiler
=$_windows_compiler
125 _options
=$_windows_options
127 compile_miniaudio windows
131 _folder
=$_windows_folder
135 _link
="$_windows_linkgraphics $_windows_linksteam"
136 _src
="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_windows.o"
141 titleit
"Creating Server build"
142 mkdir
-p $_linux_server_folder/cfg
145 cp vg
/dep
/steam
/steamclient.so bin
/linux_server
/
146 cp vg
/dep
/steam
/libsteam_api.so bin
/linux_server
/
147 cp vg
/dep
/steam
/libsdkencryptedappticket.so bin
/linux_server
/
149 _compiler
=$_linux_compiler
150 _options
=$_linux_options
151 _link
="-lm -lsdkencryptedappticket $_linux_linksteam"
153 _folder
=$_linux_server_folder
154 _dst
="skaterift_server"
161 mkdir
-p bin
/aatest
/cfg
163 _compiler
=$_linux_compiler
164 _options
=$_linux_options
174 #TODO: These are not cross platform in the build script, a full build
175 # from source is therefore not possible on windows, only a linux
178 titleit
"Compiling textures"
179 mkdir
-p .
/bin
/content
/textures
180 for f
in .
/textures_src
/*.png
;
181 do logit
" qoiconv: $f";
182 dest
=.
/bin
/content
/textures
/"$(basename "$f" .png).qoi"
183 .
/bin
/linux
/tools
/qoiconv
$f $dest
187 logit
"Copying content"
188 mkdir
-p .
/bin
/content
/models
189 mkdir
-p .
/bin
/content
/sound
191 cp .
/models_src
/* .
/bin
/content
/models
/
192 cp .
/sound_src
/* .
/bin
/content
/sound
/
210 titleit
"Compressing distributions"
212 tar -chzvf dist
/skaterift_linux__
$TIMESTAMP.
tar.gz bin
/linux
/
214 tar -chzvf dist
/skaterift_server__
$TIMESTAMP.
tar.gz bin
/linux_server
216 tar -chzvf dist
/skaterift_win32__
$TIMESTAMP.
tar.gz bin
/win32
/
219 # ========================================================================
238 echo "Unrecognised command $1"
243 source vg
/vg_build.sh