-
Notifications
You must be signed in to change notification settings - Fork 71
/
build_d9.sh
executable file
·158 lines (135 loc) · 4.47 KB
/
build_d9.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
#!/bin/bash
# BMF compilation script
#
# To build for x86 (default):
# ./build.sh
#
# To clean up:
# ./build.sh clean
#
# For debug build:
# ./build.sh debug
#
# For debug build and generating coverage report:
# ./build.sh with_cov
#
# Default build type - Release
BUILD_TYPE="Release"
# For SCM compilation only:
#
# To compile for x86 (multiple Python versions):
# export SCRIPT_EXEC_MODE=x86
#
# Note: x86 package will include Python sdist for Python 3.6 - 3.9 (located in
# dist folder). The other folders are catered for SCM installation method.
COVERAGE_OPTION=0
# Handle options
if [ $# -gt 0 ]
then
# Clean up
if [ "$1" = "clean" ]
then
rm -rf build
exit
fi
# Debug type
if [ "$1" = "debug" ]
then
BUILD_TYPE="Debug"
fi
# Debug type with coverage option
if [ "$1" = "with_cov" ]
then
BUILD_TYPE="Debug"
COVERAGE_OPTION=1
fi
fi
mkdir -p output
# Generate BMF version
source ./version.sh
export EXACT_PYTHON_TARGET=1
# Create an output directory at repo root for packaging
mkdir -p output/dist
mkdir -p output/3rd_party
cp bmf/engine/c_engine/BUILTIN_CONFIG bmf
# Build x86
python_versions=(3.7)
python_names=(37)
for i in "${!python_versions[@]}"
do
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBMF_PYENV="${python_versions[$i]}" \
-DBMF_BUILD_VERSION=${BMF_BUILD_VERSION} \
-DBMF_BUILD_COMMIT=${BMF_BUILD_COMMIT} ..
make -j8
# Transfer to output directory to package
mkdir output/bmf/3rd_party
# Store the pre-compiled dependencies
cp -r /usr/local/build/lib/. output/bmf/3rd_party
cp /usr/local/boost_1_68_0/stage/lib/libboost_python"${python_names[$i]}".so.1.68.0 output/bmf/3rd_party
cp /usr/local/boost_1_68_0/stage/lib/libboost_numpy"${python_names[$i]}".so.1.68.0 output/bmf/3rd_party
cp /usr/local/boost_1_68_0/stage/lib/libboost_system.so.1.68.0 output/bmf/3rd_party
cp /usr/local/boost_1_68_0/stage/lib/libboost_filesystem.so.1.68.0 output/bmf/3rd_party
cp /usr/lib/x86_64-linux-gnu/libgflags.so.2.2 output/bmf/3rd_party
cp /usr/lib/x86_64-linux-gnu/libglog.so.0 output/bmf/3rd_party
cp /usr/lib/x86_64-linux-gnu/libunwind.so.8 output/bmf/3rd_party
cp -r output/bmf/lib/. output/bmf/3rd_party
# Patch rpath for dependencies
cd output/bmf/3rd_party
for libfile in *.so*
do
if [ -f "$libfile" ]; then
patchelf --set-rpath '$ORIGIN' "$libfile"
echo "Patch $libfile"
fi
done
cd ../../..
cp /usr/local/lib/libpython"${python_versions[$i]}"* output/bmf/3rd_party
mv output/bmf/3rd_party ../bmf/lib
cp -r /usr/local/build/bin/. output/bmf/bin/
cp -r output/bmf/bin ../bmf/bin
cp -r /usr/local/boost_1_68_0/boost output/bmf/include/
cp -r /usr/include/glog output/bmf/include/
cp -r ../3rd_party/json/include/. output/bmf/include/
cp -r output/bmf/include ../bmf/include
# Package for specific python version
cd ..
/usr/bin/python3.7 setup.py bdist_wheel
cd dist
for file in *.whl
do
echo "$file"
mv "$file" ../output/dist/"${file%-py3-none-any.whl}-cp${python_names[$i]}-none-linux_x86_64.whl"
done
cd ..
# Only include example and test for the default package
if [ "${python_versions[$i]}" == "3.7" ]
then
mv build/output/bmf output
mv build/output/example output/example
mv build/output/test output/test
fi
rm -rf build
rm -rf dist
rm -rf bmf/lib
rm -rf bmf/bin
rm -rf bmf/include
done
mkdir -p output/3rd_party/lib
cp -a -r 3rd_party/json output/3rd_party/
# glog
cp /usr/lib/x86_64-linux-gnu/libglog.so.* output/3rd_party/lib
# boost
cp /usr/local/boost_1_68_0/stage/lib/libboost_numpy37.so.1.68.0* output/3rd_party/lib
cp /usr/local/boost_1_68_0/stage/lib/libboost_system.so.1.68.0* output/3rd_party/lib
cp /usr/local/boost_1_68_0/stage/lib/libboost_python37.so.1.68.0* output/3rd_party/lib
cp /usr/local/boost_1_68_0/stage/lib/libboost_filesystem.so.1.68.0* output/3rd_party/lib
cp /usr/local/lib/libpython3.7* output/3rd_party/lib
# others
cp /usr/lib/x86_64-linux-gnu/libgflags.so.2.2* output/3rd_party/lib
cp /usr/lib/x86_64-linux-gnu/libunwind.so.8* output/3rd_party/lib
mkdir -p output/3rd_party/ffmpeg output/3rd_party/include
cp -a -r /usr/local/build/lib/. output/3rd_party/ffmpeg
cp -a -r /usr/local/build/bin/. output/3rd_party/ffmpeg
cp -a -r /usr/local/build/include/. output/3rd_party/include