2022-06-27 07:35:04 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-06-24 10:05:39 +02:00
|
|
|
|
2022-06-27 11:46:13 +02:00
|
|
|
# Copyright 2022, FOSS-VG Developers and Contributers
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU Affero General Public License as published
|
|
|
|
# by the Free Software Foundation, version 3.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# version 3 along with this program.
|
|
|
|
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
|
2022-07-30 21:10:07 +02:00
|
|
|
source scripts/lib.sh
|
2022-06-24 10:23:12 +02:00
|
|
|
|
2022-07-01 13:57:20 +02:00
|
|
|
# if unknown, figure out endianness
|
|
|
|
if [ -f .endianness ]; then
|
|
|
|
echo "Endianness known:"
|
|
|
|
cat .endianness
|
|
|
|
else
|
|
|
|
echo "Endianness unknown."
|
|
|
|
if [ ! -x resources/check_endianness ]; then
|
|
|
|
echo "Building endianness test."
|
|
|
|
$CXX_WITH_FLAGS -o resources/check_endianness resources/check_endianness.cpp
|
|
|
|
fi
|
|
|
|
echo "Probing endianness:"
|
|
|
|
resources/check_endianness > .endianness
|
|
|
|
fi
|
|
|
|
|
2022-06-24 12:36:15 +02:00
|
|
|
# `.cpp` files in src/lib will be automatically picked up and compiled into
|
|
|
|
# dynamically linked libraries.
|
2022-08-13 00:28:36 +02:00
|
|
|
echo ">>> Building libs..."
|
2022-07-30 21:10:07 +02:00
|
|
|
create_directory bin/lib
|
2024-06-08 14:26:48 +02:00
|
|
|
COMPILE_COMMANDS=(
|
2024-06-08 23:59:55 +02:00
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/net/connection.so ./src/lib/net/connection.cpp"
|
2024-06-08 14:26:48 +02:00
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/cli.so ./src/lib/cli.cpp"
|
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/file.so ./src/lib/file.cpp"
|
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/game/block.so ./src/lib/game/block.cpp"
|
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/game/entity.so ./src/lib/game/entity.cpp"
|
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/nbt.so ./src/lib/nbt.cpp"
|
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/region.so ./src/lib/region.cpp"
|
|
|
|
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -l:libz.so -o ./bin/lib/zlibutil.so ./src/lib/zlibutil.cpp"
|
|
|
|
)
|
|
|
|
for command in ${!COMPILE_COMMANDS[@]}; do
|
|
|
|
echo "${COMPILE_COMMANDS[command]}"
|
|
|
|
${COMPILE_COMMANDS[command]} &
|
2022-07-06 10:50:55 +02:00
|
|
|
$WAIT_ANYWAY
|
2022-06-24 09:21:57 +02:00
|
|
|
done
|
|
|
|
|
2022-06-24 16:36:57 +02:00
|
|
|
wait
|
2022-06-24 10:05:39 +02:00
|
|
|
|
2022-06-24 09:21:57 +02:00
|
|
|
# Commands for every program need to be given individually because we can't
|
|
|
|
# just add all shared libraries to all programs.
|
|
|
|
# Or can we? Idk, cba to find out.
|
2022-06-24 10:05:39 +02:00
|
|
|
|
|
|
|
# How to build a tool: Tell the compiler where to find shared libraries and
|
2022-06-24 16:50:41 +02:00
|
|
|
# which libraries to use.
|
2022-06-24 10:05:39 +02:00
|
|
|
# Example: shared libraries are in bin/lib => -Lbin/lib
|
2022-06-24 16:50:41 +02:00
|
|
|
# one of the libraries in that directory is nbt.so => use with -l:nbt.so
|
2022-06-24 10:05:39 +02:00
|
|
|
# How to run a tool: specify the library path to use for the dynamic linker
|
2022-06-24 16:50:41 +02:00
|
|
|
# when running a program
|
2022-06-24 10:05:39 +02:00
|
|
|
# Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt
|
2024-01-07 20:07:33 +01:00
|
|
|
echo ">>> Building programs..."
|
2022-07-30 21:10:07 +02:00
|
|
|
create_directory bin/tools
|
2022-06-27 04:49:05 +02:00
|
|
|
# add compile commands to this array
|
|
|
|
COMPILE_COMMANDS=(
|
2022-10-30 04:55:58 +01:00
|
|
|
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:cli.so -o bin/tools/dumpnbt"
|
2022-10-05 05:26:04 +02:00
|
|
|
"$CXX_WITH_FLAGS src/tools/arraydump.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -o bin/tools/arraydump"
|
2022-10-08 08:29:01 +02:00
|
|
|
"$CXX_WITH_FLAGS src/tools/baseconvert.cpp -I./include -Lbin/lib -l:cli.so -o bin/tools/baseconvert"
|
2024-06-08 14:26:48 +02:00
|
|
|
"$CXX_WITH_FLAGS src/tools/zlibutil.cpp -I./include -Lbin/lib -l:cli.so -l:file.so -l:zlibutil.so -l:libz.so -o bin/tools/zlibutil"
|
2022-10-23 03:06:48 +02:00
|
|
|
"$CXX_WITH_FLAGS -pthread src/tools/hexnet.cpp -I./include -Lbin/lib -l:cli.so -l:libsockpp.so -o bin/tools/hexnet"
|
2024-01-07 20:07:33 +01:00
|
|
|
"$CXX_WITH_FLAGS -DFOSSVG_DEBUG src/fossvg.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -lglfw -lvulkan -o bin/fossvg"
|
2022-10-28 01:53:20 +02:00
|
|
|
"$CXX_WITH_FLAGS src/fossvgd.cpp -I./include -Lbin/lib -l:cli.so -o bin/fossvgd"
|
2022-06-27 04:49:05 +02:00
|
|
|
)
|
|
|
|
for command in ${!COMPILE_COMMANDS[@]}; do
|
|
|
|
echo "${COMPILE_COMMANDS[command]}"
|
|
|
|
${COMPILE_COMMANDS[command]} &
|
2022-07-06 10:50:55 +02:00
|
|
|
$WAIT_ANYWAY
|
2022-06-27 04:49:05 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
wait
|
2024-01-07 20:07:33 +01:00
|
|
|
|
|
|
|
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
|