1 # Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
3 cmd_lib_dir
="-I. -L./lib -L./"
6 cmd_target
="fishladder"
9 # ===========================================
11 echo -e "\033[1;31mError:\e[0m $@"
16 echo -e "\033[1;33mWarning:\e[0m $@"
20 echo -e "\033[1;32mSuccess:\e[0m $@"
24 echo -e "\033[0;37m$@\e[0m"
28 # ===========================================
32 target_compiler
="i686-w64-mingw32-gcc"
33 target_libs
="-lglfw3 -lopengl32 -lm -mwindows"
34 target_dir
="build.win32"
35 target_steam_api
="steam_api.dll"
36 if [ $cmd_release = true
]; then
46 target_libs
="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl"
47 target_dir
="build.linux"
48 target_steam_api
="libsteam_api.so"
49 if [ $cmd_release = true
]; then
52 target_opts
="-fsanitize=address -ggdb3"
57 cmd_setup
="$target_compiler -Wall -Wstrict-aliasing=3 -Wno-unused-function $cmd_lib_dir"
58 cmd_targets
="$1 gl/glad.c -o $2$target_ext"
59 cmd_final
="$target_libs -Wl,-rpath=./ $cmd_defines"
60 cmd
="$cmd_setup $target_opts $cmd_targets $cmd_final"
62 echo "Compile -> $2$target_ext:"
67 error
"compiler signaled fail"
71 success
"$2$target_ext built"
80 compile_x fishladder.c
$target_dir/$cmd_target
82 echo "Setting up build structure"
85 mkdir
$target_dir/cfg
-p
86 mkdir
$target_dir/textures
-p
87 mkdir
$target_dir/sound
-p
88 mkdir
$target_dir/maps
-p
89 mkdir
$target_dir/sav
-p
92 cp steam
/$target_steam_api $target_dir/$target_steam_api
94 # Clear and copy assets
95 rm -r $target_dir/textures
96 rm -r $target_dir/sound
97 rm -r $target_dir/maps
99 cp -r .temp_textures
$target_dir
100 mv $target_dir/.temp_textures
$target_dir/textures
101 cp -r sound
$target_dir
102 cp -r maps
$target_dir
104 success
"Build made: $target_dir"
108 # These should only be compiled for native platform
110 echo "compile_tools()"
113 compile_x fontcomp.c tools
/fontcomp
114 compile_x texsheet.c tools
/texsheet
115 compile_x qoiconv.c tools
/qoiconv
120 echo "compile_assets()"
121 [[ -d .temp_textures
]] && rm -r .temp_textures
124 # Convert all png to qoi
125 echo "Compile textures:"
126 for f
in textures
/*.png
;
128 .
/tools
/qoiconv
$target_ext $f .temp_textures
/"$(basename "$f" .png).qoi"
131 # Autocombine textures
137 do logit
" combine: $f";
138 auto_combine
="$auto_combine $f"
140 ..
/tools
/texsheet
$taget_ext ..
/.temp_textures
/autocombine.qoi ..
/sprites_autocombine.h sprites_auto_combine
$auto_combine
145 echo "Compile fonts:"
146 .
/tools
/fontcomp
$target_ext fonts
/vg_font.png vg
/vg_pxfont.h
149 # ==============================================================
152 if [[ "$OSTYPE" != "linux-gnu"* ]]; then
153 echo "Host: Microsoft Windows (implied)"
157 echo "Host: GNU/Linux"
167 echo " + Release Mode"
170 cmd_defines
="-DVG_NO_STEAM"
171 echo " + Disable steam"
187 # Extra glfw.dll copy step
188 cp glfw
/glfw3.dll
$target_dir/glfw3.dll
191 if [ $host_is_linux ]; then
198 logit
"======= exec: $target_dir/$cmd_target$target_ext ======="
206 echo "Unkown param: $1"
214 logit
"cleaning up..."