2 # Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
5 vg_root
=`dirname $vg_root`
18 # ===========================================
20 echo -e "\033[1;31mError:\e[0m $@"
25 echo -e "\033[1;33mWarning:\e[0m $@"
29 echo -e "\033[1;32mSuccess:\e[0m $@"
33 echo -e "\033[0;37m$@\e[0m"
38 echo -e "\033[1;35m$@\e[0m"
39 echo "=========================="
43 if [[ -f vg.conf
]]; then
46 error
"Directory is not a VG project"
51 # ===========================================
55 target_compiler
="i686-w64-mingw32-gcc"
56 target_libs
="-lglfw3 -lopengl32 -lm -mwindows"
57 target_dir
="build.win32"
58 target_steam_api
="steam_api.dll"
59 if [ $opt_release = true
]; then
69 target_libs
="-lGL -lglfw -lX11 -lXxf86vm -lXrandr -lm -lpthread -lXi -ldl"
70 target_dir
="build.linux"
71 target_steam_api
="libsteam_api.so"
72 if [ $opt_release = true
]; then
75 target_opts
="-fsanitize=address -ggdb3"
80 paths
="-I. -L$vg_root/dep/glfw -I$vg_root/dep -I$vg_root/src"
81 setup
="$target_compiler -Wall -Wstrict-aliasing=3 -Wno-unused-function $paths"
82 targets
="$1 $vg_root/dep/glad/glad.c -o $2$target_ext"
83 final
="$target_libs -Wl,-rpath=./ $opt_steam"
84 cmd
="$setup $target_opts $targets $final"
90 error
"compiler signaled fail"
94 success
"$2$target_ext built"
98 titleit
"Main build: $target_dir"
101 compile_x
$vg_src $target_dir/$vg_target
103 logit
"Setting up build structure"
106 mkdir
$target_dir/cfg
-p
107 mkdir
$target_dir/textures
-p
108 mkdir
$target_dir/sound
-p
109 mkdir
$target_dir/maps
-p
110 mkdir
$target_dir/sav
-p
113 if [ "$opt_steam" != "" ]; then
114 cp $vg_root/dep
/steam
/$target_steam_api $target_dir/$target_steam_api
117 # Clear and copy assets
118 rm -r $target_dir/textures
119 rm -r $target_dir/sound
120 rm -r $target_dir/maps
122 cp -r .temp_textures
$target_dir
123 mv $target_dir/.temp_textures
$target_dir/textures
124 cp -r sound
$target_dir
125 cp -r maps
$target_dir
129 # These should only be compiled for native platform
132 mkdir
$vg_root/bin
-p
134 compile_x
$vg_root/src
/fontcomp.c
$vg_root/bin
/fontcomp
135 compile_x
$vg_root/src
/texsheet.c
$vg_root/bin
/texsheet
136 compile_x
$vg_root/src
/qoiconv.c
$vg_root/bin
/qoiconv
141 [[ -d .temp_textures
]] && rm -r .temp_textures
144 # Convert all png to qoi
145 echo "Compile textures:"
146 for f
in textures
/*.png
;
148 $vg_root/bin
/qoiconv
$target_ext $f .temp_textures
/"$(basename "$f" .png).qoi"
151 # Autocombine textures
157 do logit
" combine: $f";
158 auto_combine
="$auto_combine $f"
160 $vg_root/bin
/texsheet
$taget_ext ..
/.temp_textures
/autocombine.qoi ..
/sprites_autocombine.h sprites_auto_combine
$auto_combine
165 echo "Compile fonts:"
166 $vg_root/bin
/fontcomp
$target_ext $vg_root/src
/fonts
/vg_font.png
$vg_root/src
/vg
/vg_pxfont.h
169 # ==============================================================
172 if [[ "$OSTYPE" != "linux-gnu"* ]]; then
181 longopts
=release
,build-linux
,build-windows
,steam
,play
,build-tools
,assets
,full
182 parsed
=$
(getopt
--options=$options --longoptions=$longopts --name "vgc" -- "$@")
184 if [ $?
-ne 0 ]; then
185 error
"getopt failed"
189 eval set -- "$parsed"
227 opt_steam
="-DVG_STEAM"
235 error
"programming error"
241 titleit
" vgc ver: $vg_version\n host: $host_os"
242 logit
" assets: $opt_assets"
243 logit
" release: $opt_release"
244 logit
" play: $opt_play"
245 logit
" build-linux: $opt_linux"
246 logit
"build-windows: $opt_windows"
247 logit
" build-tools: $opt_tools"
248 logit
" steam: $opt_steam"
252 if [ $opt_tools = true
]; then compile_tools
; fi
253 if [ $opt_assets = true
]; then compile_assets
; fi
254 if [ $opt_linux = true
]; then target_os_linux
; compile_main
; fi
255 if [ $opt_windows = true
]; then
259 cp $vg_root/dep
/glfw
/glfw3.dll
$target_dir/glfw3.dll
262 if [ $opt_play = true
]; then
264 if [ $host_os = linux
]; then
271 logit
"======= exec: $target_dir/$vg_target$target_ext ======="
275 .
/$vg_target$target_ext