X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_compiler.sh;h=33d80575df8953dfb5110d137cd20109c513409c;hb=4d6575e40f0366f937e4ee45e0cf0a17bb9adffc;hp=a27da4ae00509e05e67850040f471289255dabce;hpb=c9d41059e232eabbcfebc2d7401a2b617a20f630;p=vg.git diff --git a/vg_compiler.sh b/vg_compiler.sh index a27da4a..33d8057 100755 --- a/vg_compiler.sh +++ b/vg_compiler.sh @@ -6,6 +6,7 @@ vg_root=`dirname $vg_root` vg_version="0.2" opt_assets=false +opt_shaders=false opt_release=false opt_play=false opt_linux=false @@ -17,6 +18,7 @@ opt_steam="" target_platform_include="" target_standard="-std=c99" target_link_steam=false +target_shaders="" # Util # =========================================== @@ -65,7 +67,7 @@ target_os_windows(){ target_platform_include="" if [ $opt_release = true ]; then - target_opts="-O3" + target_opts="-O3 -DVG_RELEASE" else target_opts="-ggdb3" fi @@ -82,9 +84,9 @@ target_os_linux(){ target_steam_api="libsteam_api.so" target_miniaudio="$vg_root/dep/dr_soft/miniaudio_linux.o" if [ $opt_release = true ]; then - target_opts="-O3" + target_opts="-O3 -DVG_RELEASE" else - target_opts="-O1 -fsanitize=address -ggdb3 -fno-omit-frame-pointer" + target_opts="-O0 -fsanitize=address -ggdb3 -fno-omit-frame-pointer" fi } @@ -95,7 +97,7 @@ precompile_x(){ fi sources="$1" output="-o $2" - cmd="$target_compiler -D_REENTRANT $target_standard $target_opts $target_platform_include + cmd="$target_compiler $target_standard $target_opts $target_platform_include -c $sources $output" @@ -120,7 +122,7 @@ compile_x(){ steam_part="$opt_steam $target_libs_steam" fi - warnings="-Wall -Wstrict-aliasing=3 -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable" + warnings="-Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable" sources="$1 $vg_root/dep/glad/glad.c $target_miniaudio" output="-o $2$target_ext" @@ -163,17 +165,6 @@ compile_main(){ if [ "$opt_steam" != "" ]; then cp $vg_root/dep/steam/$target_steam_api $target_dir/$target_steam_api fi - - # Clear and copy assets - rm -r $target_dir/textures - rm -r $target_dir/sound - rm -r $target_dir/maps - - cp -r .temp_textures $target_dir - mv $target_dir/.temp_textures $target_dir/textures - cp -r sound $target_dir - cp -r maps $target_dir - cp -r models $target_dir } compile_tools(){ @@ -188,10 +179,10 @@ compile_tools(){ compile_x $vg_root/src/fontcomp.c $vg_root/bin/fontcomp compile_x $vg_root/src/texsheet.c $vg_root/bin/texsheet compile_x $vg_root/src/qoiconv.c $vg_root/bin/qoiconv + compile_x $vg_root/src/shader.c $vg_root/bin/shader opt_steam=$steam_prev } - compile_assets(){ titleit "Assets" [[ -d .temp_textures ]] && rm -r .temp_textures @@ -205,7 +196,6 @@ compile_assets(){ done if [[ -d "textures_combine" ]]; then - # Autocombine textures echo " [combine]:" auto_combine="" @@ -214,7 +204,7 @@ compile_assets(){ do logit " combine: $f"; auto_combine="$auto_combine $f" done - $vg_root/bin/texsheet$taget_ext ../.temp_textures/autocombine.qoi ../sprites_autocombine.h sprites_auto_combine $auto_combine + $vg_root/bin/texsheet$target_ext ../.temp_textures/autocombine.qoi ../sprites_autocombine.h sprites_auto_combine $auto_combine cd .. fi @@ -222,12 +212,37 @@ compile_assets(){ echo "" echo "Compile fonts:" $vg_root/bin/fontcomp$target_ext $vg_root/src/fonts/vg_font.png $vg_root/src/vg/vg_pxfont.h + + # Clear and copy assets + rm -r $target_dir/textures + rm -r $target_dir/sound + rm -r $target_dir/maps + + cp -r .temp_textures $target_dir + mv $target_dir/.temp_textures $target_dir/textures + cp -r sound $target_dir + cp -r maps $target_dir + cp -r models $target_dir +} + +compile_shaders(){ + titleit "Shaders" + + if [[ -d "shaders" ]]; then + cd shaders + $vg_root/bin/shader$target_ext $target_shaders + cd .. + fi +} + +shader(){ + target_shaders="$target_shaders $1 $2 $3" } # ============================================================== # Compile process -options=rptlwa +options=rptlwas longopts=release,build-linux,build-windows,steam,play,build-tools,assets,full,miniaudio,template parsed=$(getopt --options=$options --longoptions=$longopts --name "vgc" -- "$@") @@ -239,8 +254,13 @@ fi eval set -- "$parsed" while true; do case "$1" in + -s|--shaders) + opt_shaders=true + shift; + ;; -a|--assets) opt_assets=true + opt_shaders=true shift; ;; -r|--release) @@ -326,6 +346,7 @@ detect_os titleit " vgc ver: $vg_version\n host: $host_os" logit " assets: $opt_assets" +logit " shaders: $opt_shaders" logit " release: $opt_release" logit " play: $opt_play" logit " build-linux: $opt_linux" @@ -338,6 +359,7 @@ logit " miniaudio: $opt_recompile_mini_audio" if [ $opt_tools = true ]; then detect_os; compile_tools; fi if [ $opt_assets = true ]; then compile_assets; fi +if [ $opt_shaders = true ]; then compile_shaders; fi if [ $opt_linux = true ]; then target_os_linux; compile_main; fi if [ $opt_windows = true ]; then target_os_windows