Skip to content

Commit 9e05f3a

Browse files
committed
Implement build timeouts
1 parent 33de69a commit 9e05f3a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

travis_config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function bdist_wheel_cmd {
1616
local abs_wheelhouse=$1
1717
if [ -n "$IS_OSX" ]; then
1818
source travis_osx_build.sh
19-
build_bdist_osx_wheel . $@
19+
build_bdist_osx_wheel . $@ || return $?
2020
else
2121
CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
2222
fi

travis_osx_build.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ function pre_build_osx {
1515
local build_dir="$repo_dir/opencv/build"
1616
local num_cpus=$(sysctl -n hw.ncpu)
1717
num_cpus=${num_cpus:-4}
18+
local travis_start_time=$(($TRAVIS_TIMER_START_TIME/10**9))
19+
local time_limit=$((30*60))
1820

1921
cd "$repo_dir"
2022
git submodule sync
@@ -44,7 +46,6 @@ function pre_build_osx {
4446
-DBUILD_TESTS=OFF
4547
-DBUILD_PERF_TESTS=OFF
4648
-DBUILD_DOCS=OFF
47-
-DBUILD_LIST=core,imgproc,videoio,python3 # FIXME: experiments
4849
)
4950
if [ $ENABLE_CONTRIB -ne 0 ]; then
5051
CMAKE_OPTS+=(-DOPENCV_EXTRA_MODULES_PATH="$repo_dir/opencv_contrib/modules")
@@ -128,13 +129,18 @@ function pre_build_osx {
128129
)
129130
for m in "${CV_MODULES[@]}"; do
130131
if make help | grep -w "$m"; then
132+
# Check time limit (3min should be enough for a module to built)
133+
local projected_time=$(($(date +%s) - travis_start_time + 3 * 60))
134+
if [ $projected_time -ge $time_limit ]; then
135+
echo "*** Not enough time to build $m: $((projected_time/60))m (${projected_time}s)"
136+
return 1
137+
fi
131138
make -j${num_cpus} "$m"
139+
local elapsed_time=$(($(date +%s) - travis_start_time))
140+
echo "Elapsed time: "$((elapsed_time/60))"m (${elapsed_time}s)"
132141
fi
133142
done
134143
make -j${num_cpus}
135-
136-
# Print ccache stats
137-
ccache -s
138144
}
139145

140146
function build_osx {
@@ -170,7 +176,7 @@ function build_osx {
170176
function build_bdist_osx_wheel {
171177
local repo_dir=$(abspath ${1:-$REPO_DIR})
172178
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
173-
pre_build_osx "$repo_dir"
179+
pre_build_osx "$repo_dir" || return $?
174180
if [ -n "$BUILD_DEPENDS" ]; then
175181
pip install $(pip_opts) $BUILD_DEPENDS
176182
fi

0 commit comments

Comments
 (0)