2022-06-27 09:07:25 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
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-27 09:07:25 +02:00
|
|
|
echo -n "Wget or curl? "
|
|
|
|
if command -v wget >/dev/null 2>&1; then
|
|
|
|
USE_WGET=yes
|
|
|
|
echo "wget"
|
|
|
|
else
|
|
|
|
if command -v curl >/dev/null 2>&1; then
|
|
|
|
USE_WGET=no
|
|
|
|
echo "curl"
|
|
|
|
else
|
2022-06-27 13:06:09 +02:00
|
|
|
echo "Found neither wget nor curl. Aborting."
|
2022-06-27 09:07:25 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
function download {
|
|
|
|
URL="$1"
|
|
|
|
DESTINATION="$2"
|
2022-07-20 15:52:04 +02:00
|
|
|
SHA256SUM="$3"
|
|
|
|
|
|
|
|
if [ ! -d .download_cache ]; then
|
|
|
|
echo "Cache directory missing."
|
2022-07-30 21:10:07 +02:00
|
|
|
create_directory .download_cache
|
2022-06-27 09:07:25 +02:00
|
|
|
fi
|
2022-07-20 15:52:04 +02:00
|
|
|
|
|
|
|
if [ -f ".download_cache/$SHA256SUM" ]; then
|
2022-07-30 21:10:07 +02:00
|
|
|
if check_sha256 ".download_cache/$SHA256SUM" "$SHA256SUM"; then
|
2022-07-20 15:52:04 +02:00
|
|
|
echo "Using locally cached file for $DESTINATION"
|
|
|
|
cp ".download_cache/$SHA256SUM" "$DESTINATION"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo "Locally cached file for $DESTINATION is corrupted."
|
|
|
|
rm ".download_cache/$SHA256SUM"
|
|
|
|
download "$URL" "$DESTINATION" "$SHA256SUM"
|
|
|
|
return $?
|
|
|
|
fi
|
2022-07-06 14:15:40 +02:00
|
|
|
else
|
2022-07-20 15:52:04 +02:00
|
|
|
echo -n "Downloading $URL to $DESTINATION... "
|
|
|
|
if [ $USE_WGET = yes ]; then
|
|
|
|
wget -O ".download_cache/$SHA256SUM" "$URL" >/dev/null 2>&1
|
|
|
|
else
|
|
|
|
curl -L "$URL" --output ".download_cache/$SHA256SUM" >/dev/null 2>&1
|
|
|
|
fi
|
2022-07-30 21:10:07 +02:00
|
|
|
if check_sha256 ".download_cache/$SHA256SUM" "$SHA256SUM"; then
|
2022-07-20 15:52:04 +02:00
|
|
|
cp ".download_cache/$SHA256SUM" "$DESTINATION"
|
|
|
|
echo "done."
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo "error."
|
|
|
|
echo "Checksum verification failed. Your download is either corrupted or the file has been altered. Removing file."
|
|
|
|
rm ".download_cache/$SHA256SUM"
|
|
|
|
return 1
|
|
|
|
fi
|
2022-07-06 14:15:40 +02:00
|
|
|
fi
|
2022-06-27 09:07:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
scripts/clean.sh
|
|
|
|
scripts/clean_dependencies.sh
|
|
|
|
|
2022-07-12 01:51:23 +02:00
|
|
|
set -e # failures are not acceptable here
|
2022-07-30 21:10:07 +02:00
|
|
|
create_directory dependencies/tmp
|
2022-07-06 14:15:40 +02:00
|
|
|
download https://github.com/DuffsDevice/tiny-utf8/archive/refs/tags/v4.4.3.tar.gz dependencies/tmp/tiny-utf8.tar.gz 8e3f61651909c9f3105d3501932a96aa65733127fb6e7cf94cb1b0a2dff42c8f
|
2023-06-18 07:01:10 +02:00
|
|
|
download https://github.com/fpagliughi/sockpp/archive/refs/tags/v0.8.1.tar.gz dependencies/tmp/sockpp.tar.gz a8aedff8bd8c1da530b91be650352008fddabc9f1df0d19701d76cbc359c8651
|
2024-03-24 12:07:49 +01:00
|
|
|
download https://www.zlib.net/zlib-1.3.1.tar.xz dependencies/tmp/zlib.tar.xz 38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32
|
2022-06-27 09:07:25 +02:00
|
|
|
|
2024-01-07 20:07:33 +01:00
|
|
|
#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
|
|
|
|
|
2022-08-13 00:28:36 +02:00
|
|
|
echo -n ">>> Extracting tiny-utf8... "
|
2022-06-27 09:07:25 +02:00
|
|
|
gzip -d dependencies/tmp/tiny-utf8.tar.gz
|
|
|
|
tar -xf dependencies/tmp/tiny-utf8.tar -C dependencies
|
2022-08-13 00:28:36 +02:00
|
|
|
echo "done"
|
2022-06-27 09:07:25 +02:00
|
|
|
|
2022-08-13 00:28:36 +02:00
|
|
|
echo -n ">>> Extracting sockpp... "
|
2022-07-12 01:51:23 +02:00
|
|
|
gzip -d dependencies/tmp/sockpp.tar.gz
|
|
|
|
tar -xf dependencies/tmp/sockpp.tar -C dependencies
|
2022-08-13 00:28:36 +02:00
|
|
|
echo "done"
|
|
|
|
|
2024-03-24 12:07:49 +01:00
|
|
|
echo -n ">>> Extracting zlib... "
|
|
|
|
xz -d dependencies/tmp/zlib.tar.xz
|
|
|
|
tar -xf dependencies/tmp/zlib.tar -C dependencies
|
|
|
|
echo "done"
|
|
|
|
|
2024-01-07 20:07:33 +01:00
|
|
|
echo ">>> Building sockpp..."
|
2023-06-18 07:01:10 +02:00
|
|
|
pushd dependencies/sockpp-0.8.1/ >/dev/null 2>&1
|
2022-10-30 19:39:27 +01:00
|
|
|
if uname -s | tr [:upper:] [:lower:] | grep cygwin >/dev/null; then
|
2022-10-31 01:21:16 +01:00
|
|
|
echo "Adding Cygwin workaound for building sockpp."
|
|
|
|
|
2023-06-18 07:53:35 +02:00
|
|
|
#for FILE in "$(find ./ -type f)"; do
|
|
|
|
# sed -i -e 's/_WIN32/PLEASE_DO_NOT_DEFINE_THIS_MACRO/g' $FILE
|
|
|
|
#done
|
|
|
|
#mv ./include/sockpp/socket.h ./include/sockpp/socket.h_original
|
|
|
|
#echo '#include <sys/time.h>
|
|
|
|
##include "socket.h_original"' > ./include/sockpp/socket.h
|
2022-10-31 01:21:16 +01:00
|
|
|
sed -i -e 's/SO_REUSEPORT/SO_REUSEADDR/g' ./src/acceptor.cpp
|
|
|
|
|
2023-06-18 07:53:35 +02:00
|
|
|
#CFLAGS="-D_XOPEN_SOURCE=700" CXXFLAGS="-D_XOPEN_SOURCE=700" cmake -Bbuild
|
|
|
|
#CFLAGS="-D_XOPEN_SOURCE=700" CXXFLAGS="-D_XOPEN_SOURCE=700" cmake --build build
|
|
|
|
cmake -Bbuild .
|
|
|
|
cmake --build build
|
2022-10-30 19:39:27 +01:00
|
|
|
else
|
|
|
|
cmake -Bbuild .
|
2022-10-31 01:21:16 +01:00
|
|
|
cmake --build build
|
2022-10-30 19:39:27 +01:00
|
|
|
fi
|
2022-07-12 01:51:23 +02:00
|
|
|
popd >/dev/null 2>&1
|
2024-01-07 20:07:33 +01:00
|
|
|
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"
|
2022-07-12 01:51:23 +02:00
|
|
|
|
2024-03-24 12:07:49 +01:00
|
|
|
echo ">>> Building zlib..."
|
|
|
|
pushd dependencies/zlib-1.3.1/
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
popd
|
|
|
|
echo "done"
|
|
|
|
|
2022-08-13 00:28:36 +02:00
|
|
|
echo ">>> Cleaning up..."
|
2024-01-07 20:07:33 +01:00
|
|
|
remove -f dependencies/tmp
|