cleaned up world edges (revision)
[fishladder.git] / build.sh
index 9acfd368af55f6fde749dff7598d3e200089d5e9..aa0d03e0c21f5fa1d6b07d7fa6ac41469bc05692 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -3,31 +3,42 @@
 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"
-flags="-fsanitize=address -ggdb3 -Wno-unused-function -DNO_STEAM"
+libs="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl"
+steam_part="-l:steam/libsteam_api.so"
+flags="-fsanitize=address -ggdb3 -Wno-unused-function"
+build_dir="build.linux"
+steam_api="libsteam_api.so"
 
 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"
+       flags="-ggdb3 -Wno-unused-function"
+       build_dir="build.win32"
+       steam_api="steam_api.dll"
 fi
 
 run_after=false
 do_build=true
 compile_tools=false
-compile_models=false
+#compile_models=false
 
 while (( "$#" )); do
        case $1 in
                -r|--release) 
-                       flags="-O3"
+                       flags="-O3 -Wno-unused-function"
                        echo "Release mode" 
                ;;
                -p|--play)
                        run_after=true 
                        echo "& Run" 
                ;;
+               -s|--no-steam)
+                       steam_part=""
+                       defines="-DNO_STEAM"
+                       echo "no-steam"
+               ;;
                -n|--nobuild)
                        do_build=false
                        echo "no-build"
@@ -36,10 +47,10 @@ while (( "$#" )); do
                        compile_tools=true
                        echo "build-tools"
                ;;
-               -m|--models)
-                       compile_models=true
-                       echo "build-models"
-               ;;
+               #-m|--models)
+               #       compile_models=true
+               #       echo "build-models"
+               #;;
                *) 
                        echo "Unkown param: $1" 
                        exit 1
@@ -52,22 +63,31 @@ done
 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 -Wall -Wstrict-aliasing=3 $lib $flags mdlcomp.c gl/glad.c -o tools/mdlcomp $libs $steam_part -Wl,-rpath=./ $defines
+       gcc -Wall -Wstrict-aliasing=3 $lib $flags fontcomp.c gl/glad.c -o tools/fontcomp $libs $steam_part -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
+mkdir _temp_textures
+# Convert all png to qoi
+echo "Compiling textures"
+for f in textures/*.png;
+       do echo "-> qoi: $f";
+       ./tools/qoiconv $f ./_temp_textures/"$(basename "$f" .png).qoi"
+done
+
+#if [ "$compile_models" = true ]; then
+#      echo "Recompiling models"
+#      for f in models/*.obj; 
+#              do echo "Compiling $f..";
+#              ./tools/mdlcomp $f $f.h
+#      done
+#fi
 
 # Main build
 if [ "$do_build" = true ]; then
-       gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs -Wl,-rpath=./ $defines
+       gcc -Wall -Wstrict-aliasing=3 $lib $flags $src gl/glad.c -o $target $libs $steam_part -Wl,-rpath=./ $defines
 
        if [ $? -ne 0 ]; then
                echo "GCC build failed"
@@ -77,39 +97,23 @@ if [ "$do_build" = true ]; then
        echo "Build succeeded"
 fi
 
-if [[ "$OSTYPE" == "linux-gnu"* ]]; then
-       # Directories to initialize
-       mkdir build.linux/cfg -p
-       mkdir build.linux/textures -p
-       mkdir build.linux/sound -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 -r ./sound/ ./build.linux/
+cp $target $build_dir/$target
+cp ./steam/$steam_api $build_dir/$steam_api
+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"
+if [ "$run_after" = true ]; then
+       echo "Playing"
 
-               cd ./build.linux/
-               ./$target
-               cd ./../
-       fi
-else
-       mkdir build.win32/cfg -p
-       mkdir build.win32/textures -p
-       mkdir build.win32/sound -p
-       
-       cp $target ./build.win32/$target
-       cp -r ./textures/ ./build.win32/
-       cp -r ./sound/ ./build.win32/
-       cp ./lib/glfw3.dll ./build.win32/glfw3.dll
-       
-       if [ "$run_after" = true ]; then
-               echo "Playing"
-               
-               cd ./build.win32/
-               ./$target
-               cd ./../
-       fi
+       cd $build_dir
+       ./$target
+       cd ./../
 fi