Build system: better cross-platform compatibility
I hope we don't run into more versions of sha256(sum)...BodgeMaster-unfinished
parent
845b3fb922
commit
d90e7f16bd
|
@ -15,20 +15,7 @@
|
||||||
# version 3 along with this program.
|
# version 3 along with this program.
|
||||||
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
|
||||||
if [ "$(tr '[:upper:]' '[:lower:]' <<< $SINGLE)" = "yes" ]; then
|
source scripts/lib.sh
|
||||||
echo "Running build script in single-threaded mode."
|
|
||||||
WAIT_ANYWAY="wait"
|
|
||||||
else
|
|
||||||
WAIT_ANYWAY=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$CXX" ]; then
|
|
||||||
CXX="c++"
|
|
||||||
fi
|
|
||||||
if [ -z "$CXXFLAGS" ]; then
|
|
||||||
CXXFLAGS="-std=c++20 -Wall -Wextra"
|
|
||||||
fi
|
|
||||||
CXX_WITH_FLAGS="$CXX $CXXFLAGS"
|
|
||||||
|
|
||||||
# if unknown, figure out endianness
|
# if unknown, figure out endianness
|
||||||
if [ -f .endianness ]; then
|
if [ -f .endianness ]; then
|
||||||
|
@ -47,7 +34,7 @@ fi
|
||||||
# `.cpp` files in src/lib will be automatically picked up and compiled into
|
# `.cpp` files in src/lib will be automatically picked up and compiled into
|
||||||
# dynamically linked libraries.
|
# dynamically linked libraries.
|
||||||
echo "Building libs..."
|
echo "Building libs..."
|
||||||
mkdir -pv bin/lib
|
create_directory bin/lib
|
||||||
for lib in $(find ./src/lib -name "*.cpp"); do
|
for lib in $(find ./src/lib -name "*.cpp"); do
|
||||||
COMPILE_COMMAND="$CXX_WITH_FLAGS -I ./include -fPIC -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
|
COMPILE_COMMAND="$CXX_WITH_FLAGS -I ./include -fPIC -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
|
||||||
echo $COMPILE_COMMAND
|
echo $COMPILE_COMMAND
|
||||||
|
@ -69,7 +56,7 @@ wait
|
||||||
# when running a program
|
# when running a program
|
||||||
# Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt
|
# Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt
|
||||||
echo "Building tools..."
|
echo "Building tools..."
|
||||||
mkdir -pv bin/tools
|
create_directory bin/tools
|
||||||
# add compile commands to this array
|
# add compile commands to this array
|
||||||
COMPILE_COMMANDS=(
|
COMPILE_COMMANDS=(
|
||||||
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:javacompat.so -o bin/tools/dumpnbt"
|
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:javacompat.so -o bin/tools/dumpnbt"
|
||||||
|
|
|
@ -15,13 +15,15 @@
|
||||||
# version 3 along with this program.
|
# version 3 along with this program.
|
||||||
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
|
||||||
rm -rv ./bin
|
source scripts/lib.sh
|
||||||
rm -rv ./include
|
|
||||||
rm -vf .endianness
|
remove ./bin
|
||||||
rm -vf resources/check_endianness
|
remove ./include
|
||||||
mkdir -v ./bin
|
remove .endianness
|
||||||
mkdir -v ./bin/lib
|
remove resources/check_endianness
|
||||||
mkdir -v ./include
|
create_directory ./bin
|
||||||
|
create_directory ./bin/lib
|
||||||
|
create_directory ./include
|
||||||
|
|
||||||
ln -vs ../../dependencies/sockpp-0.7.1/build/libsockpp.so bin/lib/
|
ln -vs ../../dependencies/sockpp-0.7.1/build/libsockpp.so bin/lib/
|
||||||
ln -vs ../../dependencies/sockpp-0.7.1/build/libsockpp.so.0 bin/lib/
|
ln -vs ../../dependencies/sockpp-0.7.1/build/libsockpp.so.0 bin/lib/
|
||||||
|
@ -30,6 +32,5 @@ ln -vs ../../dependencies/sockpp-0.7.1/build/libsockpp.so.0.7.1 bin/lib/
|
||||||
ln -vs ../dependencies/sockpp-0.7.1/include/sockpp/ ./include/
|
ln -vs ../dependencies/sockpp-0.7.1/include/sockpp/ ./include/
|
||||||
ln -vs ../dependencies/tiny-utf8-4.4.3/include/tinyutf8/ ./include/
|
ln -vs ../dependencies/tiny-utf8-4.4.3/include/tinyutf8/ ./include/
|
||||||
|
|
||||||
set -v
|
create_file ./bin/.placeholder
|
||||||
echo -n "" > ./bin/.placeholder
|
create_file ./include/.placeholder
|
||||||
echo -n "" > ./include/.placeholder
|
|
||||||
|
|
|
@ -15,11 +15,13 @@
|
||||||
# version 3 along with this program.
|
# version 3 along with this program.
|
||||||
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
|
||||||
|
source scripts/lib.sh
|
||||||
|
|
||||||
echo "Checking download cache for unneeded or corrupted files..."
|
echo "Checking download cache for unneeded or corrupted files..."
|
||||||
for file in $(ls .download_cache); do
|
for file in $(ls .download_cache); do
|
||||||
#TODO: remove if unknown shasum
|
#TODO: remove if unknown shasum
|
||||||
if grep $file scripts/setup_project.sh >/dev/null 2>&1; then
|
if grep $file scripts/setup_project.sh >/dev/null 2>&1; then
|
||||||
if sha256sum --check <<< "$file *.download_cache/$file" >/dev/null 2>&1; then
|
if check_sha256 ".download_cache/$file" "$file"; then
|
||||||
echo -n "."
|
echo -n "."
|
||||||
else
|
else
|
||||||
echo -n "!"
|
echo -n "!"
|
||||||
|
@ -32,7 +34,6 @@ for file in $(ls .download_cache); do
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
rm -rv ./dependencies
|
remove ./dependencies
|
||||||
mkdir -v ./dependencies
|
create_directory ./dependencies
|
||||||
set -v
|
create_file ./dependencies/.placeholder
|
||||||
echo -n "" > ./dependencies/.placeholder
|
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#!/bin/echo You are not supposed to run this file.
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if [ "$(tr '[:upper:]' '[:lower:]' <<< $SINGLE)" = "yes" ]; then
|
||||||
|
echo "Single-threaded mode enabled."
|
||||||
|
WAIT_ANYWAY="wait"
|
||||||
|
else
|
||||||
|
WAIT_ANYWAY=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CXX" ]; then
|
||||||
|
CXX="c++"
|
||||||
|
fi
|
||||||
|
if [ -z "$CXXFLAGS" ]; then
|
||||||
|
CXXFLAGS="-std=c++20 -Wall -Wextra"
|
||||||
|
fi
|
||||||
|
CXX_WITH_FLAGS="$CXX $CXXFLAGS"
|
||||||
|
|
||||||
|
# automatically find and use an appropriate sha256 sum command
|
||||||
|
# currently supports sha256sum and NetBSD's sha256
|
||||||
|
if command -v sha256sum > /dev/null; then
|
||||||
|
function check_sha256 {
|
||||||
|
FILE="$1"
|
||||||
|
CHECKSUM="$2"
|
||||||
|
sha256sum --check <<< "$CHECKSUM *$FILE" >/dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if command -v sha256 > /dev/null; then
|
||||||
|
function check_sha256 {
|
||||||
|
FILE="$1"
|
||||||
|
CHECKSUM="$2"
|
||||||
|
sha256 --c <<< "SHA256 ($FILE) = $CHECKSUM" >/dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "Could not find sha256sum or sha256."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This function exists to make the output more sensible on platforms where
|
||||||
|
# `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"
|
||||||
|
else
|
||||||
|
rm -v "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# some platforms don’t support `mkdir -v`
|
||||||
|
function create_directory {
|
||||||
|
echo "Creating directory: $1"
|
||||||
|
mkdir -p "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# `mkfile -v` if you will
|
||||||
|
function create_file {
|
||||||
|
echo "Creating file: $1"
|
||||||
|
touch "$1"
|
||||||
|
}
|
|
@ -15,6 +15,8 @@
|
||||||
# version 3 along with this program.
|
# version 3 along with this program.
|
||||||
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
|
||||||
|
source scripts/lib.sh
|
||||||
|
|
||||||
echo -n "Wget or curl? "
|
echo -n "Wget or curl? "
|
||||||
if command -v wget >/dev/null 2>&1; then
|
if command -v wget >/dev/null 2>&1; then
|
||||||
USE_WGET=yes
|
USE_WGET=yes
|
||||||
|
@ -36,11 +38,11 @@ function download {
|
||||||
|
|
||||||
if [ ! -d .download_cache ]; then
|
if [ ! -d .download_cache ]; then
|
||||||
echo "Cache directory missing."
|
echo "Cache directory missing."
|
||||||
mkdir -v .download_cache
|
create_directory .download_cache
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ".download_cache/$SHA256SUM" ]; then
|
if [ -f ".download_cache/$SHA256SUM" ]; then
|
||||||
if sha256sum --check <<< "$SHA256SUM *.download_cache/$SHA256SUM" >/dev/null 2>&1; then
|
if check_sha256 ".download_cache/$SHA256SUM" "$SHA256SUM"; then
|
||||||
echo "Using locally cached file for $DESTINATION"
|
echo "Using locally cached file for $DESTINATION"
|
||||||
cp ".download_cache/$SHA256SUM" "$DESTINATION"
|
cp ".download_cache/$SHA256SUM" "$DESTINATION"
|
||||||
return 0
|
return 0
|
||||||
|
@ -57,7 +59,7 @@ function download {
|
||||||
else
|
else
|
||||||
curl -L "$URL" --output ".download_cache/$SHA256SUM" >/dev/null 2>&1
|
curl -L "$URL" --output ".download_cache/$SHA256SUM" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
if sha256sum --check <<< "$SHA256SUM *.download_cache/$SHA256SUM" >/dev/null 2>&1; then
|
if check_sha256 ".download_cache/$SHA256SUM" "$SHA256SUM"; then
|
||||||
cp ".download_cache/$SHA256SUM" "$DESTINATION"
|
cp ".download_cache/$SHA256SUM" "$DESTINATION"
|
||||||
echo "done."
|
echo "done."
|
||||||
return 0
|
return 0
|
||||||
|
@ -76,7 +78,7 @@ echo "Cleaning dependencies..."
|
||||||
scripts/clean_dependencies.sh
|
scripts/clean_dependencies.sh
|
||||||
|
|
||||||
set -e # failures are not acceptable here
|
set -e # failures are not acceptable here
|
||||||
mkdir -v dependencies/tmp
|
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/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.7.1.tar.gz dependencies/tmp/sockpp.tar.gz 2e023528bebbd2ac083fc91fbe6d5c4158c3336bedbcff48f594f3b28f53b940
|
download https://github.com/fpagliughi/sockpp/archive/refs/tags/v0.7.1.tar.gz dependencies/tmp/sockpp.tar.gz 2e023528bebbd2ac083fc91fbe6d5c4158c3336bedbcff48f594f3b28f53b940
|
||||||
|
|
||||||
|
@ -96,4 +98,4 @@ cmake --build build
|
||||||
popd >/dev/null 2>&1
|
popd >/dev/null 2>&1
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
rm -rv dependencies/tmp
|
remove dependencies/tmp
|
||||||
|
|
|
@ -15,20 +15,7 @@
|
||||||
# version 3 along with this program.
|
# version 3 along with this program.
|
||||||
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
|
||||||
if [ "$(tr '[:upper:]' '[:lower:]' <<< $SINGLE)" = "yes" ]; then
|
source scripts/lib.sh
|
||||||
echo "Building tests in single-threaded mode."
|
|
||||||
WAIT_ANYWAY="wait"
|
|
||||||
else
|
|
||||||
WAIT_ANYWAY=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$CXX" ]; then
|
|
||||||
CXX="c++"
|
|
||||||
fi
|
|
||||||
if [ -z "$CXXFLAGS" ]; then
|
|
||||||
CXXFLAGS="-std=c++20 -Wall -Wextra"
|
|
||||||
fi
|
|
||||||
CXX_WITH_FLAGS="$CXX $CXXFLAGS"
|
|
||||||
|
|
||||||
echo -n "Using LD_LIBRARY_PATH "
|
echo -n "Using LD_LIBRARY_PATH "
|
||||||
if [ -z "$LD_LIBRARY_PATH" ]; then
|
if [ -z "$LD_LIBRARY_PATH" ]; then
|
||||||
|
@ -38,7 +25,7 @@ else
|
||||||
fi
|
fi
|
||||||
echo "$LD_LIBRARY_PATH"
|
echo "$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
mkdir -pv bin/test
|
create_directory bin/test
|
||||||
|
|
||||||
echo "Building tests..."
|
echo "Building tests..."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue