X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=build.sh;h=fad620190cce6a31a17c14c4b1dc5b418e1efe7f;hb=47941822dae18a018c985847b052e70214a3ccc6;hp=26b2fe10222f5ec4df04481a45f82ae568349f32;hpb=91d035f4845a6f9f62487b43e5142c4148e7f047;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/build.sh b/build.sh index 26b2fe1..fad6201 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,12 @@ #!/bin/bash -# Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved - +# +# Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved +# +# Main cross-compiling build script for Skate Rift +# Supports Linux and Windows building from a Linux Host +# +# vg must be "ln -s"'d into this src folder as the only dependency +# # Compiler Presets # ============================================================================== @@ -8,16 +14,16 @@ _linux_compiler="gcc -std=c99 -D_REENTRANT" _linux_linkgraphics="-lGL -lglfw3 -lX11 -lXxf86vm -lXrandr -lm -pthread -lXi -ldl" _linux_asan="-fsanitize=address" _linux_linksteam="-lsteam_api" -_linux_folder="build.linux" -_linux_server_folder="build.linux_server" +_linux_folder="bin/linux" +_linux_server_folder="bin/linux_server" _windows_compiler="i686-w64-mingw32-gcc" -_windows_linkgraphics="-lglfw3dll -lopengl32 -lm -mwindows" +_windows_linkgraphics="-lglfw3dll -lopengl32 -lm -pthread -static -mwindows" _windows_asan="" _windows_linksteam="vg/dep/steam/steam_api.dll" -_windows_folder="build.win32" +_windows_folder="bin/win32" -_options_debugmode="-O0 -ggdb3 -fno-omit-frame-pointer" +_options_debugmode="-O0 -ggdb3 -fno-omit-frame-pointer -rdynamic" _options_release="-O3 -DVG_RELEASE" # Compiler lines @@ -32,17 +38,6 @@ _ext="" # Compile scripts # ============================================================================== -release(){ - _linux_options=$_options_release - _windows_options=$_options_release -} - -debug(){ - _linux_options="$_linux_asan $_options_debugmode" - _windows_options="$_windows_asan $_options_debugmode" -} -debug - compile_miniaudio(){ temp_options=$_options @@ -58,66 +53,207 @@ compile_miniaudio(){ _options=$temp_options } -game() { - _compiler=$_linux_compiler - _options=$_linux_options - - compile_miniaudio linux +# Again, these are not cross platform currently +# TODO +run_game(){ + cd $_linux_folder + ./skaterift --samples=4 + cd ./../ +} - # Game tools - _folder="$_linux_folder" - _ext="" - vg_compile_tools - - # Main build - _link="$_linux_linkgraphics $_linux_linksteam" - _src="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_linux.o" - _dst="skaterift" - compile_x +run_server(){ + cd $_linux_server_folder + ./skaterift_server + cd ./../ } -game_windows() { - _compiler=$_windows_compiler - _options=$_windows_options +delay_run_game(){ + sleep 2 + run_game +} - compile_miniaudio windows +link_content(){ + unlink $1/textures + unlink $1/models + unlink $1/sound - # Game tools - _folder="$_windows_folder" - _ext=".exe" - vg_compile_tools - - # Main build - _link="$_windows_linkgraphics $_windows_linksteam" - _src="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_windows.o" - _dst="skaterift" - compile_x + ln -srf bin/content/textures $1/textures + ln -srf bin/content/models $1/models + ln -srf bin/content/sound $1/sound } - -server() { - _compiler=$_linux_compiler - _options=$_linux_options - _link="-lm $_linux_linksteam" - _folder="$_linux_server_folder" - _src="server.c" - _dst="skaterift_server" - _ext="" - compile_x -} +TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` -all() { - tools - game - server -} +vg_command(){ + case "$1" in + release) + _linux_options=$_options_release + _windows_options=$_options_release + ;; + debug) + _linux_options="$_linux_asan $_options_debugmode" + _windows_options="$_windows_asan $_options_debugmode" + ;; + game) + titleit "Creating Linux build" + mkdir -p $_linux_folder/cfg + + # Dependencies + cp vg/dep/steam/libsteam_api.so $_linux_folder + link_content $_linux_folder -distribution(){ - release - tools - game - game_windows - server + _compiler=$_linux_compiler + _options=$_linux_options + + compile_miniaudio linux + + # Game tools + _folder=$_linux_folder + _ext="" + vg_compile_tools + + # Main build + _link="$_linux_linkgraphics $_linux_linksteam" + _src="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_linux.o" + _dst="skaterift" + compile_x + ;; + game_win) + titleit "Creating Windows build" + mkdir -p $_windows_folder/cfg + + # Dependencies + cp vg/dep/steam/steam_api.dll $_windows_folder + link_content $_windows_folder + + _compiler=$_windows_compiler + _options=$_windows_options + + compile_miniaudio windows + + # Game tools + _ext=".exe" + _folder=$_windows_folder + vg_compile_tools + + # Main build + _link="$_windows_linkgraphics $_windows_linksteam" + _src="main.c vg/dep/glad/glad.c vg/dep/dr_soft/miniaudio_windows.o" + _dst="skaterift" + compile_x + ;; + server) + titleit "Creating Server build" + mkdir -p $_linux_server_folder/cfg + + # Dependencies + cp vg/dep/steam/steamclient.so bin/linux_server/ + cp vg/dep/steam/libsteam_api.so bin/linux_server/ + cp vg/dep/steam/libsdkencryptedappticket.so bin/linux_server/ + + _compiler=$_linux_compiler + _options=$_linux_options + _link="-pthread -lm -lsdkencryptedappticket $_linux_linksteam" + _src="server.c" + _folder=$_linux_server_folder + _dst="skaterift_server" + _ext="" + + compile_x + ;; + testaa) + titleit "Dev" + mkdir -p bin/aatest/cfg + + _compiler=$_linux_compiler + _options=$_linux_options + _link="-lm" + _src="testaa.c" + _folder=bin/aatest + _dst="testaa" + _ext="" + + compile_x + ;; + + #TODO: These are not cross platform in the build script, a full build + # from source is therefore not possible on windows, only a linux + # host can do that. + textures) + titleit "Compiling textures" + mkdir -p ./bin/content/textures + for f in ./textures_src/*.png; + do logit " qoiconv: $f"; + dest=./bin/content/textures/"$(basename "$f" .png).qoi" + ./bin/linux/tools/qoiconv $f $dest + done + ;; + content) + logit "Copying content" + mkdir -p ./bin/content/models + mkdir -p ./bin/content/sound + + cp ./models_src/* ./bin/content/models/ + cp ./sound_src/* ./bin/content/sound/ + ;; + + all) + run_command tools + run_command game + run_command server + ;; + disb) + mkdir -p ./dist + run_command release + run_command tools + run_command game + run_command game_win + run_command content + run_command textures + run_command server + ;; + + distribution) + titleit "Compressing distributions" + logit "Linux" + tar -chzvf dist/skaterift_linux__$TIMESTAMP.tar.gz bin/linux/ + logit "Server" + tar -chzvf dist/skaterift_server__$TIMESTAMP.tar.gz bin/linux_server + logit "Windows" + tar -chzvf dist/skaterift_win32__$TIMESTAMP.tar.gz bin/win32/ + zip -r9 dist/skaterift_win32__$TIMESTAMP.zip bin/win32/ + ;; + # Runners + # ======================================================================== + test) + run_game + ;; + gdb) + cd $_linux_folder + gdb -tui ./skaterift + cd ./../ + ;; + testserver) + run_server + ;; + testnet) + delay_run_game & + run_server + wait + ;; + aa) + run_command testaa + cd bin/aatest + ./testaa + cd ./../ + ;; + *) + echo "Unrecognised command $1" + esac } +lsan_file=$(realpath ".lsan_suppress.txt") +export LSAN_OPTIONS="suppressions=$lsan_file" + +vg_command debug source vg/vg_build.sh