-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sh
executable file
·43 lines (38 loc) · 1.01 KB
/
build.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
#!/bin/bash
if [[ -f "Grail_Workspace.code-workspace" ]]; then
echo "\"Grail_Workspace.code-workspace\" found, most likely in Grail's root"
elif [[ $(pwd | awk -F"/" '{print $NF}') == "test" ]]; then
echo "Current directory is a test directory, assuming Grail's test"
cd ..
elif [[ -z ${GRAIL} ]]; then # Currently does not find GRAIL
echo "GRAIL environment variable set"
cd "${GRAIL}" || exit 1
pwd
fi
if [ -d "build" ]; then
echo "Build directory found"
cd "build" || exit 1
else
if [[ -f "CMakeLists.txt" ]]; then
mkdir build
cd "build" || exit 1
else
{
echo "Error: no CMakeLists.txt, no build directory"
echo "Are you in the right directory?"
} >/dev/stderr
exit 1
fi
fi
if ! [ -f "build.ninja" ]; then
cmake -GNinja ..
fi
if [ "$#" -eq 1 ]; then
ninja "$1"
else
ninja
fi
cd .. || exit 1
if [[ ! -L "compile_commands.json" ]]; then
cp build/compile_commands.json compile_commands.json
fi