From b8ce05b34d018f52a190b6be837f9693a983b771 Mon Sep 17 00:00:00 2001 From: hgn Date: Tue, 9 Aug 2022 11:32:04 +0100 Subject: [PATCH] improved build --- .gitignore | 5 +- build.sh | 236 +++++++++++++----- {models => models_src}/cement_r1.mdl | Bin {models => models_src}/ch_anim.mdl | Bin {models => models_src}/ch_default.mdl | Bin {models => models_src}/ch_mike.mdl | Bin {models => models_src}/ch_outlaw.mdl | Bin {models => models_src}/ch_suitman.mdl | Bin {models => models_src}/char_dev.mdl | Bin {models => models_src}/cubeh.mdl | Bin {models => models_src}/epic_scene.mdl | Bin {models => models_src}/export 10.mdl | Bin {models => models_src}/export 8.mdl | Bin {models => models_src}/free_dev.mdl | Bin {models => models_src}/mp_cliff.mdl | Bin {models => models_src}/mp_demo.mdl | Bin {models => models_src}/mp_dev.mdl | Bin {models => models_src}/mp_works.mdl | Bin {models => models_src}/rs_cars.mdl | Bin {models => models_src}/rs_chicken.mdl | Bin {models => models_src}/rs_foliage.mdl | Bin {models => models_src}/rs_gate.mdl | Bin {models => models_src}/rs_scoretext.mdl | Bin {models => models_src}/rs_skydome.mdl | Bin {models => models_src}/rs_vig.mdl | Bin {models => models_src}/skydome.mdl | Bin {models => models_src}/test.mdl | 0 shaders.sh | 16 ++ {sound => sound_src}/skate.ogg | Bin {sound => sound_src}/slide.ogg | Bin {sound => sound_src}/wheel.ogg | Bin {textures => textures_src}/alphatest.png | Bin {textures => textures_src}/cement512.png | Bin {textures => textures_src}/ch_gradient.png | Bin {textures => textures_src}/garbage.png | Bin {textures => textures_src}/gradients.png | Bin {textures => textures_src}/grid.png | Bin {textures => textures_src}/grid_terrain.png | Bin {textures => textures_src}/norway_foliage.png | Bin {textures => textures_src}/norwey.png | Bin {textures => textures_src}/road.png | Bin {textures => textures_src}/scoretext.png | Bin {textures => textures_src}/sky.png | Bin {textures => textures_src}/water.png | Bin {textures => textures_src}/water_surf.png | Bin 45 files changed, 190 insertions(+), 67 deletions(-) rename {models => models_src}/cement_r1.mdl (100%) rename {models => models_src}/ch_anim.mdl (100%) rename {models => models_src}/ch_default.mdl (100%) rename {models => models_src}/ch_mike.mdl (100%) rename {models => models_src}/ch_outlaw.mdl (100%) rename {models => models_src}/ch_suitman.mdl (100%) rename {models => models_src}/char_dev.mdl (100%) rename {models => models_src}/cubeh.mdl (100%) rename {models => models_src}/epic_scene.mdl (100%) rename {models => models_src}/export 10.mdl (100%) rename {models => models_src}/export 8.mdl (100%) rename {models => models_src}/free_dev.mdl (100%) rename {models => models_src}/mp_cliff.mdl (100%) rename {models => models_src}/mp_demo.mdl (100%) rename {models => models_src}/mp_dev.mdl (100%) rename {models => models_src}/mp_works.mdl (100%) rename {models => models_src}/rs_cars.mdl (100%) rename {models => models_src}/rs_chicken.mdl (100%) rename {models => models_src}/rs_foliage.mdl (100%) rename {models => models_src}/rs_gate.mdl (100%) rename {models => models_src}/rs_scoretext.mdl (100%) rename {models => models_src}/rs_skydome.mdl (100%) rename {models => models_src}/rs_vig.mdl (100%) rename {models => models_src}/skydome.mdl (100%) rename {models => models_src}/test.mdl (100%) create mode 100644 shaders.sh rename {sound => sound_src}/skate.ogg (100%) rename {sound => sound_src}/slide.ogg (100%) rename {sound => sound_src}/wheel.ogg (100%) rename {textures => textures_src}/alphatest.png (100%) rename {textures => textures_src}/cement512.png (100%) rename {textures => textures_src}/ch_gradient.png (100%) rename {textures => textures_src}/garbage.png (100%) rename {textures => textures_src}/gradients.png (100%) rename {textures => textures_src}/grid.png (100%) rename {textures => textures_src}/grid_terrain.png (100%) rename {textures => textures_src}/norway_foliage.png (100%) rename {textures => textures_src}/norwey.png (100%) rename {textures => textures_src}/road.png (100%) rename {textures => textures_src}/scoretext.png (100%) rename {textures => textures_src}/sky.png (100%) rename {textures => textures_src}/water.png (100%) rename {textures => textures_src}/water_surf.png (100%) diff --git a/.gitignore b/.gitignore index b02fe58..988d57d 100755 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,9 @@ * !*/ -build.linux/ -build.win32/ +bin/ restricted/ -.temp_textures/ +dist/ # ALLOW ============================ !.gitattributes diff --git a/build.sh b/build.sh index 26b2fe1..d7ea276 100755 --- a/build.sh +++ b/build.sh @@ -8,14 +8,14 @@ _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_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_release="-O3 -DVG_RELEASE" @@ -32,17 +32,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 +47,185 @@ compile_miniaudio(){ _options=$temp_options } -game() { - _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 +# Again, these are not cross platform currently +# TODO +run_game(){ + cd $_linux_folder + ./skaterift + cd ./../ } -game_windows() { - _compiler=$_windows_compiler - _options=$_windows_options +run_server(){ + cd $_linux_server_folder + ./skaterift_server + cd ./../ +} - compile_miniaudio windows +delay_run_game(){ + sleep 2 + run_game +} - # 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 +#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" } - -server() { - _compiler=$_linux_compiler - _options=$_linux_options - _link="-lm $_linux_linksteam" - _folder="$_linux_server_folder" - _src="server.c" - _dst="skaterift_server" - _ext="" - compile_x +compile_shaders(){ + titleit "Compiling shaders" + source shaders.sh + cd shaders + ../bin/linux/tools/shader $target_shaders + cd .. } -all() { - tools - game - server +link_content(){ + ln -sr bin/content/textures/ $1/textures + ln -sr bin/content/models/ $1/models + ln -sr bin/content/sound/ $1/sound } -distribution(){ - release - tools - game - game_windows - server +TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` + +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 + + _compiler=$_linux_compiler + _options=$_linux_options + + compile_miniaudio linux + + # Game tools + _folder=$_linux_folder + _ext="" + vg_compile_tools + compile_shaders + + # 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/ + + _compiler=$_linux_compiler + _options=$_linux_options + _link="-lm $_linux_linksteam" + _src="server.c" + _folder=$_linux_server_folder + _dst="skaterift_server" + _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 + ;; + distribution) + 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 + + 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/ + ;; + # Runners + # ======================================================================== + test) + run_game + ;; + testnet) + delay_run_game & + run_server + wait + ;; + *) + echo "Unrecognised command $1" + esac } +vg_command debug source vg/vg_build.sh diff --git a/models/cement_r1.mdl b/models_src/cement_r1.mdl similarity index 100% rename from models/cement_r1.mdl rename to models_src/cement_r1.mdl diff --git a/models/ch_anim.mdl b/models_src/ch_anim.mdl similarity index 100% rename from models/ch_anim.mdl rename to models_src/ch_anim.mdl diff --git a/models/ch_default.mdl b/models_src/ch_default.mdl similarity index 100% rename from models/ch_default.mdl rename to models_src/ch_default.mdl diff --git a/models/ch_mike.mdl b/models_src/ch_mike.mdl similarity index 100% rename from models/ch_mike.mdl rename to models_src/ch_mike.mdl diff --git a/models/ch_outlaw.mdl b/models_src/ch_outlaw.mdl similarity index 100% rename from models/ch_outlaw.mdl rename to models_src/ch_outlaw.mdl diff --git a/models/ch_suitman.mdl b/models_src/ch_suitman.mdl similarity index 100% rename from models/ch_suitman.mdl rename to models_src/ch_suitman.mdl diff --git a/models/char_dev.mdl b/models_src/char_dev.mdl similarity index 100% rename from models/char_dev.mdl rename to models_src/char_dev.mdl diff --git a/models/cubeh.mdl b/models_src/cubeh.mdl similarity index 100% rename from models/cubeh.mdl rename to models_src/cubeh.mdl diff --git a/models/epic_scene.mdl b/models_src/epic_scene.mdl similarity index 100% rename from models/epic_scene.mdl rename to models_src/epic_scene.mdl diff --git a/models/export 10.mdl b/models_src/export 10.mdl similarity index 100% rename from models/export 10.mdl rename to models_src/export 10.mdl diff --git a/models/export 8.mdl b/models_src/export 8.mdl similarity index 100% rename from models/export 8.mdl rename to models_src/export 8.mdl diff --git a/models/free_dev.mdl b/models_src/free_dev.mdl similarity index 100% rename from models/free_dev.mdl rename to models_src/free_dev.mdl diff --git a/models/mp_cliff.mdl b/models_src/mp_cliff.mdl similarity index 100% rename from models/mp_cliff.mdl rename to models_src/mp_cliff.mdl diff --git a/models/mp_demo.mdl b/models_src/mp_demo.mdl similarity index 100% rename from models/mp_demo.mdl rename to models_src/mp_demo.mdl diff --git a/models/mp_dev.mdl b/models_src/mp_dev.mdl similarity index 100% rename from models/mp_dev.mdl rename to models_src/mp_dev.mdl diff --git a/models/mp_works.mdl b/models_src/mp_works.mdl similarity index 100% rename from models/mp_works.mdl rename to models_src/mp_works.mdl diff --git a/models/rs_cars.mdl b/models_src/rs_cars.mdl similarity index 100% rename from models/rs_cars.mdl rename to models_src/rs_cars.mdl diff --git a/models/rs_chicken.mdl b/models_src/rs_chicken.mdl similarity index 100% rename from models/rs_chicken.mdl rename to models_src/rs_chicken.mdl diff --git a/models/rs_foliage.mdl b/models_src/rs_foliage.mdl similarity index 100% rename from models/rs_foliage.mdl rename to models_src/rs_foliage.mdl diff --git a/models/rs_gate.mdl b/models_src/rs_gate.mdl similarity index 100% rename from models/rs_gate.mdl rename to models_src/rs_gate.mdl diff --git a/models/rs_scoretext.mdl b/models_src/rs_scoretext.mdl similarity index 100% rename from models/rs_scoretext.mdl rename to models_src/rs_scoretext.mdl diff --git a/models/rs_skydome.mdl b/models_src/rs_skydome.mdl similarity index 100% rename from models/rs_skydome.mdl rename to models_src/rs_skydome.mdl diff --git a/models/rs_vig.mdl b/models_src/rs_vig.mdl similarity index 100% rename from models/rs_vig.mdl rename to models_src/rs_vig.mdl diff --git a/models/skydome.mdl b/models_src/skydome.mdl similarity index 100% rename from models/skydome.mdl rename to models_src/skydome.mdl diff --git a/models/test.mdl b/models_src/test.mdl similarity index 100% rename from models/test.mdl rename to models_src/test.mdl diff --git a/shaders.sh b/shaders.sh new file mode 100644 index 0000000..2ebc67b --- /dev/null +++ b/shaders.sh @@ -0,0 +1,16 @@ +shader blit blit.vs blit.fs +shader fscolour blit.vs colour.fs +shader terrain standard.vs terrain.fs +shader vblend standard.vs vblend.fs +shader alphatest standard.vs std_alphatest.fs +shader standard standard.vs standard.fs +shader unlit standard.vs unlit.fs +shader character character.vs character.fs +shader gate gate.vs gate.fs +shader gatelq gate.vs gate_lq.fs +shader water standard.vs water.fs +shader sky standard.vs sky.fs +shader planeinf standard.vs planeinf.fs +shader gpos standard.vs gpos.fs +shader route standard.vs route.fs +shader scoretext scoretext.vs vblend.fs diff --git a/sound/skate.ogg b/sound_src/skate.ogg similarity index 100% rename from sound/skate.ogg rename to sound_src/skate.ogg diff --git a/sound/slide.ogg b/sound_src/slide.ogg similarity index 100% rename from sound/slide.ogg rename to sound_src/slide.ogg diff --git a/sound/wheel.ogg b/sound_src/wheel.ogg similarity index 100% rename from sound/wheel.ogg rename to sound_src/wheel.ogg diff --git a/textures/alphatest.png b/textures_src/alphatest.png similarity index 100% rename from textures/alphatest.png rename to textures_src/alphatest.png diff --git a/textures/cement512.png b/textures_src/cement512.png similarity index 100% rename from textures/cement512.png rename to textures_src/cement512.png diff --git a/textures/ch_gradient.png b/textures_src/ch_gradient.png similarity index 100% rename from textures/ch_gradient.png rename to textures_src/ch_gradient.png diff --git a/textures/garbage.png b/textures_src/garbage.png similarity index 100% rename from textures/garbage.png rename to textures_src/garbage.png diff --git a/textures/gradients.png b/textures_src/gradients.png similarity index 100% rename from textures/gradients.png rename to textures_src/gradients.png diff --git a/textures/grid.png b/textures_src/grid.png similarity index 100% rename from textures/grid.png rename to textures_src/grid.png diff --git a/textures/grid_terrain.png b/textures_src/grid_terrain.png similarity index 100% rename from textures/grid_terrain.png rename to textures_src/grid_terrain.png diff --git a/textures/norway_foliage.png b/textures_src/norway_foliage.png similarity index 100% rename from textures/norway_foliage.png rename to textures_src/norway_foliage.png diff --git a/textures/norwey.png b/textures_src/norwey.png similarity index 100% rename from textures/norwey.png rename to textures_src/norwey.png diff --git a/textures/road.png b/textures_src/road.png similarity index 100% rename from textures/road.png rename to textures_src/road.png diff --git a/textures/scoretext.png b/textures_src/scoretext.png similarity index 100% rename from textures/scoretext.png rename to textures_src/scoretext.png diff --git a/textures/sky.png b/textures_src/sky.png similarity index 100% rename from textures/sky.png rename to textures_src/sky.png diff --git a/textures/water.png b/textures_src/water.png similarity index 100% rename from textures/water.png rename to textures_src/water.png diff --git a/textures/water_surf.png b/textures_src/water_surf.png similarity index 100% rename from textures/water_surf.png rename to textures_src/water_surf.png -- 2.25.1