-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.sh
executable file
·97 lines (78 loc) · 1.71 KB
/
launch.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
#!/bin/bash
BIN=boids
BUILD=build
CONFIG=Release
CFLAGS="-O2"
WORKDIR=$(pwd)
function usage() {
echo "Usage: ./launch.sh <ARG>"
echo " <ARG> may be one of: "
echo " - profile "
echo " - build "
echo " - run "
echo " - doit "
echo " - clean "
}
function profile() {
echo "Detecting profile..."
conan profile detect --force
}
function build() {
profile
cd $WORKDIR
echo "Building into $BUILD/..."
conan install . -c tools.system.package_manager:mode=install --output-folder=$BUILD --build=missing
echo "Entering $BUILD/..."
cd $BUILD
# export CMAKE_GENERATOR="Visual Studio 17 2022" to set default for CMake>=3.15
echo "Generating build system using env CMAKE_GENERATOR=$CMAKE_GENERATOR..."
cmake .. -DCMAKE_C_FLAGS=$CFLAGS -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$CONFIG
echo "Building with $CONFIG..."
cmake --build . --config $CONFIG
echo "Build finished."
}
function run() {
cd $WORKDIR
echo "Running with $CONFIG..."
echo ""
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
# windows environment
EXECUTABLE="$BUILD/$CONFIG/$BIN.exe"
else
# unix-based environment
EXECUTABLE="$BUILD/$BIN"
fi
if [[ -f "$EXECUTABLE" ]]; then
./"$EXECUTABLE"
else
echo "Error - executable $EXECUTABLE not found"
exit 1
fi
}
function clean() {
cd $WORKDIR
echo "Cleaning..."
rm -r build/
rm CMakeUserPresets.json
echo "Cleaned!"
}
case $1 in
profile)
profile
;;
build)
build
;;
run)
run
;;
doit)
build && run
;;
clean)
clean
;;
*)
usage
;;
esac