X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=build.sh;h=63891f6238109708a1f33facbefb4dec890da946;hb=4694f19706f5176135b06329773ecd7e23aa2c5b;hp=2ce525a1cac803535b4d038cb65e2df3d356047c;hpb=2224e74bdfc8e19a2de99645246daf671d4323b4;p=fishladder.git diff --git a/build.sh b/build.sh index 2ce525a..63891f6 100755 --- a/build.sh +++ b/build.sh @@ -3,16 +3,28 @@ src="fishladder.c" target="fishladder" lib="-I. -L./lib -L./" -libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl" # -l:steam/libsteam_api.so" +libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl -l:steam/libsteam_api.so" flags="-fsanitize=address -ggdb3 -Wno-unused-function -DNO_STEAM" +build_dir="build.linux" + +if [[ "$OSTYPE" != "linux-gnu"* ]]; then + echo "Operating system is not GNU/Linux, windows will be assumed." + + target="fishladder.exe" + libs="-lglfw3 -lopengl32 -lm -mwindows" + flags="-ggdb3 -Wno-unused-function -DNO_STEAM" + build_dir="build.win32" +fi run_after=false do_build=true +compile_tools=false +compile_models=false while (( "$#" )); do case $1 in -r|--release) - flags="-O3" + flags="-O3 -Wno-unused-function" echo "Release mode" ;; -p|--play) @@ -23,6 +35,14 @@ while (( "$#" )); do do_build=false echo "no-build" ;; + -t|--tools) + compile_tools=true + echo "build-tools" + ;; + -m|--models) + compile_models=true + echo "build-models" + ;; *) echo "Unkown param: $1" exit 1 @@ -31,6 +51,32 @@ while (( "$#" )); do shift done +# Tools +if [ "$compile_tools" = true ]; then + echo "Building tools" + mkdir tools -p + gcc -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs -Wl,-rpath=./ $defines + gcc -Wall -Wstrict-aliasing=3 $lib $flags fontcomp.c gl/glad.c -o tools/fontcomp $libs -Wl,-rpath=./ $defines + gcc $lib qoiconv.c -std=c99 -O3 -o tools/qoiconv +fi + +# Resources +if [ "$compile_models" = true ]; then + echo "Recompiling models" + for f in models/*.obj; + do echo "Compiling $f.."; + ./tools/mdlcomp $f $f.h + done +fi + +# Convert all png to qoi +echo "Compiling textures" +mkdir _temp_textures +for f in textures/*.png; + do echo "-> qoi: $f"; + ./tools/qoiconv $f ./_temp_textures/"$(basename "$f" .png).qoi" +done + # Main build if [ "$do_build" = true ]; then gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs -Wl,-rpath=./ $defines @@ -43,18 +89,23 @@ if [ "$do_build" = true ]; then echo "Build succeeded" fi -# Directories to initialize -mkdir build.linux/cfg -p -mkdir build.linux/textures -p +mkdir $build_dir/cfg -p +mkdir $build_dir/textures -p +mkdir $build_dir/sound -p +mkdir $build_dir/maps -p +mkdir $build_dir/sav -p -cp $target ./build.linux/$target -cp ./steam/libsteam_api.so ./build.linux/libsteam_api.so -cp -r ./textures/ ./build.linux/ +cp $target $build_dir/$target +cp ./steam/libsteam_api.so $build_dir/libsteam_api.so +rm -r $build_dir/textures +mv ./_temp_textures/ $build_dir/textures +cp -r ./sound/ $build_dir +cp -r ./maps/ $build_dir if [ "$run_after" = true ]; then echo "Playing" - cd ./build.linux/ + cd $build_dir ./$target cd ./../ fi