2 # Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
5 vg_root
=`dirname $vg_root`
7 #echo "VG Root: $vg_root"
8 #echo "Working dir: `pwd`"
10 cmd_lib_dir
="-I. -L$vg_root/lib -L./ -I$vg_root"
13 cmd_target
="fishladder"
16 # ===========================================
18 echo -e "\033[1;31mError:\e[0m $@"
23 echo -e "\033[1;33mWarning:\e[0m $@"
27 echo -e "\033[1;32mSuccess:\e[0m $@"
31 echo -e "\033[0;37m$@\e[0m"
35 # ===========================================
39 target_compiler
="i686-w64-mingw32-gcc"
40 target_libs
="-lglfw3 -lopengl32 -lm -mwindows"
41 target_dir
="build.win32"
42 target_steam_api
="steam_api.dll"
43 if [ $cmd_release = true
]; then
53 target_libs
="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl"
54 target_dir
="build.linux"
55 target_steam_api
="libsteam_api.so"
56 if [ $cmd_release = true
]; then
59 target_opts
="-fsanitize=address -ggdb3"
64 cmd_setup
="$target_compiler -Wall -Wstrict-aliasing=3 -Wno-unused-function $cmd_lib_dir"
65 cmd_targets
="$1 ${vg_root}/gl/glad.c -o $2$target_ext"
66 cmd_final
="$target_libs -Wl,-rpath=./ $cmd_defines"
67 cmd
="$cmd_setup $target_opts $cmd_targets $cmd_final"
69 echo "Compile -> $2$target_ext:"
74 error
"compiler signaled fail"
78 success
"$2$target_ext built"
87 compile_x fishladder.c
$target_dir/$cmd_target
89 echo "Setting up build structure"
92 mkdir
$target_dir/cfg
-p
93 mkdir
$target_dir/textures
-p
94 mkdir
$target_dir/sound
-p
95 mkdir
$target_dir/maps
-p
96 mkdir
$target_dir/sav
-p
99 cp $vg_root/steam
/$target_steam_api $target_dir/$target_steam_api
101 # Clear and copy assets
102 rm -r $target_dir/textures
103 rm -r $target_dir/sound
104 rm -r $target_dir/maps
106 cp -r .temp_textures
$target_dir
107 mv $target_dir/.temp_textures
$target_dir/textures
108 cp -r sound
$target_dir
109 cp -r maps
$target_dir
111 success
"Build made: $target_dir"
115 # These should only be compiled for native platform
117 echo "compile_tools()"
120 compile_x
$vg_root/fontcomp.c tools
/fontcomp
121 compile_x
$vg_root/texsheet.c tools
/texsheet
122 compile_x
$vg_root/qoiconv.c tools
/qoiconv
127 echo "compile_assets()"
128 [[ -d .temp_textures
]] && rm -r .temp_textures
131 # Convert all png to qoi
132 echo "Compile textures:"
133 for f
in textures
/*.png
;
135 .
/tools
/qoiconv
$target_ext $f .temp_textures
/"$(basename "$f" .png).qoi"
138 # Autocombine textures
144 do logit
" combine: $f";
145 auto_combine
="$auto_combine $f"
147 ..
/tools
/texsheet
$taget_ext ..
/.temp_textures
/autocombine.qoi ..
/sprites_autocombine.h sprites_auto_combine
$auto_combine
152 echo "Compile fonts:"
153 .
/tools
/fontcomp
$target_ext $vg_root/fonts
/vg_font.png
$vg_root/vg
/vg_pxfont.h
156 # ==============================================================
159 if [[ "$OSTYPE" != "linux-gnu"* ]]; then
160 echo "Host: Microsoft Windows (implied)"
164 echo "Host: GNU/Linux"
176 cmd_defines
="-DVG_NO_STEAM"
192 # Extra glfw.dll copy step
193 cp $vg_root/glfw
/glfw3.dll
$target_dir/glfw3.dll
196 if [ $host_is_linux ]; then
203 logit
"======= exec: $target_dir/$cmd_target$target_ext ======="
211 echo "Unkown param: $1"
219 logit
"cleaning up..."