2 # Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
5 vg_root
=`dirname $vg_root`
19 # ===========================================
21 echo -e "\033[1;31mError:\e[0m $@"
26 echo -e "\033[1;33mWarning:\e[0m $@"
30 echo -e "\033[1;32mSuccess:\e[0m $@"
34 echo -e "\033[0;37m$@\e[0m"
39 echo -e "\033[1;35m$@\e[0m"
40 echo "=========================="
44 if [[ -f vg.conf
]]; then
47 error
"Directory is not a VG project"
52 # ===========================================
56 target_compiler
="i686-w64-mingw32-gcc"
57 target_libs
="-lglfw3 -lopengl32 -lm -mwindows"
58 target_dir
="build.win32"
59 target_steam_api
="steam_api.dll"
60 if [ $opt_release = true
]; then
70 target_libs
="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl -lsteam_api"
71 target_dir
="build.linux"
72 target_steam_api
="libsteam_api.so"
73 if [ $opt_release = true
]; then
76 target_opts
="-fsanitize=address -ggdb3"
81 paths
="-I. -L$vg_root/dep/glfw -L$vg_root/dep/steam -I$vg_root/dep -I$vg_root/src"
82 setup
="$target_compiler $opt_gcc -Wall -Wstrict-aliasing=3 -Wno-unused-function $paths"
83 targets
="$1 $vg_root/dep/glad/glad.c -o $2$target_ext"
84 final
="$target_libs -Wl,-rpath=./ $opt_steam"
85 cmd
="$setup $target_opts $targets $final"
91 error
"compiler signaled fail"
95 success
"$2$target_ext built"
99 titleit
"Main build: $target_dir"
102 compile_x
$vg_src $target_dir/$vg_target
104 logit
"Setting up build structure"
107 mkdir
$target_dir/cfg
-p
108 mkdir
$target_dir/textures
-p
109 mkdir
$target_dir/sound
-p
110 mkdir
$target_dir/maps
-p
111 mkdir
$target_dir/sav
-p
114 if [ "$opt_steam" != "" ]; then
115 cp $vg_root/dep
/steam
/$target_steam_api $target_dir/$target_steam_api
118 # Clear and copy assets
119 rm -r $target_dir/textures
120 rm -r $target_dir/sound
121 rm -r $target_dir/maps
123 cp -r .temp_textures
$target_dir
124 mv $target_dir/.temp_textures
$target_dir/textures
125 cp -r sound
$target_dir
126 cp -r maps
$target_dir
130 # These should only be compiled for native platform
133 mkdir
$vg_root/bin
-p
135 compile_x
$vg_root/src
/fontcomp.c
$vg_root/bin
/fontcomp
136 compile_x
$vg_root/src
/texsheet.c
$vg_root/bin
/texsheet
137 compile_x
$vg_root/src
/qoiconv.c
$vg_root/bin
/qoiconv
142 [[ -d .temp_textures
]] && rm -r .temp_textures
145 # Convert all png to qoi
146 echo "Compile textures:"
147 for f
in textures
/*.png
;
149 $vg_root/bin
/qoiconv
$target_ext $f .temp_textures
/"$(basename "$f" .png).qoi"
152 # Autocombine textures
158 do logit
" combine: $f";
159 auto_combine
="$auto_combine $f"
161 $vg_root/bin
/texsheet
$taget_ext ..
/.temp_textures
/autocombine.qoi ..
/sprites_autocombine.h sprites_auto_combine
$auto_combine
166 echo "Compile fonts:"
167 $vg_root/bin
/fontcomp
$target_ext $vg_root/src
/fonts
/vg_font.png
$vg_root/src
/vg
/vg_pxfont.h
170 # ==============================================================
173 if [[ "$OSTYPE" != "linux-gnu"* ]]; then
182 longopts
=release
,build-linux
,build-windows
,steam
,play
,build-tools
,assets
,full
183 parsed
=$
(getopt
--options=$options --longoptions=$longopts --name "vgc" -- "$@")
185 if [ $?
-ne 0 ]; then
186 error
"getopt failed"
190 eval set -- "$parsed"
232 opt_steam
="-DVG_STEAM"
240 error
"programming error"
246 titleit
" vgc ver: $vg_version\n host: $host_os"
247 logit
" assets: $opt_assets"
248 logit
" release: $opt_release"
249 logit
" play: $opt_play"
250 logit
" build-linux: $opt_linux"
251 logit
"build-windows: $opt_windows"
252 logit
" build-tools: $opt_tools"
253 logit
" steam: $opt_steam"
257 if [ $opt_tools = true
]; then compile_tools
; fi
258 if [ $opt_assets = true
]; then compile_assets
; fi
259 if [ $opt_linux = true
]; then target_os_linux
; compile_main
; fi
260 if [ $opt_windows = true
]; then
264 cp $vg_root/dep
/glfw
/glfw3.dll
$target_dir/glfw3.dll
267 if [ $opt_play = true
]; then
269 if [ $host_os = linux
]; then
276 logit
"======= exec: $target_dir/$vg_target$target_ext ======="
280 .
/$vg_target$target_ext