#!/bin/bash set -eu for arg in "$@"; do declare $arg="1"; done if [ ! -v clang ]; then gcc=1; fi if [ ! -v release ]; then debug=1; fi if [ -v debug ]; then echo "[debug mode]"; fi if [ -v release ]; then echo "[release mode]"; fi if [ -v gcc ]; then compiler="${CC:-gcc}"; cpp_compiler="g++"; echo "[gcc compiler]"; fi if [ -v clang ]; then compiler="${CC:-clang}"; cpp_compiler="clang++"; echo "[clang compiler]"; fi if [ -v vulkan ]; then render_flag="-DSTG_VULKAN_RENDERER"; echo "[vulkan renderer]"; fi if [ -v opengl ] && [ ! -v render_flag ]; then render_flag="-DSTG_OPENGL_RENDERER"; echo "[opengl renderer]"; fi if [ -v webgl ] && [ ! -v render_flag ]; then render_flag="-DSTG_WEBGL_RENDERER"; echo "[webgl renderer]"; fi if [ -v dx11 ] && [ ! -v render_flag ]; then render_flag="-DSTG_DX11_RENDERER"; echo "[dx11 renderer]"; fi if [ ! -v render_flag ]; then render_flag="-DSTG_VULKAN_RENDERER"; echo "[default renderer - vulkan]"; fi # for command line build args auto_compile_flags="${render_flag}" # source files source_files="../src/main.c" # includes include_flags="-I../src/ -I../external/ -L." # executable name out_name="here" # vma flags vma_ld="ld -static vma.o `g++ -print-file-name=libstdc++.a` -o vmastdc++.o" vma_source_files="../external/vma/vma.cpp" vma_compile_flags="-std=c++20 -I../external/vma" vma_out="-c -o" vma_obj="vma.o" clang_common="${include_flags} -g -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -DVMA_STATIC_VULKAN_FUNCTIONS=0" clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}" clang_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${clang_common} ${auto_compile_flags}" clang_link="-lpthread -lm -lrt -ldl -l:libvma.a" clang_out="-o" gcc_common="${include_flags} -fuse-ld=mold -g -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -DVMA_STATIC_VULKAN_FUNCTIONS=0" gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common} ${auto_compile_flags}" gcc_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${gcc_common} ${auto_compile_flags}" gcc_link="-lpthread -lm -lrt -ldl -l:libvma.a" gcc_out="-o" link_dll="-fPIC" link_os_gfx="-lxcb -lvulkan" if [ -v gcc ]; then compile_debug="$gcc_debug"; fi if [ -v gcc ]; then compile_release="$gcc_release"; fi if [ -v gcc ]; then compile_link="$gcc_link"; fi if [ -v gcc ]; then out="$gcc_out"; fi if [ -v clang ]; then compile_debug="$clang_debug"; fi if [ -v clang ]; then compile_release="$clang_release"; fi if [ -v clang ]; then compile_link="$clang_link"; fi if [ -v clang ]; then out="$clang_out"; fi if [ -v debug ]; then compile="$compile_debug"; fi if [ -v release ]; then compile="$compile_release"; fi mkdir -p build cd build if [ ! -f $vma_obj ]; then $vma_ld fi $cpp_compiler $vma_compile_flags $vma_source_files $vma_out $vma_obj ar rcs libvma.a vmastdc++.o $compile $source_files $compile_link $link_os_gfx $out $out_name