X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=build.sh;h=0228534080bc83d6aee13c56acbaa198e065ba1d;hb=bdac014448b6ec968fe645f1581f321144f07dba;hp=d7ea276397084ac89b6e5144db45787f48d2e3f7;hpb=b8ce05b34d018f52a190b6be837f9693a983b771;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/build.sh b/build.sh index d7ea276..0228534 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,16 @@ #!/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 # ============================================================================== -_linux_compiler="gcc -std=c99 -D_REENTRANT" +_linux_compiler="clang -std=c99 -D_REENTRANT" _linux_linkgraphics="-lGL -lglfw3 -lX11 -lXxf86vm -lXrandr -lm -pthread -lXi -ldl" _linux_asan="-fsanitize=address" _linux_linksteam="-lsteam_api" @@ -12,12 +18,12 @@ _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="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 @@ -51,7 +57,7 @@ compile_miniaudio(){ # TODO run_game(){ cd $_linux_folder - ./skaterift + ./skaterift --samples=4 cd ./../ } @@ -66,27 +72,14 @@ delay_run_game(){ run_game } -#TODO: Make this a seperate script -# it should not be called compile, rename to 'generate' shader headers, -# its a code writing tool, not a compiling tool -# -target_shaders="" -shader(){ - target_shaders="$target_shaders $1 $2 $3" -} - -compile_shaders(){ - titleit "Compiling shaders" - source shaders.sh - cd shaders - ../bin/linux/tools/shader $target_shaders - cd .. -} - link_content(){ - ln -sr bin/content/textures/ $1/textures - ln -sr bin/content/models/ $1/models - ln -sr bin/content/sound/ $1/sound + unlink $1/textures + unlink $1/models + unlink $1/sound + + ln -srf bin/content/textures $1/textures + ln -srf bin/content/models $1/models + ln -srf bin/content/sound $1/sound } TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` @@ -101,6 +94,14 @@ vg_command(){ _linux_options="$_linux_asan $_options_debugmode" _windows_options="$_windows_asan $_options_debugmode" ;; + ltools) + _compiler=$_linux_compiler + _options=$_linux_options + _folder=$_linux_folder + _ext="" + vg_compile_tools + + ;; game) titleit "Creating Linux build" mkdir -p $_linux_folder/cfg @@ -118,7 +119,6 @@ vg_command(){ _folder=$_linux_folder _ext="" vg_compile_tools - compile_shaders # Main build _link="$_linux_linkgraphics $_linux_linksteam" @@ -156,10 +156,12 @@ vg_command(){ # 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="-lm $_linux_linksteam" + _link="-pthread -lm -lsdkencryptedappticket $_linux_linksteam" _src="server.c" _folder=$_linux_server_folder _dst="skaterift_server" @@ -167,6 +169,20 @@ vg_command(){ 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 @@ -180,13 +196,24 @@ vg_command(){ ./bin/linux/tools/qoiconv $f $dest done ;; + sounds) + titleit "Compiling sounds" + mkdir -p ./bin/content/textures + + for f in ./sound_src/*.wav + do + dest=./bin/content/sounds/"$(basename "$f" .wav).44100.ima_adpcm" + ./bin/linux/tools/audcomp $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/ + #cp ./sound_src/* ./bin/content/sound/ ;; all) @@ -194,7 +221,7 @@ vg_command(){ run_command game run_command server ;; - distribution) + disb) mkdir -p ./dist run_command release run_command tools @@ -203,7 +230,9 @@ vg_command(){ 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/ @@ -211,21 +240,39 @@ vg_command(){ 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