-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.sh
executable file
·84 lines (76 loc) · 2.56 KB
/
setup.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
#!/bin/bash
if [ "$(uname)" == "Linux" ]; then
YELLOW="\e[33m"
DEFAULT="\e[0m"
RED="\e[31m"
elif [ "$(uname)" == "Darwin" ]; then
RED="\033[0;31m"
DEFAULT="\033[0m"
YELLOW="\033[1;33m"
else
RED=""
DEFAULT=""
YELLOW=""
echo "INFO: Colored text disabled"
fi
echoerr() {
echo -e "${RED}Error${DEFAULT} - Invalid arguments: ${RED}$1${DEFAULT}"
echo "Expected one of the following modes of operation:"
echo " Mode 1: setup.sh (dev|eosdev|prod|eosprod|develop|production) (e.g., 'setup.sh dev')"
echo " Mode 2: setup.sh compiler (docker|local) (e.g., 'setup.sh compiler docker')"
}
if [[ $# -eq 1 ]];
then
if [[ "$1" == "dev" || "$1" == "develop" ]];
then
ENV="development"
elif [[ "$1" == "prod" || "$1" == "production" ]];
then
ENV="production"
elif [[ "$1" == "eosdev" || "$1" == "eosdevelop" ]];
then
ENV="eos_development"
elif [[ "$1" == "eosprod" || "$1" == "eosproduction" ]];
then
ENV="eos_production"
else
echoerr "Expected one of the following (dev|eosdev|prod|eosprod|develop|production) i.e 'setup.sh dev'"
exit
fi
# Get setup.sh directory since we could be running this script from a different location
CWD="$(dirname "$0")"
echo -e "\nConfiguring build for ${YELLOW}"$ENV"${DEFAULT}\n"
cp "$CWD/templates/config/$ENV.config.hpp" "$CWD/include/config/config.hpp"
mkdir -p build
elif [[ $# -eq 2 ]];
then
if [[ "$1" == "compiler" ]];
then
if [[ "$2" == "local" ]];
then
COMPILER="local"
elif [[ "$2" == "docker" ]];
then
COMPILER="docker"
else
echoerr "Expected 'local' or 'docker' as the second argument for mode 2."
exit
fi
# Get setup.sh directory since we could be running this script from a different location
CWD="$(dirname "$0")"
echo "\nConfiguring compiler for ${YELLOW}"$COMPILER"${DEFAULT}\n"
if [[ "$COMPILER" == "local" ]];
then
cp "$CWD/templates/cmake/CMakeLists.local.txt" "$CWD/CMakeLists.txt"
cp "$CWD/templates/cmake/CMakeLists_src.local.txt" "$CWD/src/CMakeLists.txt"
elif [[ "$COMPILER" == "docker" ]];
then
cp "$CWD/templates/cmake/CMakeLists.dune.txt" "$CWD/CMakeLists.txt"
cp "$CWD/templates/cmake/CMakeLists_src.dune.txt" "$CWD/src/CMakeLists.txt"
fi
else
echoerr "Expected 'compiler' as the first argument for mode 2."
fi
else
echoerr "Incorrect number of arguments."
fi