-
Notifications
You must be signed in to change notification settings - Fork 25
/
manage.sh
executable file
·258 lines (207 loc) · 6.21 KB
/
manage.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit
fi
# -------------------------------------------------------------------------------------------------
# Building
# -------------------------------------------------------------------------------------------------
if [ $1 == "rebuild" ]
then
rm -rf build
mkdir -p build &&
cd build && \
cmake .. -GNinja && \
ninja && \
cd ..
fi
if [ $1 == "build" ]
then
# Make sure macOS uses clang and not gcc
if [[ "$OSTYPE" == "darwin"* ]]; then
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
fi
ln -sf $(pwd)/data/screenshots $(pwd)/docs/images/ &&
mkdir -p build &&
cd build && \
cmake .. -GNinja && \
ninja && \
cd ..
fi
if [ $1 == "swiftshader" ]
then
mkdir -p build &&
cd build && \
cmake .. -GNinja -DDATOVIZ_WITH_SWIFTSHADER=1 && \
ninja && \
cd .. && \
LD_LIBRARY_PATH=data/swiftshader/linux ./build/datoviz test
fi
# -------------------------------------------------------------------------------------------------
# Code quality
# -------------------------------------------------------------------------------------------------
if [ $1 == "format" ]
then
find examples/ tests/ src/ include/ -iname *.h -o -iname *.c | xargs clang-format -i
fi
if [ $1 == "valgrind" ]
then
valgrind \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--verbose \
--suppressions=.valgrind.exceptions.txt \
--log-file=.valgrind.out.txt \
${@:2}
fi
if [ $1 == "cppcheck" ]
then
cppcheck --enable=all --inconclusive src/ include/ cli/ tests/ -i external 2> .cppcheck.out.txt && \
echo ".cppcheck.out.txt saved"
fi
if [ $1 == "prof" ]
then
gprof build/datoviz gmon.out
fi
# -------------------------------------------------------------------------------------------------
# Python bindings
# -------------------------------------------------------------------------------------------------
if [ $1 == "parseheaders" ]
then
python3 utils/parse_headers.py
fi
if [ $1 == "cython" ]
then
python3 utils/generate_cython.py && \
cd bindings/cython && \
python3 setup.py build_ext -i && \
python3 setup.py develop --user && \
cd ../..
if [[ "$OSTYPE" == "darwin"* ]]; then
install_name_tool -add_rpath `pwd`/build bindings/cython/datoviz/pydatoviz.*.so
fi
fi
if [ $1 == "pytest" ]
then
rm -f imgui.ini bindings/cython/imgui.ini bindings/cython/dist/imgui.ini
pytest bindings/cython/ -vv
fi
if [ $1 == "wheel" ]
then
ROOT_DIR=`pwd`
# macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
cd bindings/cython/
python3 setup.py build_ext -i
python3 setup.py sdist bdist_wheel
cd dist/
FILENAME=`ls datoviz*.whl`
echo $FILENAME
cp $FILENAME "$FILENAME~"
# broken: remove libvulkan from the wheel?? "-e libvulkan"
DYLD_LIBRARY_PATH=../../../build/ delocate-wheel $FILENAME -w . -e libvulkan
cd ../../../
# TODO: Windows
elif [[ "$OSTYPE" == "msys" ]]; then
echo "TODO!"
# manylinux
else
# Build the docker image.
sudo docker build -t datoviz_wheel -f Dockerfile_wheel .
# Clean up the Cython bindings before running the docker container.
cd bindings/cython && \
python3 setup.py clean --all && \
rm -rf build dist datoviz.egg-info datoviz/*.c datoviz/*.so datoviz/__pycache__ && \
cd ../../
# Make the wheel and repair it.
# Build a container based on a manylinux image, + Vulkan and other things needed by the
# datoviz build script.
sudo docker run --rm -v $ROOT_DIR:/io datoviz_wheel /io/wheel.sh && \
USER=`users | awk '{print $1}'`
sudo chown -R $USER:$USER bindings/cython/dist
fi
fi
if [ $1 == "testwheel" ]
then
# Test the wheel
cd bindings/cython/dist
rm -rf venv
virtualenv venv
venv/bin/python -m pip install --upgrade pip
venv/bin/pip install datoviz*.whl --upgrade
venv/bin/python -c "from datoviz import canvas, run; canvas().gui_demo(); run(0)"
# rm -rf venv
# cd ../../..
fi
# -------------------------------------------------------------------------------------------------
# Testing
# -------------------------------------------------------------------------------------------------
if [ $1 == "test" ]
then
dump=""
if [ ! -z "$3" ]
then
if [ $3 == "dump" ]
then
dump="VK_LAYER_LUNARG_api_dump"
fi
fi
VK_INSTANCE_LAYERS=$dump ./build/datoviz test $2
# When running all tests, also compile and run the standalone examples.
if [ -z "$2" ]
then
cd examples/standalone/
for filename in standalone_*.c*; do
./build.sh $filename automated
done
cd ../..
./build/datoviz demo
fi
fi
if [ $1 == "demo" ]
then
./build/datoviz demo $2
fi
# -------------------------------------------------------------------------------------------------
# Docker
# -------------------------------------------------------------------------------------------------
if [ $1 == "docker" ]
then
docker build -t datoviz .
fi
if [ $1 == "dockerrun" ]
then
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -h $HOSTNAME -v $HOME/.Xauthority:/home/datoviz/.Xauthority -it datoviz
fi
# -------------------------------------------------------------------------------------------------
# Documentation
# -------------------------------------------------------------------------------------------------
if [ $1 == "doc" ]
then
python3 utils/generate_doc.py && \
mkdocs build
fi
if [ $1 == "docs" ]
then
python3 utils/generate_doc.py && \
mkdocs serve
fi
if [ $1 == "publish" ]
then
SOURCE=`pwd`
mkdocs build
cd ../datoviz.github.io
ghp-import -b main -p $SOURCE/site
cd $SOURCE
fi
# -------------------------------------------------------------------------------------------------
# Release
# -------------------------------------------------------------------------------------------------
if [ $1 == "testpypi" ]
then
cd bindings/cython
twine upload --repository testpypi dist/*.whl dist/*.tar.gz
fi