Skip to content

Commit 8a147fd

Browse files
committed
Merge pull request #44 from AlloSphere-Research-Group/run_debug
Merged debug.sh into run.sh.
2 parents b421e3d + b23edfc commit 8a147fd

File tree

2 files changed

+33
-53
lines changed

2 files changed

+33
-53
lines changed

debug.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

run.sh

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
#!/bin/sh
22

3+
# Pass -d to enter debugger mode.
4+
5+
if [ "$(uname -s)" = "Darwin" ]; then
6+
DEBUGGER=lldb
7+
else
8+
DEBUGGER=gdb
9+
fi
10+
311
# ------------------------------------------------
4-
# You shouldn't need to touch the stuff below
12+
# You shouldn't need to touch the stuff below.
13+
14+
# Runs the program through the specified debugger if -d is passed.
15+
OPTIND=1
16+
while getopts "d" opt; do
17+
case "$opt" in
18+
d) debugger="$DEBUGGER"
19+
shift
20+
;;
21+
esac
22+
done
523

624
# Get the number of processors on OS X, linux, and (to-do) Windows.
725
NPROC=$(grep --count ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu || 2)
826
# Save one core for the gui.
927
PROC_FLAG=$((NPROC - 1))
1028

11-
if [ $# = 0 ]
12-
then
13-
echo Aborting: You must provide a source filename or a directory
29+
if [ "$#" = 0 ]; then
30+
echo Aborting: You must provide a source filename or a directory.
1431
exit 1
1532
fi
1633

@@ -26,22 +43,26 @@ if [ "$DIRNAME" != "." ]; then
2643
TARGET=$(echo "${TARGET}" | sed 's/\./_/g')
2744
fi
2845

29-
#echo FILENAME: ${FILENAME}
30-
#echo TARGET: ${TARGET}
31-
46+
# Change behavior if the target is a file or directory.
3247
if [ -f "$1" ]; then
3348
TARGET_FLAG="-DALLOSYSTEM_BUILD_APP_FILE=$1"
3449
DBUILD_FLAG="-DALLOSYSTEM_BUILD_DIR=0"
35-
echo RUN SCRIPT: Building file "$1"
50+
echo RUN SCRIPT: Building file "$1".
3651
elif [ -d "$1" ]; then
3752
TARGET_FLAG="-DALLOSYSTEM_BUILD_APP_DIR=$1"
3853
DBUILD_FLAG="-DALLOSYSTEM_BUILD_DIR=1"
39-
echo RUN SCRIPT: Building all files in dir "$1"
54+
echo RUN SCRIPT: Building all files in dir "$1".
4055
else
41-
echo Aborting: "$1" is neither a file nor directory
56+
echo Aborting: "$1" is neither a file nor directory.
4257
exit 1
4358
fi
59+
# Don't pass target as Make flag.
60+
shift
4461

45-
cmake . "$TARGET_FLAG" "$DBUILD_FLAG" -DRUN_IN_DEBUGGER=0 -DCMAKE_BUILD_TYPE=Release -Wno-dev > cmake_log.txt
46-
make "$TARGET" -j "$PROC_FLAG" "$*"
62+
if [ -n "$debugger" ]; then
63+
cmake . "$TARGET_FLAG" "$DBUILD_FLAG" -DRUN_IN_DEBUGGER=1 "-DALLOSYSTEM_DEBUGGER=${debugger}" -DCMAKE_BUILD_TYPE=Debug > cmake_log.txt
64+
else
65+
cmake . "$TARGET_FLAG" "$DBUILD_FLAG" -DRUN_IN_DEBUGGER=0 -DCMAKE_BUILD_TYPE=Release -Wno-dev > cmake_log.txt
66+
fi
4767

68+
make "$TARGET" -j "$PROC_FLAG" "$*"

0 commit comments

Comments
 (0)