-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·99 lines (81 loc) · 1.77 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
set -e
# set -x
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
SRC_ROOT_DIR=$PROJECT_DIR
cd $SRC_ROOT_DIR
PROJECT_PATH="$SRC_ROOT_DIR"
BUILD_PATH="$SRC_ROOT_DIR/.build"
[[ ! -z "${getDevBuildPath}" ]] && eval "$getDevBuildPath" && BUILD_PATH=$(getDevBuildPath);
[[ -z "$NUM_CPU" ]] && NUM_CPU=$(getconf _NPROCESSORS_ONLN)
export DEPS_DIR_NAME=deps
export DEPS_SRC_DIR=$SRC_ROOT_DIR/$DEPS_DIR_NAME
export DEPS_BUILD_PATH=$BUILD_PATH/$DEPS_DIR_NAME
SILENT_MAKE="-s"
# VERBOSE_ARGS="-DCMAKE_VERBOSE_MAKEFILE=TRUE"
run(){
cd $BUILD_PATH
./$@
# | TZ=UTC ts '[%F %.T]'
cd ~-
}
debug(){
cd $BUILD_PATH
lldb $@
# | TZ=UTC ts '[%F %.T]'
cd ~-
}
printSize(){
echo BUILD_PATH: $BUILD_PATH
cd $BUILD_PATH
exec_files_array=(${@})
if [ -z "$exec_files_array" ]; then
executables=$(find . -maxdepth 1 -executable -type f -printf '%f ' || find . -maxdepth 1 -perm +0111 -type f)
if [ ! -z "$executables" ]; then
echo $executables | xargs md5
echo $executables | xargs size
echo $executables | xargs ls -la
fi
return
fi
for exec in "${exec_files_array[@]}"
do
md5 $exec
size $exec
ls -la $exec
done
cd ~-
}
build(){
mkdir -p $BUILD_PATH
cd $BUILD_PATH
[[ ! -f "Makefile" ]] && cmake $VERBOSE_ARGS $PROJECT_PATH
make $SILENT_MAKE -j $NUM_CPU $@
cd ~-
}
compile(){
build $@;
printSize $@;
}
ACTION="$1"
shift;
if [[ $ACTION == "c" ]]; then
build clean;
elif [[ $ACTION == "b" ]]; then
compile $@;
elif [[ $ACTION == "br" ]]; then
app=$1
shift;
compile $app;
run $app $@;
elif [[ $ACTION == "brd" ]]; then
app=$1
shift;
compile $app;
debug $app $@;
elif [[ $ACTION == "id" ]] ; then
deps/init.sh
elif [[ $ACTION == "bd" ]]; then
deps/build.sh
else
run $ACTION $@
fi