Compare commits

..

No commits in common. "d90e7f16bd94f521fc3d9d2a3a18a37c4644abe9" and "4f1ad714bd7f6c9a1f9fa6ba2a629f2c7fc57e51" have entirely different histories.

8 changed files with 55 additions and 134 deletions

View File

@ -22,19 +22,13 @@ Immediate goals:
### Prerequisites:
Build dependencies:
This project requires bash and a C++20 compiler.
- bash
- a C++ 20 compiler
The project setup requires wget or curl, gzip, and tar.
Setup dependencies:
Additional requirements for building dependencies:
- wget or curl
- gzip
- sha256sum (or NetBSD's sha256, hashalot's sha256 will not work)
- tar
- a C compiler (for sockpp)
- CMake (for sockpp)
- sockpp: a C compiler, CMake
**For people using other shells than bash:** You need to at least have bash
installed to use the scripts, but using it as your shell while working on

View File

@ -76,20 +76,3 @@ Also removes the endianness header and the endianness check binary.
Removes and re-creates `dependencies/` and prunes the download cache of files
that either have been corrupted or are no longer used.
# lib
This is not a script you are supposed to run. It's a library that contains
some functions for the other scripts to work properly on all platforms.
Features it provides:
- `$WAIT_ANYWAY`: a variable containing the `wait` command if `SINGLE=yes`
is set.
- `$CXX_WITH_FLAGS`: deals with `CXX` and `CXXFLAGS` environment variables
so it can be used as a generic compiler command
- function `check_sha256`: deals with `sha256sum` and NetBSD's `sha256`
- function `remove`: better verbosity
- function `create_directory`: alternative to `mkdir -v` because that's not
available on some systems
- function `create_file`: the same but for files

View File

@ -15,7 +15,20 @@
# version 3 along with this program.
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
source scripts/lib.sh
if [ "$(tr '[:upper:]' '[:lower:]' <<< $SINGLE)" = "yes" ]; then
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 [ -f .endianness ]; then
@ -34,7 +47,7 @@ fi
# `.cpp` files in src/lib will be automatically picked up and compiled into
# dynamically linked libraries.
echo "Building libs..."
create_directory bin/lib
mkdir -pv bin/lib
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"
echo $COMPILE_COMMAND
@ -56,7 +69,7 @@ wait
# when running a program
# Example: LD_LIBRARY_PATH=bin/lib bin/tools/dumpnbt
echo "Building tools..."
create_directory bin/tools
mkdir -pv bin/tools
# add compile commands to this array
COMPILE_COMMANDS=(
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:javacompat.so -o bin/tools/dumpnbt"

View File

@ -15,15 +15,13 @@
# version 3 along with this program.
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
source scripts/lib.sh
remove ./bin
remove ./include
remove .endianness
remove resources/check_endianness
create_directory ./bin
create_directory ./bin/lib
create_directory ./include
rm -rv ./bin
rm -rv ./include
rm -vf .endianness
rm -vf resources/check_endianness
mkdir -v ./bin
mkdir -v ./bin/lib
mkdir -v ./include
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/
@ -32,5 +30,6 @@ 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/tiny-utf8-4.4.3/include/tinyutf8/ ./include/
create_file ./bin/.placeholder
create_file ./include/.placeholder
set -v
echo -n "" > ./bin/.placeholder
echo -n "" > ./include/.placeholder

View File

@ -15,13 +15,11 @@
# version 3 along with this program.
# 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..."
for file in $(ls .download_cache); do
#TODO: remove if unknown shasum
if grep $file scripts/setup_project.sh >/dev/null 2>&1; then
if check_sha256 ".download_cache/$file" "$file"; then
if sha256sum --check <<< "$file *.download_cache/$file" >/dev/null 2>&1; then
echo -n "."
else
echo -n "!"
@ -34,6 +32,7 @@ for file in $(ls .download_cache); do
done
echo ""
remove ./dependencies
create_directory ./dependencies
create_file ./dependencies/.placeholder
rm -rv ./dependencies
mkdir -v ./dependencies
set -v
echo -n "" > ./dependencies/.placeholder

View File

@ -1,78 +0,0 @@
#!/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 dont 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"
}

View File

@ -15,8 +15,6 @@
# version 3 along with this program.
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
source scripts/lib.sh
echo -n "Wget or curl? "
if command -v wget >/dev/null 2>&1; then
USE_WGET=yes
@ -38,11 +36,11 @@ function download {
if [ ! -d .download_cache ]; then
echo "Cache directory missing."
create_directory .download_cache
mkdir -v .download_cache
fi
if [ -f ".download_cache/$SHA256SUM" ]; then
if check_sha256 ".download_cache/$SHA256SUM" "$SHA256SUM"; then
if sha256sum --check <<< "$SHA256SUM *.download_cache/$SHA256SUM" >/dev/null 2>&1; then
echo "Using locally cached file for $DESTINATION"
cp ".download_cache/$SHA256SUM" "$DESTINATION"
return 0
@ -59,7 +57,7 @@ function download {
else
curl -L "$URL" --output ".download_cache/$SHA256SUM" >/dev/null 2>&1
fi
if check_sha256 ".download_cache/$SHA256SUM" "$SHA256SUM"; then
if sha256sum --check <<< "$SHA256SUM *.download_cache/$SHA256SUM" >/dev/null 2>&1; then
cp ".download_cache/$SHA256SUM" "$DESTINATION"
echo "done."
return 0
@ -78,7 +76,7 @@ echo "Cleaning dependencies..."
scripts/clean_dependencies.sh
set -e # failures are not acceptable here
create_directory dependencies/tmp
mkdir -v 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.7.1.tar.gz dependencies/tmp/sockpp.tar.gz 2e023528bebbd2ac083fc91fbe6d5c4158c3336bedbcff48f594f3b28f53b940
@ -98,4 +96,4 @@ cmake --build build
popd >/dev/null 2>&1
echo "done."
remove dependencies/tmp
rm -rv dependencies/tmp

View File

@ -15,7 +15,20 @@
# version 3 along with this program.
# If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
source scripts/lib.sh
if [ "$(tr '[:upper:]' '[:lower:]' <<< $SINGLE)" = "yes" ]; then
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 "
if [ -z "$LD_LIBRARY_PATH" ]; then
@ -25,7 +38,7 @@ else
fi
echo "$LD_LIBRARY_PATH"
create_directory bin/test
mkdir -pv bin/test
echo "Building tests..."