forked from Pravez/Octopoulpe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Oceans.sh
executable file
·161 lines (147 loc) · 3.81 KB
/
Oceans.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/sh
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
EXECUTABLE_NAME=""
usage(){
echo "Help : (run -h to get this menu)"
echo "Run with -p option to ask to this script to prepare everything (create build directory, cmake ..)"
echo "Run with -c option to ask to compile sources"
echo "Run with -r [executable name] to ask to run an executable"
echo "Executables are : \" Server \" for the Server in C, and \" Aquarium \" for the View in Java"
echo "If you want to clean : you can use \"--clean\" option to execute a make clean, or if you want to remove even the build directory, use \"--clean-everything\" "
}
prepare(){
echo "Creating build directory ..."
mkdir -p $SCRIPTPATH/build
echo "Moving to build/ ..."
cd $SCRIPTPATH/build
echo "Executing cmake ..."
cmake ../
}
compile(){
if [ -d $SCRIPTPATH/build ]
then
echo "Moving to build directory"
cd $SCRIPTPATH/build
if [ -f Makefile ]
then
echo "Compiling ..."
make all
else
echo "No makefile, are you sure you runned \"-p\" option first ?"
fi
else
echo "No build directory, are you sure you runned \"-p\" option first ?"
fi
}
execute(){
runned=false
{ if [ -d $SCRIPTPATH/build ]
then
echo "Moving to build directory"
cd $SCRIPTPATH/build
if [ "$EXECUTABLE_NAME" == "Server" ] && [ -f $SCRIPTPATH/build/Poseidon/src/Server ]
then
echo "Running Server ..."
cd $SCRIPTPATH/build/Poseidon/src
./Server
runned=true
fi
if [ "$EXECUTABLE_NAME" == "Aquarium" ] && [ -f $SCRIPTPATH/build/Aquarium/src/Aquarium.jar ]
then
echo "Running aquarium ..."
cd $SCRIPTPATH/build/Aquarium/src
java -cp Aquarium.jar sample.Aquarium
runned=true
fi
if [ ${runned} == false ]
then
echo "Please be sure to give a correct executable name"
fi
else
echo "No build directory, are you sure you runned \"-p\" option first ?"
fi }
}
test(){
runned=false
{ if [ -d $SCRIPTPATH/build ]
then
echo "Moving to build directory"
cd $SCRIPTPATH/build
if [ -f $SCRIPTPATH/build/Poseidon/tst/Test_intern_protocol ]
then
cd $SCRIPTPATH/build/Poseidon/tst
./Test_intern_protocol
runned=true
fi
if [ -f $SCRIPTPATH/build/Poseidon/tst/Test_parser ]
then
cd $SCRIPTPATH/build/Poseidon/tst
./Test_parser
runned=true
fi
if [ ${runned} == false ]
then
echo "Please be sure you compiled test executables"
fi
else
echo "No build directory, are you sure you runned \"-p\" option first ?"
fi }
}
clean(){
if [ -d $SCRIPTPATH/build ]
then
echo "Moving to build directory"
cd $SCRIPTPATH/build
if [ -f Makefile ]
then
echo "Cleaning ..."
make clean
else
echo "No makefile, are you sure you runned \"-p\" option
first ?"
fi
else
echo "No build directory, are you sure you runned \"-p\" option first ?"
fi
}
if [ $# -ge 1 ]
then
while [[ $# -ge 1 ]]
do
key="$1"
case $key in
-p|--prepare)
prepare
;;
-c|--compile)
compile
;;
-t|--test)
test
;;
-r|--run)
EXECUTABLE_NAME="$2"
execute
shift
;;
-h|--help)
usage
;;
--clean)
clean
;;
--clean-everything)
rm -rf build/
shift
;;
*)
echo "Unknown option"
;;
esac
shift
done
else
echo "Please give at least one option"
usage
fi