-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev
More file actions
executable file
·206 lines (188 loc) · 5.23 KB
/
Copy pathdev
File metadata and controls
executable file
·206 lines (188 loc) · 5.23 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
COMPOSE='docker-compose -p cardinal-cpp -f Docker/docker-compose.yml'
CWD=$(pwd)
if [[ -z "$1" ]]
then
echo "No command specified. Please try again with either 'up', 'down', 'build', or 'run'"
exit 0
fi
install_boost_di() {
# Check to see if we can use WGET or Curl
SRC="https://raw.githubusercontent.com/boost-ext/di/cpp14/include/boost/di.hpp"
DEST="$CWD/vendor/boost"
if [[ ! -d "$DEST" ]]
then
# Make dir with parents.
mkdir -p "$DEST"
fi
# Do CURL / WGET.
if [[ -x "$(command -v curl)" ]]
then
curl -o "$DEST/di.hpp" "$SRC/di.hpp"
elif [[ -x "$(command -v wget)" ]]
then
wget -O "$DEST/di.hpp" "$SRC/di.hpp"
else
echo "Unable to install boost::di. Please install either CURL or WGET."
exit 1
fi
}
install_submodules_manually() {
CONTENTS=$(cat .gitmodules | grep -E '(path|url).*' | cut -d " " -f 3)
CWD=$(pwd)
LAST=""
for item in ${CONTENTS[@]};
do
cd "$CWD"
STRINGHEAD=$( echo "$item" | cut -d '/' -f 1)
if [[ "$STRINGHEAD" == "vendor" ]]
then
if [[ -d "$CWD/$item" ]]
then
LAST=$(echo "$item")
echo "$item already exists."
continue
fi
mkdir -p "$item"
cd "$item"
LAST=$(echo "$item")
else
if [[ -d "$CWD/$LAST/.git" ]]
then
echo "$LAST already installed."
continue
fi
cd "$CWD/$LAST"
echo "Installing $item"
git config --global --add safe.directory "$CWD/$LAST"
git init .
git remote add origin $item
res=$(git pull origin master 2>&1)
if [[ "$res" == "fatal: couldn't find remote ref master" ]]
then
git pull origin main
fi
fi
done
}
install_modules () {
CWD=$(pwd)
if [[ ! -d "$CWD/vendor" ]]
then
mkdir "$CWD/vendor"
git submodule init
git submodule update
fi
if [[ ! -d "$CWD/vendor/microsoft" ]]
then
echo "Unable to auto-install using GIT, trying another route."
install_submodules_manually
else
echo "Submodules installed."
fi
if [[ ! -f "$CWD/vendor/boost/di.hpp" ]]
then
echo "Installing boost::di"
install_boost_di
fi
}
if [[ "$1" = "up" ]]
then
if [[ ! -d vendor ]]
then
mkdir vendor
fi
$COMPOSE $@
elif [[ "$1" = "down" ]]
then
$COMPOSE down
elif [[ "$1" = "install_modules" ]]
then
install_modules
elif [[ "$1" = "clean" ]]
then
rm -rf build/*
rm -rf build/.*
elif [[ "$1" = "ninja" ]]
then
./dev clean
/usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER='/usr/bin/clang' -DCMAKE_CXX_COMPILER='/usr/bin/clang++' -DCMAKE_MAKE_PROGRAM='/Users/sarahjabado/.vscode/extensions/powertech.powercpp-23.2.24/thirdparty/bin/ninja' -S/Users/sarahjabado/development/cardinal_c++ -B/Users/sarahjabado/development/cardinal_c++/build -G Ninja
elif [[ "$1" = "build" ]]
then
git config --global --add safe.directory '*'
install_modules
CWD=$(pwd)
if [[ ! -f "$CWD/vendor/microsoft/GSL/build/Makefile" ]]
then
cd "$CWD/vendor/microsoft/GSL/"
mkdir build
cd build
cmake ..
make
make install || echo "Cannot install Microsoft GSL on the system."
cd "$CWD"
fi
if [[ ! -f "$CWD/vendor/mariusbancila/stduuid/build/Makefile" ]]
then
cd "$CWD/vendor/mariusbancila/stduuid/"
mkdir build
cd build
cmake ..
make
cd "$CWD"
fi
if [[ ! -f "$CWD/vendor/sewenew/redis-plus-plus/build/Makefile" ]]
then
if [[ ! -d "$CWD/vendor/sewenew/redis-plus-plus/build" ]]
then
mkdir -p "$CWD/vendor/sewenew/redis-plus-plus/build"
fi
cd "$CWD/vendor/sewenew/redis-plus-plus/build"
pwd
cmake ..
make
cd "$CWD"
fi
cd "$CWD/vendor/sewenew/redis-plus-plus/build"
make install || echo "Cannot install redis-plus-plus on system."
cd "$CWD"
if [[ ! -d "$CWD/build" ]]
then
mkdir "$CWD/build"
else
rm -rf "$CWD/build/*"
fi
cd "$CWD/build" && export CXX=/usr/bin/clang++ && cmake .. && make
if [[ ! -f "$CWD/build/bin/libredis++.so.1" ]]
then
cp "$CWD/vendor/sewenew/redis-plus-plus/build/libredis++.so.1.3.6" "$CWD/build/bin/libredis++.so.1"
fi
if [[ ! -f "$CWD/build/bin/libcardinal.so" ]]
then
cp "$CWD/build/lib/libcardinal.so" "$CWD/build/bin/libcardinal.so"
fi
elif [[ "$1" = "run" ]]
then
./dev build
".$CWD/build/bin/cardinal-server"
elif [[ "$1" = "test" ]]
then
cd "$CWD/UnitTests/build" && rm -rf * && cmake .. && make && cd "$CWD"
RES=$(./UnitTests/build/TEST_Runner 2>&1)
echo "$RES"
if [[ "$RES" == *"FAILURE"* ]]
then
echo "Tests failed."
exit 1
elif [[ "$RES" == *"No such"* ]]
then
echo "Tests failed."
exit 1
else
echo "All Tests passed successfully."
exit 0
fi
elif [[ "$1" = "install" ]]
then
install_modules
fi