forked from interpretml/interpret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
300 lines (283 loc) · 13.1 KB
/
build.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/sh
clang_pp_bin=clang++
g_pp_bin=g++
os_type=`uname`
root_path=`dirname "$0"`
build_32_bit=0
for arg in "$@"; do
if [ "$arg" = "-32bit" ]; then
build_32_bit=1
fi
done
# re-enable these warnings when they are better supported by g++ or clang: -Wduplicated-cond -Wduplicated-branches -Wrestrict
compile_all="\"$root_path/core/DataSetByFeature.cpp\" \"$root_path/core/DataSetByFeatureCombination.cpp\" \"$root_path/core/InteractionDetection.cpp\" \"$root_path/core/Logging.cpp\" \"$root_path/core/SamplingWithReplacement.cpp\" \"$root_path/core/Training.cpp\" -I\"$root_path/core\" -I\"$root_path/core/inc\" -Wall -Wextra -Wno-parentheses -Wold-style-cast -Wdouble-promotion -Wshadow -Wformat=2 -std=c++11 -fpermissive -fvisibility=hidden -fvisibility-inlines-hidden -O3 -march=core2 -DEBMCORE_EXPORTS -fpic"
if [ "$os_type" = "Darwin" ]; then
# reference on rpath & install_name: https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
# try moving some of these clang specific warnings into compile_all if g++ eventually supports them
compile_mac="$compile_all -Wnull-dereference -dynamiclib"
printf "%s\n" "Creating initial directories"
[ -d "$root_path/staging" ] || mkdir -p "$root_path/staging"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/python/interpret/lib" ] || mkdir -p "$root_path/python/interpret/lib"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
printf "%s\n" "Compiling ebmcore with $clang_pp_bin for macOS release|x64"
[ -d "$root_path/tmp/clang/intermediate/release/mac/x64/ebmcore" ] || mkdir -p "$root_path/tmp/clang/intermediate/release/mac/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/clang/bin/release/mac/x64/ebmcore" ] || mkdir -p "$root_path/tmp/clang/bin/release/mac/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$clang_pp_bin $compile_mac -m64 -DNDEBUG -install_name @rpath/lib_ebmcore_mac_x64.dylib -o \"$root_path/tmp/clang/bin/release/mac/x64/ebmcore/lib_ebmcore_mac_x64.dylib\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/clang/intermediate/release/mac/x64/ebmcore/ebmcore_release_mac_x64_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/release/mac/x64/ebmcore/lib_ebmcore_mac_x64.dylib" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/release/mac/x64/ebmcore/lib_ebmcore_mac_x64.dylib" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
printf "%s\n" "Compiling ebmcore with $clang_pp_bin for macOS debug|x64"
[ -d "$root_path/tmp/clang/intermediate/debug/mac/x64/ebmcore" ] || mkdir -p "$root_path/tmp/clang/intermediate/debug/mac/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/clang/bin/debug/mac/x64/ebmcore" ] || mkdir -p "$root_path/tmp/clang/bin/debug/mac/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$clang_pp_bin $compile_mac -m64 -install_name @rpath/lib_ebmcore_mac_x64_debug.dylib -o \"$root_path/tmp/clang/bin/debug/mac/x64/ebmcore/lib_ebmcore_mac_x64_debug.dylib\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/clang/intermediate/debug/mac/x64/ebmcore/ebmcore_debug_mac_x64_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/debug/mac/x64/ebmcore/lib_ebmcore_mac_x64_debug.dylib" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/debug/mac/x64/ebmcore/lib_ebmcore_mac_x64_debug.dylib" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
if [ $build_32_bit -eq 1 ]; then
printf "%s\n" "Compiling ebmcore with $clang_pp_bin for macOS release|x86"
[ -d "$root_path/tmp/clang/intermediate/release/mac/x86/ebmcore" ] || mkdir -p "$root_path/tmp/clang/intermediate/release/mac/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/clang/bin/release/mac/x86/ebmcore" ] || mkdir -p "$root_path/tmp/clang/bin/release/mac/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$clang_pp_bin $compile_mac -m32 -DNDEBUG -install_name @rpath/lib_ebmcore_mac_x86.dylib -o \"$root_path/tmp/clang/bin/release/mac/x86/ebmcore/lib_ebmcore_mac_x86.dylib\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/clang/intermediate/release/mac/x86/ebmcore/ebmcore_release_mac_x86_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/release/mac/x86/ebmcore/lib_ebmcore_mac_x86.dylib" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/release/mac/x86/ebmcore/lib_ebmcore_mac_x86.dylib" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
printf "%s\n" "Compiling ebmcore with $clang_pp_bin for macOS debug|x86"
[ -d "$root_path/tmp/clang/intermediate/debug/mac/x86/ebmcore" ] || mkdir -p "$root_path/tmp/clang/intermediate/debug/mac/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/clang/bin/debug/mac/x86/ebmcore" ] || mkdir -p "$root_path/tmp/clang/bin/debug/mac/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$clang_pp_bin $compile_mac -m32 -install_name @rpath/lib_ebmcore_mac_x86_debug.dylib -o \"$root_path/tmp/clang/bin/debug/mac/x86/ebmcore/lib_ebmcore_mac_x86_debug.dylib\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/clang/intermediate/debug/mac/x86/ebmcore/ebmcore_debug_mac_x86_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/debug/mac/x86/ebmcore/lib_ebmcore_mac_x86_debug.dylib" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/clang/bin/debug/mac/x86/ebmcore/lib_ebmcore_mac_x86_debug.dylib" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
fi
elif [ "$os_type" = "Linux" ]; then
# to cross compile for different architectures x86/x64, run the following command: sudo apt-get install g++-multilib
# try moving some of these g++ specific warnings into compile_all if clang eventually supports them
compile_linux="$compile_all -Wlogical-op -Wl,--version-script=\"$root_path/core/ebmcore_exports.txt\" -Wl,--exclude-libs,ALL -Wl,--wrap=memcpy \"$root_path/core/wrap_func.cpp\" -static-libgcc -static-libstdc++ -shared"
printf "%s\n" "Creating initial directories"
[ -d "$root_path/staging" ] || mkdir -p "$root_path/staging"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/python/interpret/lib" ] || mkdir -p "$root_path/python/interpret/lib"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
printf "%s\n" "Compiling ebmcore with $g_pp_bin for Linux release|x64"
[ -d "$root_path/tmp/gcc/intermediate/release/linux/x64/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/intermediate/release/linux/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/gcc/bin/release/linux/x64/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/bin/release/linux/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$g_pp_bin $compile_linux -m64 -DNDEBUG -o \"$root_path/tmp/gcc/bin/release/linux/x64/ebmcore/lib_ebmcore_linux_x64.so\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/gcc/intermediate/release/linux/x64/ebmcore/ebmcore_release_linux_x64_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/release/linux/x64/ebmcore/lib_ebmcore_linux_x64.so" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/release/linux/x64/ebmcore/lib_ebmcore_linux_x64.so" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
printf "%s\n" "Compiling ebmcore with $g_pp_bin for Linux debug|x64"
[ -d "$root_path/tmp/gcc/intermediate/debug/linux/x64/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/intermediate/debug/linux/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/gcc/bin/debug/linux/x64/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/bin/debug/linux/x64/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$g_pp_bin $compile_linux -m64 -o \"$root_path/tmp/gcc/bin/debug/linux/x64/ebmcore/lib_ebmcore_linux_x64_debug.so\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/gcc/intermediate/debug/linux/x64/ebmcore/ebmcore_debug_linux_x64_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/debug/linux/x64/ebmcore/lib_ebmcore_linux_x64_debug.so" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/debug/linux/x64/ebmcore/lib_ebmcore_linux_x64_debug.so" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
if [ $build_32_bit -eq 1 ]; then
printf "%s\n" "Compiling ebmcore with $g_pp_bin for Linux release|x86"
[ -d "$root_path/tmp/gcc/intermediate/release/linux/x86/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/intermediate/release/linux/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/gcc/bin/release/linux/x86/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/bin/release/linux/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$g_pp_bin $compile_linux -m32 -DNDEBUG -o \"$root_path/tmp/gcc/bin/release/linux/x86/ebmcore/lib_ebmcore_linux_x86.so\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/gcc/intermediate/release/linux/x86/ebmcore/ebmcore_release_linux_x86_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/release/linux/x86/ebmcore/lib_ebmcore_linux_x86.so" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/release/linux/x86/ebmcore/lib_ebmcore_linux_x86.so" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
printf "%s\n" "Compiling ebmcore with $g_pp_bin for Linux debug|x86"
[ -d "$root_path/tmp/gcc/intermediate/debug/linux/x86/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/intermediate/debug/linux/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
[ -d "$root_path/tmp/gcc/bin/debug/linux/x86/ebmcore" ] || mkdir -p "$root_path/tmp/gcc/bin/debug/linux/x86/ebmcore"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
compile_command="$g_pp_bin $compile_linux -m32 -o \"$root_path/tmp/gcc/bin/debug/linux/x86/ebmcore/lib_ebmcore_linux_x86_debug.so\" 2>&1"
compile_out=`eval $compile_command`
ret_code=$?
printf "%s\n" "$compile_out"
printf "%s\n" "$compile_out" > "$root_path/tmp/gcc/intermediate/debug/linux/x86/ebmcore/ebmcore_debug_linux_x86_build_log.txt"
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/debug/linux/x86/ebmcore/lib_ebmcore_linux_x86_debug.so" "$root_path/python/interpret/lib/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
cp "$root_path/tmp/gcc/bin/debug/linux/x86/ebmcore/lib_ebmcore_linux_x86_debug.so" "$root_path/staging/"
ret_code=$?
if [ $ret_code -ne 0 ]; then
exit $ret_code
fi
fi
else
printf "%s\n" "OS $os_type not recognized. We support $clang_pp_bin on macOS and $g_pp_bin on Linux"
exit 1
fi