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.
725NPROC=$( grep --count ^processor /proc/cpuinfo 2> /dev/null || sysctl -n hw.ncpu || 2)
826# Save one core for the gui.
927PROC_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
1532fi
1633
@@ -26,22 +43,26 @@ if [ "$DIRNAME" != "." ]; then
2643 TARGET=$( echo " ${TARGET} " | sed ' s/\./_/g' )
2744fi
2845
29- # echo FILENAME: ${FILENAME}
30- # echo TARGET: ${TARGET}
31-
46+ # Change behavior if the target is a file or directory.
3247if [ -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 " .
3651elif [ -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 " .
4055else
41- echo Aborting: " $1 " is neither a file nor directory
56+ echo Aborting: " $1 " is neither a file nor directory.
4257 exit 1
4358fi
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