-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakeme.sh
executable file
·77 lines (68 loc) · 1.76 KB
/
makeme.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
#!/bin/bash
# Exit the script if an error occurs
set -e
function check_submodule ()
{
submodule_name=${1}
test_file=${2}
main_branch=${3}
if [ -d "${submodule_name}/${test_file}" ]; then
echo "${submodule_name} exists"
else
echo "${submodule_name} does not exist"
echo "git submodules will be updated"
rm -r ${submodule_name}
git submodule update --init
pushd .
cd ${submodule_name}
git pull origin ${main_branch}
popd
fi
}
function do_the_build () {
echo ""
if [ $( git rev-parse --is-inside-work-tree ) ]; then
check_submodule "viz/glad" "src" "main"
check_submodule "viz/glfw" "src" "master"
check_submodule "viz/glm" "glm" "master"
check_submodule "viz/imgui" "backends" "master"
check_submodule "tests/exec_tests/Catch2_header_only" "catch2.hpp" "main"
else
echo "this is not a repository"
fi
pushd .
popd
pushd .
cd build
# Either pass the explicit help arg to the cmake file or give all function
# args to the cmake file
if [ "${1}" == "--help" ]; then
cmake -DHELP_SOS=1 -LAH ..
else
cmake $@ ..
num_jays=1
if [ -z $( which nproc ) ]; then
echo "the nproc command wasn't found, using two cores to build."
num_jays=4
else
if [ $( nproc ) -ge 4 ]; then
num_jays=4
else
echo "Using one core to build since there are only " $( nproc ) " available"
fi
fi
make -j ${num_jays}
fi
popd
}
if [ "${1}" == "--help" ]; then
args=$1
else
args=$@
fi
if [ -d build ]; then
do_the_build $args
else
mkdir build
do_the_build $args
fi