-
Notifications
You must be signed in to change notification settings - Fork 2
/
lxp-run
executable file
·110 lines (104 loc) · 2.17 KB
/
lxp-run
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
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
set -e
NUM_JOBS=${NUM_JOBS:--j8}
BUILD_ONLY=${BUILD_ONLY:-"OFF"}
BUILD_FOLDER="build"
RUN_ONLY=${RUN_ONLY:-"OFF"}
DEFINES=""
function show_help() {
echo "$0 --verbose --help"
echo "- Build options"
echo "$0 --build --bf [folder] --jobs N --def DEF1=VAL,DEF2=VAL"
echo "- Performance options"
echo "$0 --pgo-generate --pgo-use"
echo "- Run options"
echo "$0 --run --root --gdb --create-tap"
}
for i in "$@"
do
case $i in
-v|--verbose)
export VERBOSE=1
shift # past argument with no value
;;
--build)
BUILD_ONLY="ON"
shift # past argument with no value
;;
--bf)
shift
BUILD_FOLDER="$1"
shift # past argument with no value
;;
--def)
shift
echo "* Using #defines $1"
DEFINES="$1"
shift # past argument with no value
;;
-j|--jobs)
shift
NUM_JOBS=-j$1
shift # past argument with no value
;;
--pgo-generate)
CMAKE_OPTIONS="-DPGO_ENABLE=ON -DPGO_GENERATE=ON"
shift # past argument with no value
;;
--pgo-use)
CMAKE_OPTIONS="-DPGO_ENABLE=ON -DPGO_GENERATE=OFF"
shift # past argument with no value
;;
--run)
RUN_ONLY="ON"
shift # past argument with no value
;;
--root)
AS_ROOT="sudo -E"
shift # past argument with no value
;;
--gdb)
DBG="gdb"
shift # past argument with no value
;;
--create-tap)
set +e
sudo mknod /dev/net/tap c 10 200
set -e
shift # past argument with no value
;;
--flush)
set +e
sudo ip addr flush dev bridge43
set -e
shift # past argument with no value
;;
-h|--help)
show_help
exit
;;
*)
# unknown option
;;
esac
done
function make_service() {
mkdir -p $BUILD_FOLDER
pushd $BUILD_FOLDER
cmake .. "$@" $CMAKE_OPTIONS -DDEFINES=$DEFINES
make $NUM_JOBS
popd
}
# check that at least there is a cmake script here
if [ ! -f CMakeLists.txt ]; then
echo "There must be at least a CMakeLists.txt in service folder"
exit 1
fi
if [[ "$RUN_ONLY" = "OFF" ]]; then
make_service "$@"
fi
if [[ "$BUILD_ONLY" = "OFF" ]]; then
BINARY=$BUILD_FOLDER/"`cat build/binary.txt`"
# run with options
$AS_ROOT $DBG $BINARY
fi