Skip to content

Commit

Permalink
fix debug script, add shellcheck config
Browse files Browse the repository at this point in the history
  • Loading branch information
Razish committed Sep 27, 2023
1 parent ae93787 commit cc97c41
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
external-sources=true
disable=SC2002 # Useless cat
enable=check-extra-masked-returns,deprecate-which,quote-safe-variables
19 changes: 15 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"

# fetch arguments
ARGS=($@)
ARGS=("$@")
ARGSLEN=${#ARGS[@]}

# options
Expand All @@ -17,7 +19,7 @@ NOGEOIP=0
USE_ASAN=0
export NO_SSE=1

build='scons -Q'
build="scons -Q"

for ((i = 0; i < ARGSLEN; i++)); do
case ${ARGS[$i]} in
Expand All @@ -28,7 +30,7 @@ for ((i = 0; i < ARGSLEN; i++)); do
DEBUG=2
;;
"analyse")
build='scan-build $build'
build="scan-build \$build"
;;
"use_asan")
USE_ASAN=1
Expand All @@ -53,4 +55,13 @@ for ((i = 0; i < ARGSLEN; i++)); do
esac
done

$build debug=$DEBUG force32=$FORCE32 no_sql=$NOSQL no_notify=$NONOTIFY no_crashhandler=$NOCRASHHANDLER no_geoip=$NOGEOIP use_asan=$USE_ASAN project=$PROJECT tools=$TOOLS
$build \
"debug=$DEBUG" \
"force32=$FORCE32" \
"no_crashhandler=$NOCRASHHANDLER" \
"no_geoip=$NOGEOIP" \
"no_notify=$NONOTIFY" \
"no_sql=$NOSQL" \
"project=$PROJECT" \
"tools=$TOOLS" \
"use_asan=$USE_ASAN"
13 changes: 12 additions & 1 deletion clean.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"

# fetch arguments
ARGS=("$@")
ARGSLEN=${#ARGS[@]}
Expand Down Expand Up @@ -50,7 +52,16 @@ for ((i = 0; i < ARGSLEN; i++)); do
esac
done

$clean debug=$DEBUG force32=$FORCE32 no_sql=$NOSQL no_notify=$NONOTIFY no_crashhandler=$NOCRASHHANDLER no_geoip=$NOGEOIP use_asan=$USE_ASAN project=$PROJECT tools=$TOOLS
$clean \
"debug=$DEBUG" \
"force32=$FORCE32" \
"no_crashhandler=$NOCRASHHANDLER" \
"no_geoip=$NOGEOIP" \
"no_notify=$NONOTIFY" \
"no_sql=$NOSQL" \
"project=$PROJECT" \
"tools=$TOOLS" \
"use_asan=$USE_ASAN"

# remove any lingering object files
find . -type f -name "*.os" -delete
5 changes: 4 additions & 1 deletion debug.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
# usage: debug.sh [binary] [additional args]
set -euo pipefail

cd "$(dirname "$0")"

assert_dir() {
[ -d "$1" ] && return 0
echo >&2 "missing ./$1 symlink"
Expand All @@ -11,4 +14,4 @@ assert_dir basepath
assert_dir cdpath
assert_dir homepath

"${1-openjk}" +set fs_basepath "basepath" +set fs_homepath "homepath" +set fs_cdpath "cdpath" +set fs_game "japlus" "${*:2}"
gdb -ex=r --args "${1-openjk}" +set fs_basepath "basepath" +set fs_homepath "homepath" +set fs_cdpath "cdpath" +set fs_game "japlus" "${@:2}"

0 comments on commit cc97c41

Please sign in to comment.