-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·81 lines (71 loc) · 1.73 KB
/
run.sh
File metadata and controls
executable file
·81 lines (71 loc) · 1.73 KB
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
#!/bin/bash
#makeAndRun(){
# if command -v cmake &> /dev/null; then
# echo "CMake found!!"
# cmake --version
# else
# sudo apt install cmake
# echo "CMake installed!!"
# cmake --version
# fi
# if command -v ninja &> /dev/null; then
# echo "ninja found!!"
# ninja --version
# else
# sudo apt install ninja-build
# echo "ninja installed!!"
# ninja --version
# fi
# cd ninja
# cmake -G Ninja ..
# ninja
# ./solver
#}
#if [ -d "./ninja" ]; then
# makeAndRun
#else
# mkdir ninja
# makeAndRun
#fi
makeAndRun() {
# Check for CMake
if command -v cmake >/dev/null 2>&1; then
echo -n "CMake found!! "
cmake --version | head -n 1 | cut -d ' ' -f 3
else
echo "Installing CMake..."
sudo apt install cmake -y || { echo "Failed to install CMake"; exit 1; }
echo -n "CMake installed!! "
cmake --version | head -n 1 | cut -d ' ' -f 3
fi
# Check for Ninja (unchanged)
if command -v ninja >/dev/null 2>&1; then
echo "Ninja found!!"
ninja --version
else
echo "Installing Ninja..."
sudo apt install ninja-build -y || { echo "Failed to install Ninja"; exit 1; }
echo "Ninja installed!!"
ninja --version
fi
# Build and run (unchanged)
if ! cd ninja; then
echo "Failed to change to ninja directory"
exit 1
fi
cmake -G Ninja .. || { echo "CMake configuration failed"; exit 1; }
ninja || { echo "Ninja build failed"; exit 1; }
if [ -f "./solver" ]; then
./solver
else
echo "Solver executable not found!"
exit 1
fi
}
# Main logic (unchanged)
if [ -d "./ninja" ]; then
makeAndRun
else
mkdir ninja || { echo "Failed to create ninja directory"; exit 1; }
makeAndRun
fi