build system: add support for building shaders to SPIRV binaries
This adds the following to the project: - glslc from Google’s shaderc - src/shaders directory - shaders are now built as part of the `build` command - forcefully remove some files during the setup process and when cleaningmaster
parent
20857cb8c5
commit
97b844c6d1
|
@ -55,7 +55,7 @@ wait
|
|||
# How to run a tool: specify the library path to use for the dynamic linker
|
||||
# when running a program
|
||||
# Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt
|
||||
echo ">>> Building tools..."
|
||||
echo ">>> Building programs..."
|
||||
create_directory bin/tools
|
||||
# add compile commands to this array
|
||||
COMPILE_COMMANDS=(
|
||||
|
@ -63,7 +63,7 @@ COMPILE_COMMANDS=(
|
|||
"$CXX_WITH_FLAGS src/tools/arraydump.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -o bin/tools/arraydump"
|
||||
"$CXX_WITH_FLAGS src/tools/baseconvert.cpp -I./include -Lbin/lib -l:cli.so -o bin/tools/baseconvert"
|
||||
"$CXX_WITH_FLAGS -pthread src/tools/hexnet.cpp -I./include -Lbin/lib -l:cli.so -l:libsockpp.so -o bin/tools/hexnet"
|
||||
"$CXX_WITH_FLAGS -DFOSSVG_DEBUG src/fossvg.cpp -I./include -Lbin/lib -l:cli.so -lglfw -lvulkan -o bin/fossvg"
|
||||
"$CXX_WITH_FLAGS -DFOSSVG_DEBUG src/fossvg.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -lglfw -lvulkan -o bin/fossvg"
|
||||
"$CXX_WITH_FLAGS src/fossvgd.cpp -I./include -Lbin/lib -l:cli.so -o bin/fossvgd"
|
||||
)
|
||||
for command in ${!COMPILE_COMMANDS[@]}; do
|
||||
|
@ -73,3 +73,21 @@ for command in ${!COMPILE_COMMANDS[@]}; do
|
|||
done
|
||||
|
||||
wait
|
||||
|
||||
echo ">>> Compiling shaders..."
|
||||
create_directory bin/shaders
|
||||
for shader in $(find ./src/shaders -name "*.vsh"); do
|
||||
COMPILE_COMMAND="dependencies/shaderc/bin/glslc -o $(sed -e 's/^.\/src/.\/bin/;s/vsh$/vsh.spv/' <<< $shader) -fshader-stage=vertex $shader"
|
||||
echo $COMPILE_COMMAND
|
||||
$COMPILE_COMMAND &
|
||||
$WAIT_ANYWAY
|
||||
done
|
||||
|
||||
for shader in $(find ./src/shaders -name "*.fsh"); do
|
||||
COMPILE_COMMAND="dependencies/shaderc/bin/glslc -o $(sed -e 's/^.\/src/.\/bin/;s/fsh$/fsh.spv/' <<< $shader) -fshader-stage=fragment $shader"
|
||||
echo $COMPILE_COMMAND
|
||||
$COMPILE_COMMAND &
|
||||
$WAIT_ANYWAY
|
||||
done
|
||||
|
||||
wait
|
||||
|
|
|
@ -35,6 +35,6 @@ done
|
|||
echo "
|
||||
>>> Cleaning dependencies..."
|
||||
|
||||
remove ./dependencies
|
||||
remove -f ./dependencies
|
||||
create_directory ./dependencies
|
||||
create_file ./dependencies/.placeholder
|
||||
|
|
|
@ -57,11 +57,18 @@ fi
|
|||
# `rm -v` only prints the names of the removed things instead of a more
|
||||
# comprehensible message like "removing NAME".
|
||||
function remove {
|
||||
echo "Removing $1..."
|
||||
if [ -d "$1" ]; then
|
||||
rm -rv "$1"
|
||||
local USE_FORCE=""
|
||||
if [ "$1" = "-f" ]; then
|
||||
USE_FORCE="-f"
|
||||
echo "Forcefully removing $1..."
|
||||
else
|
||||
rm -v "$1"
|
||||
echo "Removing $1..."
|
||||
fi;
|
||||
shift
|
||||
if [ -d "$1" ]; then
|
||||
rm "$USE_FORCE" -rv "$1"
|
||||
else
|
||||
rm "$USE_FORCE" -v "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,11 @@ create_directory dependencies/tmp
|
|||
download https://github.com/DuffsDevice/tiny-utf8/archive/refs/tags/v4.4.3.tar.gz dependencies/tmp/tiny-utf8.tar.gz 8e3f61651909c9f3105d3501932a96aa65733127fb6e7cf94cb1b0a2dff42c8f
|
||||
download https://github.com/fpagliughi/sockpp/archive/refs/tags/v0.8.1.tar.gz dependencies/tmp/sockpp.tar.gz a8aedff8bd8c1da530b91be650352008fddabc9f1df0d19701d76cbc359c8651
|
||||
|
||||
#TODO: figure out how to cache shaderc
|
||||
#also TODO: target a specific commit
|
||||
git clone --branch known-good https://github.com/google/shaderc.git dependencies/tmp/shaderc
|
||||
#download https://github.com/google/shaderc/archive/refs/tags/v2023.7.tar.gz dependencies/tmp/shaderc.tar.gz 681e1340726a0bf46bea7e31f10cbfe78e01e4446a35d90fedc2b78d400fcdeb
|
||||
|
||||
echo -n ">>> Extracting tiny-utf8... "
|
||||
gzip -d dependencies/tmp/tiny-utf8.tar.gz
|
||||
tar -xf dependencies/tmp/tiny-utf8.tar -C dependencies
|
||||
|
@ -112,6 +117,26 @@ else
|
|||
cmake --build build
|
||||
fi
|
||||
popd >/dev/null 2>&1
|
||||
echo ">>> done"
|
||||
|
||||
echo ">>> Dealing with shaderc shenanigans..."
|
||||
pushd dependencies/tmp/shaderc
|
||||
echo "Getting sources using the provided script..."
|
||||
./update_shaderc_sources.py
|
||||
SHADERC_BUILD="build-$(dd if=/dev/urandom bs=1 count=5 2>/dev/null | base32)"
|
||||
echo "Creating and entering directory $SHADERC_BUILD."
|
||||
mkdir "$SHADERC_BUILD"
|
||||
cd "$SHADERC_BUILD"
|
||||
echo "Running CMake..."
|
||||
CXXFLAGS="-Wno-error" cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../src/
|
||||
echo "Running Ninja..."
|
||||
ninja
|
||||
popd >/dev/null 2>&1
|
||||
#if needed copy more relevant files to dependencies/shaderc
|
||||
echo "Copying binary to dependencies/shaderc/bin..."
|
||||
mkdir -vp dependencies/shaderc/bin
|
||||
cp -v "dependencies/tmp/shaderc/$SHADERC_BUILD/glslc/glslc" dependencies/shaderc/bin
|
||||
echo ">>> done"
|
||||
|
||||
echo ">>> Cleaning up..."
|
||||
remove dependencies/tmp
|
||||
remove -f dependencies/tmp
|
||||
|
|
Loading…
Reference in New Issue