diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b75c59f --- /dev/null +++ b/build.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -eu + +if [ -z "$1" ]; then + echo "No output parameter named, please pass the build directory to this script." + exit 1 +fi + +script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +build="$1" + +if [ -x "$(command -v g++)" ]; then cpp_compiler="g++"; c_compiler="gcc"; +elif [ -x "$(command -v clang++)" ]; then cpp_compiler="clang++"; c_compiler="clang"; +else echo "Unable to find c++ cpp_compiler"; exit -1; fi; + +if [ -x "$(command -v mold)" ]; then linker_cmd="-fuse-ld=mold"; +elif [ -x "$(command -v lld)" ]; then linker_cmd="-fuse-ld=lld"; +elif [ -x "$(command -v ld)" ]; then linker_cmd="-fuse-ld=ld"; +else echo "Unable to find c/c++ linker"; exit -1; fi; + +# Build VMA +src="${script_dir}/vma/vma.cpp" +flags="-std=c++20 -D_USE_MATH_DEFINES -Iexternal/vma -c -Wno-everything -static" +out="-o" +obj="${build}/vma.o" +lib="${build}/libvma.a" + +if ! [ -f libvma.a ]; then + $cpp_compiler $flags $src $out $obj + ar rcs $lib $obj + rm $obj +fi diff --git a/vulkan_includes.c b/vulkan_includes.c index beee96e..88c7334 100644 --- a/vulkan_includes.c +++ b/vulkan_includes.c @@ -17,6 +17,4 @@ #define VMA_DYNAMIC_VULKAN_FUNCTIONS 1 #define VMA_VULKAN_VERSION 1002000 -#define VMA_IMPLEMENTATION - #include "vma/vk_mem_alloc.h"