@@ -10,22 +10,47 @@ function package_name() {
10
10
wheel_name=$name
11
11
}
12
12
13
+ # Terminate the build but ensure saving the cache
14
+ function goto_exit {
15
+ local EXIT_CODE=${1:- 1}
16
+
17
+ echo " Exiting build"
18
+
19
+ # Can't just `exit` because that would terminate the build without saving the cache
20
+ # Have to replace further actions with no-ops
21
+
22
+ local MESSAGE=" " ; if [ " $EXIT_CODE " -ne 0 ]; then
23
+ MESSAGE=' Building package took too long. Restart the build in Travis UI to continue from cache.'
24
+ fi
25
+
26
+ set +e
27
+
28
+ eval '
29
+ function install_run {' \
30
+ " $( if [ -n " $MESSAGE " ]; then
31
+ echo ' echo -e "\n' " $MESSAGE " ' \n"'
32
+ fi) " \
33
+ '
34
+ # Travis runs user scripts via `eval` i.e. in the same shell process.
35
+ # So have to unset errexit in order to get to cache save stage
36
+ set +e
37
+ return ' " $EXIT_CODE " '
38
+ }'
39
+ }
40
+
13
41
function pre_build_osx {
14
42
local repo_dir=$( abspath ${1:- $REPO_DIR } )
15
43
local build_dir=" $repo_dir /opencv/build"
16
44
local num_cpus=$( sysctl -n hw.ncpu)
17
45
num_cpus=${num_cpus:- 4}
18
46
local travis_start_time=$(( $TRAVIS_TIMER_START_TIME / 10 ** 9 ))
19
- local time_limit=$(( 30 * 60 ))
47
+ local time_limit=$(( 46 * 60 ))
20
48
21
49
cd " $repo_dir "
22
50
git submodule sync
23
51
git submodule update --init --recursive opencv
24
52
git submodule update --init --recursive opencv_contrib
25
53
26
- pip install scikit-build
27
- pip install numpy
28
-
29
54
if [ ! -d " $build_dir " ]; then
30
55
mkdir " $build_dir "
31
56
fi
@@ -126,13 +151,15 @@ function pre_build_osx {
126
151
opencv_alphamat
127
152
opencv_stitching
128
153
opencv_gapi
154
+ all
129
155
)
130
156
for m in " ${CV_MODULES[@]} " ; do
131
157
if make help | grep -w " $m " ; then
132
158
# Check time limit (3min should be enough for a module to built)
133
159
local projected_time=$(( $(date +% s) - travis_start_time + 3 * 60 ))
134
160
if [ $projected_time -ge $time_limit ]; then
135
- echo " *** Not enough time to build $m : $(( projected_time/ 60 )) m (${projected_time} s)"
161
+ ccache -s
162
+ goto_exit
136
163
return 1
137
164
fi
138
165
make -j${num_cpus} " $m "
@@ -141,6 +168,7 @@ function pre_build_osx {
141
168
fi
142
169
done
143
170
make -j${num_cpus}
171
+ ccache -s
144
172
}
145
173
146
174
function build_osx {
@@ -176,9 +204,14 @@ function build_osx {
176
204
function build_bdist_osx_wheel {
177
205
local repo_dir=$( abspath ${1:- $REPO_DIR } )
178
206
[ -z " $repo_dir " ] && echo " repo_dir not defined" && exit 1
207
+ local wheelhouse=$( abspath ${WHEEL_SDIR:- wheelhouse} )
208
+ start_spinner
209
+ if [ -n " $( is_function " pre_build" ) " ]; then pre_build; fi
210
+ stop_spinner
211
+ pip install scikit-build
212
+ pip install numpy
179
213
pre_build_osx " $repo_dir " || return $?
180
- if [ -n " $BUILD_DEPENDS " ]; then
181
- pip install $( pip_opts) $BUILD_DEPENDS
182
- fi
183
214
build_osx " $repo_dir "
215
+ cp " $repo_dir " /dist/* .whl " $wheelhouse "
216
+ repair_wheelhouse " $wheelhouse "
184
217
}
0 commit comments