@@ -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=$(( 25 * 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
@@ -132,7 +157,8 @@ function pre_build_osx {
132
157
# Check time limit (3min should be enough for a module to built)
133
158
local projected_time=$(( $(date +% s) - travis_start_time + 3 * 60 ))
134
159
if [ $projected_time -ge $time_limit ]; then
135
- echo " *** Not enough time to build $m : $(( projected_time/ 60 )) m (${projected_time} s)"
160
+ ccache -s
161
+ goto_exit
136
162
return 1
137
163
fi
138
164
make -j${num_cpus} " $m "
@@ -141,6 +167,7 @@ function pre_build_osx {
141
167
fi
142
168
done
143
169
make -j${num_cpus}
170
+ ccache -s
144
171
}
145
172
146
173
function build_osx {
@@ -176,9 +203,13 @@ function build_osx {
176
203
function build_bdist_osx_wheel {
177
204
local repo_dir=$( abspath ${1:- $REPO_DIR } )
178
205
[ -z " $repo_dir " ] && echo " repo_dir not defined" && exit 1
206
+ local wheelhouse=$( abspath ${WHEEL_SDIR:- wheelhouse} )
207
+ start_spinner
208
+ if [ -n " $( is_function " pre_build" ) " ]; then pre_build; fi
209
+ stop_spinner
210
+ pip install scikit-build
211
+ pip install numpy
179
212
pre_build_osx " $repo_dir " || return $?
180
- if [ -n " $BUILD_DEPENDS " ]; then
181
- pip install $( pip_opts) $BUILD_DEPENDS
182
- fi
183
213
build_osx " $repo_dir "
214
+ repair_wheelhouse " $wheelhouse "
184
215
}
0 commit comments