mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Use shfmt as formatter for shell scripts
This commit is contained in:
parent
1e11fffb03
commit
c75584406a
2
.editorconfig
Normal file
2
.editorconfig
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[*.sh]
|
||||||
|
space_redirects = true
|
4
.github/workflows/style.yml
vendored
4
.github/workflows/style.yml
vendored
|
@ -23,6 +23,8 @@ jobs:
|
||||||
sudo apt-get install clang-format imagemagick ddnet-tools shellcheck pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev python3-clang libvulkan-dev glslang-tools spirv-tools -y
|
sudo apt-get install clang-format imagemagick ddnet-tools shellcheck pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev python3-clang libvulkan-dev glslang-tools spirv-tools -y
|
||||||
rustup default stable
|
rustup default stable
|
||||||
pip3 install pylint
|
pip3 install pylint
|
||||||
|
wget -O ~/.local/bin/shfmt https://github.com/mvdan/sh/releases/download/v3.8.0/shfmt_v3.8.0_linux_amd64
|
||||||
|
chmod +x ~/.local/bin/shfmt
|
||||||
git clone https://gitlab.com/Patiga/twmap.git/
|
git clone https://gitlab.com/Patiga/twmap.git/
|
||||||
cd twmap/twmap-tools
|
cd twmap/twmap-tools
|
||||||
cargo install --locked --path=.
|
cargo install --locked --path=.
|
||||||
|
@ -60,6 +62,8 @@ jobs:
|
||||||
# fi
|
# fi
|
||||||
- name: Shellcheck
|
- name: Shellcheck
|
||||||
run: find . -type f -name '*.sh' -print0 | xargs -0 shellcheck
|
run: find . -type f -name '*.sh' -print0 | xargs -0 shellcheck
|
||||||
|
- name: Shell format (shfmt)
|
||||||
|
run: find . -type f -name '*.sh' -print0 | xargs -0 shfmt -d
|
||||||
- name: Check log error case
|
- name: Check log error case
|
||||||
run: |
|
run: |
|
||||||
if grep -Eqr '(msg|Print).*\(.*"[Ee]rror:' src/;
|
if grep -Eqr '(msg|Print).*\(.*"[Ee]rror:' src/;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
command -v a2x >/dev/null 2>&1 || {
|
command -v a2x > /dev/null 2>&1 || {
|
||||||
echo >&2 "You need asciidoc installed";
|
echo >&2 "You need asciidoc installed"
|
||||||
echo >&2 "Debian/Ubuntu: sudo apt install asciidoc";
|
echo >&2 "Debian/Ubuntu: sudo apt install asciidoc"
|
||||||
echo >&2 "http://asciidoc.org/";
|
echo >&2 "http://asciidoc.org/"
|
||||||
exit 1;
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
@ -20,4 +20,3 @@ EOF
|
||||||
|
|
||||||
a2x --doctype manpage --format manpage DDNet.adoc
|
a2x --doctype manpage --format manpage DDNet.adoc
|
||||||
a2x --doctype manpage --format manpage DDNetServer.adoc
|
a2x --doctype manpage --format manpage DDNetServer.adoc
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
case "$(uname -s)" in
|
case "$(uname -s)" in
|
||||||
CYGWIN*|MINGW*|MSYS*)
|
CYGWIN* | MINGW* | MSYS*)
|
||||||
if [ -d "$APPDATA/DDNet/" ]; then
|
if [ -d "$APPDATA/DDNet/" ]; then
|
||||||
explorer "$APPDATA/DDNet/"
|
explorer "$APPDATA/DDNet/"
|
||||||
else
|
else
|
||||||
explorer "$APPDATA/Teeworlds/"
|
explorer "$APPDATA/Teeworlds/"
|
||||||
fi;;
|
fi
|
||||||
Darwin*)
|
;;
|
||||||
if [ -d "$HOME/Library/Application Support/DDNet/" ]; then
|
Darwin*)
|
||||||
open "$HOME/Library/Application Support/DDNet/"
|
if [ -d "$HOME/Library/Application Support/DDNet/" ]; then
|
||||||
else
|
open "$HOME/Library/Application Support/DDNet/"
|
||||||
open "$HOME/Library/Application Support/Teeworlds/"
|
else
|
||||||
fi;;
|
open "$HOME/Library/Application Support/Teeworlds/"
|
||||||
*)
|
fi
|
||||||
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
;;
|
||||||
if [ -d "$DATA_HOME/ddnet/" ]; then
|
*)
|
||||||
xdg-open "$DATA_HOME/ddnet/"
|
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||||
else
|
if [ -d "$DATA_HOME/ddnet/" ]; then
|
||||||
xdg-open "$HOME/.teeworlds/"
|
xdg-open "$DATA_HOME/ddnet/"
|
||||||
fi;;
|
else
|
||||||
|
xdg-open "$HOME/.teeworlds/"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -24,35 +24,35 @@ _ANDROID_SUB_BUILD_DIR=build_arch
|
||||||
_SHOW_USAGE_INFO=0
|
_SHOW_USAGE_INFO=0
|
||||||
|
|
||||||
if [ -z ${1+x} ]; then
|
if [ -z ${1+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass android build type, using default: ${_DEFAULT_ANDROID_BUILD}"
|
printf "\e[31m%s\e[30m\n" "Did not pass android build type, using default: ${_DEFAULT_ANDROID_BUILD}"
|
||||||
_SHOW_USAGE_INFO=1
|
_SHOW_USAGE_INFO=1
|
||||||
else
|
else
|
||||||
_DEFAULT_ANDROID_BUILD=$1
|
_DEFAULT_ANDROID_BUILD=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${2+x} ]; then
|
if [ -z ${2+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass game name, using default: ${_DEFAULT_GAME_NAME}"
|
printf "\e[31m%s\e[30m\n" "Did not pass game name, using default: ${_DEFAULT_GAME_NAME}"
|
||||||
_SHOW_USAGE_INFO=1
|
_SHOW_USAGE_INFO=1
|
||||||
else
|
else
|
||||||
_DEFAULT_GAME_NAME=$2
|
_DEFAULT_GAME_NAME=$2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${3+x} ]; then
|
if [ -z ${3+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass package name, using default: ${_DEFAULT_PACKAGE_NAME}"
|
printf "\e[31m%s\e[30m\n" "Did not pass package name, using default: ${_DEFAULT_PACKAGE_NAME}"
|
||||||
_SHOW_USAGE_INFO=1
|
_SHOW_USAGE_INFO=1
|
||||||
else
|
else
|
||||||
_DEFAULT_PACKAGE_NAME=$3
|
_DEFAULT_PACKAGE_NAME=$3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${4+x} ]; then
|
if [ -z ${4+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass build type, using default: ${_DEFAULT_BUILD_TYPE}"
|
printf "\e[31m%s\e[30m\n" "Did not pass build type, using default: ${_DEFAULT_BUILD_TYPE}"
|
||||||
_SHOW_USAGE_INFO=1
|
_SHOW_USAGE_INFO=1
|
||||||
else
|
else
|
||||||
_DEFAULT_BUILD_TYPE=$4
|
_DEFAULT_BUILD_TYPE=$4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${5+x} ]; then
|
if [ -z ${5+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass build folder, using default: ${_DEFAULT_BUILD_FOLDER}"
|
printf "\e[31m%s\e[30m\n" "Did not pass build folder, using default: ${_DEFAULT_BUILD_FOLDER}"
|
||||||
_SHOW_USAGE_INFO=1
|
_SHOW_USAGE_INFO=1
|
||||||
else
|
else
|
||||||
_DEFAULT_BUILD_FOLDER=$5
|
_DEFAULT_BUILD_FOLDER=$5
|
||||||
|
@ -63,17 +63,17 @@ _ANDROID_JAR_KEY_PW=android
|
||||||
_ANDROID_JAR_KEY_ALIAS=androiddebugkey
|
_ANDROID_JAR_KEY_ALIAS=androiddebugkey
|
||||||
|
|
||||||
if [ -z ${TW_KEY_NAME+x} ]; then
|
if [ -z ${TW_KEY_NAME+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass a key for the jar signer, using default: ${_ANDROID_JAR_KEY_NAME}"
|
printf "\e[31m%s\e[30m\n" "Did not pass a key for the jar signer, using default: ${_ANDROID_JAR_KEY_NAME}"
|
||||||
else
|
else
|
||||||
_ANDROID_JAR_KEY_NAME=$TW_KEY_NAME
|
_ANDROID_JAR_KEY_NAME=$TW_KEY_NAME
|
||||||
fi
|
fi
|
||||||
if [ -z ${TW_KEY_PW+x} ]; then
|
if [ -z ${TW_KEY_PW+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass a key pw for the jar signer, using default: ${_ANDROID_JAR_KEY_PW}"
|
printf "\e[31m%s\e[30m\n" "Did not pass a key pw for the jar signer, using default: ${_ANDROID_JAR_KEY_PW}"
|
||||||
else
|
else
|
||||||
_ANDROID_JAR_KEY_PW=$TW_KEY_PW
|
_ANDROID_JAR_KEY_PW=$TW_KEY_PW
|
||||||
fi
|
fi
|
||||||
if [ -z ${TW_KEY_ALIAS+x} ]; then
|
if [ -z ${TW_KEY_ALIAS+x} ]; then
|
||||||
printf "\e[31m%s\e[30m\n" "Did not pass a key alias for the jar signer, using default: ${_ANDROID_JAR_KEY_ALIAS}"
|
printf "\e[31m%s\e[30m\n" "Did not pass a key alias for the jar signer, using default: ${_ANDROID_JAR_KEY_ALIAS}"
|
||||||
else
|
else
|
||||||
_ANDROID_JAR_KEY_ALIAS=$TW_KEY_ALIAS
|
_ANDROID_JAR_KEY_ALIAS=$TW_KEY_ALIAS
|
||||||
fi
|
fi
|
||||||
|
@ -110,8 +110,8 @@ export TW_VERSION_NAME=$_ANDROID_VERSION_NAME
|
||||||
|
|
||||||
printf "\e[31m%s\e[1m\n" "Building with setting, for arch: ${_DEFAULT_ANDROID_BUILD}, with build type: ${_DEFAULT_BUILD_TYPE}, with name: ${_DEFAULT_GAME_NAME} (${_DEFAULT_PACKAGE_NAME})"
|
printf "\e[31m%s\e[1m\n" "Building with setting, for arch: ${_DEFAULT_ANDROID_BUILD}, with build type: ${_DEFAULT_BUILD_TYPE}, with name: ${_DEFAULT_GAME_NAME} (${_DEFAULT_PACKAGE_NAME})"
|
||||||
|
|
||||||
if [ $_SHOW_USAGE_INFO == 1 ]; then
|
if [ $_SHOW_USAGE_INFO == 1 ]; then
|
||||||
printf "\e[31m%s\e[1m\n" "Usage: ./cmake_android.sh <x86/x86_64/arm/arm64/all> <Game name> <Package name> <Debug/Release> <Build folder>"
|
printf "\e[31m%s\e[1m\n" "Usage: ./cmake_android.sh <x86/x86_64/arm/arm64/all> <Game name> <Package name> <Debug/Release> <Build folder>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\e[33mBuilding cmake\e[0m\n"
|
printf "\e[33mBuilding cmake\e[0m\n"
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
[ "$1" == "" ] && {
|
[ "$1" == "" ] && {
|
||||||
printf '\e[31mDid not pass APK name to build script\e[30m\n'
|
printf '\e[31mDid not pass APK name to build script\e[30m\n'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$2" == "" ] && {
|
[ "$2" == "" ] && {
|
||||||
printf '\e[31mDid not pass package name to build script\e[30m\n'
|
printf '\e[31mDid not pass package name to build script\e[30m\n'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$3" == "" ] && {
|
[ "$3" == "" ] && {
|
||||||
printf '\e[31mDid not pass build type to build script\e[30m\n'
|
printf '\e[31mDid not pass build type to build script\e[30m\n'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,15 +19,15 @@ _APK_BASENAME="$1"
|
||||||
_APK_PACKAGE_NAME="$2"
|
_APK_PACKAGE_NAME="$2"
|
||||||
_APK_BUILD_TYPE="$3"
|
_APK_BUILD_TYPE="$3"
|
||||||
|
|
||||||
_APK_PACKAGE_FOLDER=$(echo "$_APK_PACKAGE_NAME"|sed 's/\./\//g')
|
_APK_PACKAGE_FOLDER=$(echo "$_APK_PACKAGE_NAME" | sed 's/\./\//g')
|
||||||
|
|
||||||
sed -i "s/DDNet/${_APK_BASENAME}/g" settings.gradle
|
sed -i "s/DDNet/${_APK_BASENAME}/g" settings.gradle
|
||||||
|
|
||||||
sed -i "s/org.ddnet.client/${_APK_PACKAGE_NAME}/g" build.gradle
|
sed -i "s/org.ddnet.client/${_APK_PACKAGE_NAME}/g" build.gradle
|
||||||
|
|
||||||
TW_KEY_NAME_ESCAPED=$(echo "$TW_KEY_NAME"|sed 's/\//\\\//g')
|
TW_KEY_NAME_ESCAPED=$(echo "$TW_KEY_NAME" | sed 's/\//\\\//g')
|
||||||
TW_KEY_PW_ESCAPED=$(echo "$TW_KEY_PW"|sed 's/\//\\\//g')
|
TW_KEY_PW_ESCAPED=$(echo "$TW_KEY_PW" | sed 's/\//\\\//g')
|
||||||
TW_KEY_ALIAS_ESCAPED=$(echo "$TW_KEY_ALIAS"|sed 's/\//\\\//g')
|
TW_KEY_ALIAS_ESCAPED=$(echo "$TW_KEY_ALIAS" | sed 's/\//\\\//g')
|
||||||
|
|
||||||
sed -i "s/TW_KEY_NAME/${TW_KEY_NAME_ESCAPED}/g" build.gradle
|
sed -i "s/TW_KEY_NAME/${TW_KEY_NAME_ESCAPED}/g" build.gradle
|
||||||
sed -i "s/TW_KEY_PW/${TW_KEY_PW_ESCAPED}/g" build.gradle
|
sed -i "s/TW_KEY_PW/${TW_KEY_PW_ESCAPED}/g" build.gradle
|
||||||
|
@ -65,7 +65,7 @@ if [[ -z ${GE_NO_APK_BUILD} || "${GE_NO_APK_BUILD}" != "1" ]]; then
|
||||||
_RELEASE_TYPE_NAME=release
|
_RELEASE_TYPE_NAME=release
|
||||||
_RELEASE_TYPE_APK_NAME=
|
_RELEASE_TYPE_APK_NAME=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
APP_BASE_NAME=Gradle
|
APP_BASE_NAME=Gradle
|
||||||
CLASSPATH=gradle-wrapper.jar
|
CLASSPATH=gradle-wrapper.jar
|
||||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all
|
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all
|
||||||
|
@ -77,11 +77,10 @@ if [[ -z ${GE_NO_APK_BUILD} || "${GE_NO_APK_BUILD}" != "1" ]]; then
|
||||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleRelease
|
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleRelease
|
||||||
fi
|
fi
|
||||||
cp build/outputs/apk/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".apk "$_APK_BASENAME".apk
|
cp build/outputs/apk/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".apk "$_APK_BASENAME".apk
|
||||||
|
|
||||||
|
|
||||||
if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then
|
if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then
|
||||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all bundleRelease
|
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all bundleRelease
|
||||||
|
|
||||||
cp build/outputs/bundle/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".aab "$_APK_BASENAME".aab
|
cp build/outputs/bundle/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".aab "$_APK_BASENAME".aab
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -5,7 +5,7 @@ c_headers=(assert complex ctype errno fenv float inttypes iso646 limits locale m
|
||||||
c_headers_map=(cassert complex cctype cerrno cfenv cfloat cinttypes ciso646 climits clocale cmath csetjmp csignal cstdarg cstdbool cstddef cstdint cstdio cstdlib cstring ctgmath ctime cwchar cwctype)
|
c_headers_map=(cassert complex cctype cerrno cfenv cfloat cinttypes ciso646 climits clocale cmath csetjmp csignal cstdarg cstdbool cstddef cstdint cstdio cstdlib cstring ctgmath ctime cwchar cwctype)
|
||||||
|
|
||||||
# Create regex dynamically from the array to match any C header
|
# Create regex dynamically from the array to match any C header
|
||||||
c_headers_regex=$(IFS="|"; echo "${c_headers[*]}")
|
c_headers_regex=$(printf "%s" "${c_headers[*]}" | tr ' ' '|')
|
||||||
|
|
||||||
# Find all C++ source and header files
|
# Find all C++ source and header files
|
||||||
files=$(find ./src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' \) ! -path "./src/engine/external/*")
|
files=$(find ./src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' \) ! -path "./src/engine/external/*")
|
||||||
|
@ -15,10 +15,10 @@ error_found=0
|
||||||
# Check each source file for C headers
|
# Check each source file for C headers
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
# First check if the file includes any C headers for more efficiency when no C header is used
|
# First check if the file includes any C headers for more efficiency when no C header is used
|
||||||
if grep -E "#include\s+<($c_headers_regex)\.h>" "$file" >/dev/null; then
|
if grep -E "#include\s+<($c_headers_regex)\.h>" "$file" > /dev/null; then
|
||||||
# Check each C header individually to print an error message with the appropriate replacement C++ header
|
# Check each C header individually to print an error message with the appropriate replacement C++ header
|
||||||
for (( i=0; i < ${#c_headers[@]}; i++ )); do
|
for ((i = 0; i < ${#c_headers[@]}; i++)); do
|
||||||
if grep -E "#include\s+<${c_headers[i]}\.h>" "$file" >/dev/null; then
|
if grep -E "#include\s+<${c_headers[i]}\.h>" "$file" > /dev/null; then
|
||||||
echo "Error: '$file' includes C header '${c_headers[i]}.h'. Include the C++ header '${c_headers_map[i]}' instead."
|
echo "Error: '$file' includes C header '${c_headers[i]}.h'. Include the C++ header '${c_headers_map[i]}' instead."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -11,7 +11,7 @@ if [[ "${2}" == "webasm" ]]; then
|
||||||
COMPILEFLAGS="-pthread -O3 -g -s USE_PTHREADS=1"
|
COMPILEFLAGS="-pthread -O3 -g -s USE_PTHREADS=1"
|
||||||
LINKFLAGS="-pthread -O3 -g -s USE_PTHREADS=1 -s ASYNCIFY=1"
|
LINKFLAGS="-pthread -O3 -g -s USE_PTHREADS=1 -s ASYNCIFY=1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMPILEFLAGS=$3
|
COMPILEFLAGS=$3
|
||||||
LINKFLAGS=$4
|
LINKFLAGS=$4
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
CURDIR="$PWD"
|
CURDIR="$PWD"
|
||||||
if [ -z ${1+x} ]; then
|
if [ -z ${1+x} ]; then
|
||||||
echo "Give a destination path where to run this script, please choose a path other than in the source directory"
|
echo "Give a destination path where to run this script, please choose a path other than in the source directory"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${2+x} ]; then
|
if [ -z ${2+x} ]; then
|
||||||
echo "Specify the target system"
|
echo "Specify the target system"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OS_NAME=$2
|
OS_NAME=$2
|
||||||
|
|
||||||
COMPILEFLAGS="-fPIC"
|
COMPILEFLAGS="-fPIC"
|
||||||
LINKFLAGS="-fPIC"
|
LINKFLAGS="-fPIC"
|
||||||
if [[ "${OS_NAME}" == "webasm" ]]; then
|
if [[ "${OS_NAME}" == "webasm" ]]; then
|
||||||
|
|
|
@ -25,7 +25,7 @@ function buid_openssl() {
|
||||||
if [[ "$_EXISTS_PROJECT" == "0" ]]; then
|
if [[ "$_EXISTS_PROJECT" == "0" ]]; then
|
||||||
if [[ "${4}" == "webasm" ]]; then
|
if [[ "${4}" == "webasm" ]]; then
|
||||||
emconfigure ../Configure "$2" -no-tests -no-asm -static -no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom
|
emconfigure ../Configure "$2" -no-tests -no-asm -static -no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom
|
||||||
|
|
||||||
sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
|
sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
|
||||||
else
|
else
|
||||||
../Configure "$2" no-asm no-shared
|
../Configure "$2" no-asm no-shared
|
||||||
|
|
|
@ -77,4 +77,3 @@ function compile_all_opusfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_all_opusfile "$1" "$2"
|
compile_all_opusfile "$1" "$2"
|
||||||
|
|
||||||
|
|
|
@ -32,21 +32,21 @@ function make_sqlite3() {
|
||||||
LDFLAGS="${LINKER_FLAGS} -L./" \
|
LDFLAGS="${LINKER_FLAGS} -L./" \
|
||||||
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
|
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
|
||||||
${TMP_COMPILER} \
|
${TMP_COMPILER} \
|
||||||
-c \
|
-c \
|
||||||
-fPIC \
|
-fPIC \
|
||||||
-DSQLITE_ENABLE_ATOMIC_WRITE=1 \
|
-DSQLITE_ENABLE_ATOMIC_WRITE=1 \
|
||||||
-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE=1 \
|
-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE=1 \
|
||||||
-DSQLITE_ENABLE_MULTITHREADED_CHECKS=1 \
|
-DSQLITE_ENABLE_MULTITHREADED_CHECKS=1 \
|
||||||
-DSQLITE_THREADSAFE=1 \
|
-DSQLITE_THREADSAFE=1 \
|
||||||
../sqlite3.c \
|
../sqlite3.c \
|
||||||
-o sqlite3.o
|
-o sqlite3.o
|
||||||
|
|
||||||
LDFLAGS="${LINKER_FLAGS} -L./" \
|
LDFLAGS="${LINKER_FLAGS} -L./" \
|
||||||
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
|
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
|
||||||
${TMP_AR} \
|
${TMP_AR} \
|
||||||
rvs \
|
rvs \
|
||||||
sqlite3.a \
|
sqlite3.a \
|
||||||
sqlite3.o
|
sqlite3.o
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,4 +62,3 @@ function compile_all_sqlite3() {
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_all_sqlite3 "$1" "$2"
|
compile_all_sqlite3 "$1" "$2"
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
arg_verbose=0
|
arg_verbose=0
|
||||||
arg_valgrind_memcheck=0
|
arg_valgrind_memcheck=0
|
||||||
|
|
||||||
for arg in "$@"
|
for arg in "$@"; do
|
||||||
do
|
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]; then
|
||||||
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]
|
|
||||||
then
|
|
||||||
echo "usage: $(basename "$0") [OPTION..]"
|
echo "usage: $(basename "$0") [OPTION..]"
|
||||||
echo "description:"
|
echo "description:"
|
||||||
echo " Runs a simple integration test of the client and server"
|
echo " Runs a simple integration test of the client and server"
|
||||||
|
@ -16,11 +14,9 @@ do
|
||||||
echo " --verbose|-v verbose output"
|
echo " --verbose|-v verbose output"
|
||||||
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
|
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]
|
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]; then
|
||||||
then
|
|
||||||
arg_verbose=1
|
arg_verbose=1
|
||||||
elif [ "$arg" == "--valgrind-memcheck" ]
|
elif [ "$arg" == "--valgrind-memcheck" ]; then
|
||||||
then
|
|
||||||
arg_valgrind_memcheck=1
|
arg_valgrind_memcheck=1
|
||||||
else
|
else
|
||||||
echo "Error: unknown argument '$arg'"
|
echo "Error: unknown argument '$arg'"
|
||||||
|
@ -28,13 +24,11 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -f DDNet ]
|
if [ ! -f DDNet ]; then
|
||||||
then
|
|
||||||
echo "[-] Error: client binary 'DDNet' not found"
|
echo "[-] Error: client binary 'DDNet' not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -f DDNet-Server ]
|
if [ ! -f DDNet-Server ]; then
|
||||||
then
|
|
||||||
echo "[-] Error: server binary 'DDNet-Server' not found"
|
echo "[-] Error: server binary 'DDNet-Server' not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -44,30 +38,25 @@ got_killed=0
|
||||||
|
|
||||||
function kill_all() {
|
function kill_all() {
|
||||||
# needed to fix hang fifo with additional ctrl+c
|
# needed to fix hang fifo with additional ctrl+c
|
||||||
if [ "$got_killed" == "1" ]
|
if [ "$got_killed" == "1" ]; then
|
||||||
then
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
got_killed=1
|
got_killed=1
|
||||||
|
|
||||||
if [ "$arg_verbose" == "1" ]
|
if [ "$arg_verbose" == "1" ]; then
|
||||||
then
|
|
||||||
echo "[*] Shutting down test clients and server"
|
echo "[*] Shutting down test clients and server"
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
if [[ ! -f fail_server.txt ]]
|
if [[ ! -f fail_server.txt ]]; then
|
||||||
then
|
|
||||||
echo "[*] Shutting down server"
|
echo "[*] Shutting down server"
|
||||||
echo "shutdown" > server.fifo
|
echo "shutdown" > server.fifo
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
local i
|
local i
|
||||||
for ((i=1;i<3;i++))
|
for ((i = 1; i < 3; i++)); do
|
||||||
do
|
if [[ ! -f fail_client$i.txt ]]; then
|
||||||
if [[ ! -f fail_client$i.txt ]]
|
|
||||||
then
|
|
||||||
echo "[*] Shutting down client$i"
|
echo "[*] Shutting down client$i"
|
||||||
echo "quit" > "client$i.fifo"
|
echo "quit" > "client$i.fifo"
|
||||||
fi
|
fi
|
||||||
|
@ -81,8 +70,7 @@ function cleanup() {
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
function fail()
|
function fail() {
|
||||||
{
|
|
||||||
sleep 1
|
sleep 1
|
||||||
tail -n2 "$1".log > fail_"$1".txt
|
tail -n2 "$1".log > fail_"$1".txt
|
||||||
echo "$1 exited with code $2" >> fail_"$1".txt
|
echo "$1 exited with code $2" >> fail_"$1".txt
|
||||||
|
@ -90,7 +78,7 @@ function fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get unused port from the system by binding to port 0 and immediately closing the socket again
|
# Get unused port from the system by binding to port 0 and immediately closing the socket again
|
||||||
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');
|
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
|
||||||
|
|
||||||
if [[ $OSTYPE == 'darwin'* ]]; then
|
if [[ $OSTYPE == 'darwin'* ]]; then
|
||||||
DETECT_LEAKS=0
|
DETECT_LEAKS=0
|
||||||
|
@ -113,8 +101,7 @@ function print_results() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"; then
|
||||||
then
|
|
||||||
echo "[-] Error: ASAN has detected the following errors:"
|
echo "[-] Error: ASAN has detected the following errors:"
|
||||||
cat SAN.*
|
cat SAN.*
|
||||||
return 1
|
return 1
|
||||||
|
@ -153,15 +140,12 @@ function wait_for_fifo() {
|
||||||
# give the server/client time to launch and create the fifo file
|
# give the server/client time to launch and create the fifo file
|
||||||
# but assume after X secs that the server/client crashed before
|
# but assume after X secs that the server/client crashed before
|
||||||
# being able to create the file
|
# being able to create the file
|
||||||
while [[ ! -p "$fifo" ]]
|
while [[ ! -p "$fifo" ]]; do
|
||||||
do
|
fails="$((fails + 1))"
|
||||||
fails="$((fails+1))"
|
if [ "$arg_verbose" == "1" ]; then
|
||||||
if [ "$arg_verbose" == "1" ]
|
|
||||||
then
|
|
||||||
echo "[!] Note: $fifo not found (attempts $fails/$tries)"
|
echo "[!] Note: $fifo not found (attempts $fails/$tries)"
|
||||||
fi
|
fi
|
||||||
if [ "$fails" -gt "$tries" ]
|
if [ "$fails" -gt "$tries" ]; then
|
||||||
then
|
|
||||||
echo "[-] Error: $(basename "$fifo" .fifo) possibly crashed on launch"
|
echo "[-] Error: $(basename "$fifo" .fifo) possibly crashed on launch"
|
||||||
kill_all
|
kill_all
|
||||||
print_results
|
print_results
|
||||||
|
@ -282,34 +266,29 @@ fi
|
||||||
# Kill all processes first so all outputs are fully written
|
# Kill all processes first so all outputs are fully written
|
||||||
kill_all
|
kill_all
|
||||||
|
|
||||||
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log
|
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log; then
|
||||||
then
|
|
||||||
touch fail_chat.txt
|
touch fail_chat.txt
|
||||||
echo "[-] Error: chat message not found in server log"
|
echo "[-] Error: chat message not found in server log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep -q 'cmdlist' client1.log || \
|
if ! grep -q 'cmdlist' client1.log ||
|
||||||
! grep -q 'pause' client1.log || \
|
! grep -q 'pause' client1.log ||
|
||||||
! grep -q 'rank' client1.log || \
|
! grep -q 'rank' client1.log ||
|
||||||
! grep -q 'points' client1.log
|
! grep -q 'points' client1.log; then
|
||||||
then
|
|
||||||
touch fail_chatcommand.txt
|
touch fail_chatcommand.txt
|
||||||
echo "[-] Error: did not find output of /cmdlist command"
|
echo "[-] Error: did not find output of /cmdlist command"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep -q "hello from admin" server.log
|
if ! grep -q "hello from admin" server.log; then
|
||||||
then
|
|
||||||
touch fail_rcon.txt
|
touch fail_rcon.txt
|
||||||
echo "[-] Error: admin message not found in server log"
|
echo "[-] Error: admin message not found in server log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep -q "demo_player: Stopped playback" client1.log
|
if ! grep -q "demo_player: Stopped playback" client1.log; then
|
||||||
then
|
|
||||||
touch fail_demo_server.txt
|
touch fail_demo_server.txt
|
||||||
echo "[-] Error: demo playback of server demo in client 1 was not started/finished"
|
echo "[-] Error: demo playback of server demo in client 1 was not started/finished"
|
||||||
fi
|
fi
|
||||||
if ! grep -q "demo_player: Stopped playback" client2.log
|
if ! grep -q "demo_player: Stopped playback" client2.log; then
|
||||||
then
|
|
||||||
touch fail_demo_client.txt
|
touch fail_demo_client.txt
|
||||||
echo "[-] Error: demo playback of client demo in client 2 was not started/finished"
|
echo "[-] Error: demo playback of client demo in client 2 was not started/finished"
|
||||||
fi
|
fi
|
||||||
|
@ -324,33 +303,27 @@ player: client1 time: 168300.5 cps: 0.02 0.06 0.12 15300.14 15300.18 30600.2 306
|
||||||
player: client2 time: 302.02 cps: 0.42 0.5 0.0 0.66 0.92 0.02 300.18 300.46 300.76 300.88 300.98 301.16 301.24 301.28 301.3 301.86 301.96 0.0 0.0 0.0 0.0 0.0 0.0"
|
player: client2 time: 302.02 cps: 0.42 0.5 0.0 0.66 0.92 0.02 300.18 300.46 300.76 300.88 300.98 301.16 301.24 301.28 301.3 301.86 301.96 0.0 0.0 0.0 0.0 0.0 0.0"
|
||||||
|
|
||||||
# require at least one rank in all cases. Exact finishes only with valgrind disabled
|
# require at least one rank in all cases. Exact finishes only with valgrind disabled
|
||||||
if [ "$ranks" == "" ]
|
if [ "$ranks" == "" ]; then
|
||||||
then
|
|
||||||
touch fail_ranks.txt
|
touch fail_ranks.txt
|
||||||
echo "[-] Error: no ranks found in database"
|
echo "[-] Error: no ranks found in database"
|
||||||
elif [ "$arg_valgrind_memcheck" != "1" ] && [ "$rank_time" != "$expected_times" ]
|
elif [ "$arg_valgrind_memcheck" != "1" ] && [ "$rank_time" != "$expected_times" ]; then
|
||||||
then
|
|
||||||
touch fail_ranks.txt
|
touch fail_ranks.txt
|
||||||
echo "[-] Error: unexpected finish time"
|
echo "[-] Error: unexpected finish time"
|
||||||
echo " expected: $expected_times"
|
echo " expected: $expected_times"
|
||||||
echo " got: $rank_time"
|
echo " got: $rank_time"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for logfile in client1.log client2.log server.log
|
for logfile in client1.log client2.log server.log; do
|
||||||
do
|
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||||
if [ "$arg_valgrind_memcheck" == "1" ]
|
|
||||||
then
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$logfile" ]
|
if [ ! -f "$logfile" ]; then
|
||||||
then
|
|
||||||
echo "[-] Error: logfile '$logfile' not found"
|
echo "[-] Error: logfile '$logfile' not found"
|
||||||
touch fail_logs.txt
|
touch fail_logs.txt
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
logdiff="$(diff -u <(grep -v "console: .* access for .* is now .*abled" "$logfile" | sort) <(sort "stdout_$(basename "$logfile" .log).txt"))"
|
logdiff="$(diff -u <(grep -v "console: .* access for .* is now .*abled" "$logfile" | sort) <(sort "stdout_$(basename "$logfile" .log).txt"))"
|
||||||
if [ "$logdiff" != "" ]
|
if [ "$logdiff" != "" ]; then
|
||||||
then
|
|
||||||
echo "[-] Error: logfile '$logfile' differs from stdout"
|
echo "[-] Error: logfile '$logfile' differs from stdout"
|
||||||
echo "$logdiff"
|
echo "$logdiff"
|
||||||
echo "[-] Error: logfile '$logfile' differs from stdout" >> fail_logs.txt
|
echo "[-] Error: logfile '$logfile' differs from stdout" >> fail_logs.txt
|
||||||
|
@ -358,24 +331,19 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for stderr in ./stderr_*.txt
|
for stderr in ./stderr_*.txt; do
|
||||||
do
|
if [ ! -f "$stderr" ]; then
|
||||||
if [ ! -f "$stderr" ]
|
|
||||||
then
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$(cat "$stderr")" == "" ]
|
if [ "$(cat "$stderr")" == "" ]; then
|
||||||
then
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "[!] Warning: $stderr"
|
echo "[!] Warning: $stderr"
|
||||||
cat "$stderr"
|
cat "$stderr"
|
||||||
done
|
done
|
||||||
|
|
||||||
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"
|
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"; then
|
||||||
then
|
for fail in fail_*; do
|
||||||
for fail in fail_*
|
|
||||||
do
|
|
||||||
cat "$fail"
|
cat "$fail"
|
||||||
done
|
done
|
||||||
print_results
|
print_results
|
||||||
|
|
|
@ -46,13 +46,12 @@ function prine_line_for_address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ADDR_PC_REGEX='[0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+'
|
ADDR_PC_REGEX='[0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+'
|
||||||
while read -r line
|
while read -r line; do
|
||||||
do
|
|
||||||
if [[ $line =~ $ADDR_PC_REGEX ]]; then
|
if [[ $line =~ $ADDR_PC_REGEX ]]; then
|
||||||
# Check for main executable file with address information
|
# Check for main executable file with address information
|
||||||
EXE_FILE_RELATIVE_ADDR=$(echo "$line" | grep -E -o -m 1 "\s${EXE_FILE_FILENAME_REGEX}!.*0x[0-9A-Fa-f]+" | grep -E -o "0x[0-9A-Fa-f]+" | head -1)
|
EXE_FILE_RELATIVE_ADDR=$(echo "$line" | grep -E -o -m 1 "\s${EXE_FILE_FILENAME_REGEX}!.*0x[0-9A-Fa-f]+" | grep -E -o "0x[0-9A-Fa-f]+" | head -1)
|
||||||
if [ -n "$EXE_FILE_RELATIVE_ADDR" ]; then
|
if [ -n "$EXE_FILE_RELATIVE_ADDR" ]; then
|
||||||
prine_line_for_address "$(printf '0x%X\n' "$((EXE_FILE_RELATIVE_ADDR+ADDR_BASE))")"
|
prine_line_for_address "$(printf '0x%X\n' "$((EXE_FILE_RELATIVE_ADDR + ADDR_BASE))")"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -65,6 +64,6 @@ do
|
||||||
|
|
||||||
# Compatibilty with old crash logs: use the raw address and assume it belongs to the main executable
|
# Compatibilty with old crash logs: use the raw address and assume it belongs to the main executable
|
||||||
RAW_ADDR=$(echo "$line" | grep -E -o -m 1 "[0-9A-Fa-f]+ " | head -1)
|
RAW_ADDR=$(echo "$line" | grep -E -o -m 1 "[0-9A-Fa-f]+ " | head -1)
|
||||||
prine_line_for_address "$(printf '0x%X\n' "$(((0x$RAW_ADDR-0x$MODULE_OFFSET)+ADDR_BASE))")"
|
prine_line_for_address "$(printf '0x%X\n' "$(((0x$RAW_ADDR - 0x$MODULE_OFFSET) + ADDR_BASE))")"
|
||||||
fi
|
fi
|
||||||
done < "$CRASH_LOG_FILE"
|
done < "$CRASH_LOG_FILE"
|
||||||
|
|
Loading…
Reference in a new issue