Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da7d022

Browse filesBrowse files
authored
Merge pull request opencv#197 from native-api/fix_detection
Minor fixes in build logic
2 parents 7f9aa26 + fac2703 commit da7d022
Copy full SHA for da7d022

File tree

4 files changed

+69
-46
lines changed
Filter options

4 files changed

+69
-46
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ env:
55
- TEST_DEPENDS="numpy==1.11.1"
66
# params to bdist_wheel. used to set osx build target.
77
- BDIST_PARAMS=""
8+
- CONFIG_PATH="travis_config.sh"
89
- USE_CCACHE=1
910
- PLAT=x86_64
1011
- UNICODE_WIDTH=32
@@ -663,7 +664,7 @@ before_install: |
663664
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
664665
source multibuild/travis_steps.sh
665666
# This sets -x
666-
source multibuild_customize.sh
667+
source travis_multibuild_customize.sh
667668
echo $ENABLE_CONTRIB > contrib.enabled
668669
echo $ENABLE_HEADLESS > headless.enabled
669670

‎config.sh renamed to ‎travis_config.sh

Copy file name to clipboardExpand all lines: travis_config.sh
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function bdist_wheel_cmd {
1616
local abs_wheelhouse=$1
1717
python setup.py bdist_wheel $BDIST_PARAMS
1818
cp dist/*.whl $abs_wheelhouse
19-
if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache --show-stats; fi
19+
if [ -n "$USE_CCACHE" -a -z "$BREW_BOOTSTRAP_MODE" ]; then ccache -s; fi
2020
}
2121

2222
if [ -n "$IS_OSX" ]; then
@@ -92,6 +92,7 @@ function pre_build {
9292
#after the cache stage, all bottles and Homebrew metadata should be already cached locally
9393
if [ -n "$CACHE_STAGE" ]; then
9494
brew update
95+
generate_ffmpeg_formula
9596
brew_add_local_bottles
9697
fi
9798

@@ -107,7 +108,6 @@ function pre_build {
107108
echo 'Installing FFmpeg'
108109

109110
if [ -n "$CACHE_STAGE" ]; then
110-
generate_ffmpeg_formula
111111
brew_install_and_cache_within_time_limit ffmpeg_opencv || { [ $? -gt 1 ] && return 2 || return 0; }
112112
else
113113
brew install ffmpeg_opencv
File renamed without changes.

‎travis_osx_brew_cache.sh

Copy file name to clipboardExpand all lines: travis_osx_brew_cache.sh
+65-43Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export HOMEBREW_NO_INSTALL_CLEANUP=1
2727
# see https://docs.brew.sh/Manpage , "info formula" section
2828
export HOMEBREW_NO_GITHUB_API=1
2929

30-
30+
#Packages already installed in the current session to avoid checking them again
31+
_BREW_ALREADY_INSTALLED='$' #$ = illegal package name; a blank line would cause macos grep to swallow everything
3132

3233

3334
#Public functions
@@ -37,39 +38,8 @@ function brew_install_and_cache_within_time_limit {
3738
# use bottle if available, build and cache bottle if not.
3839
# Terminate and exit with status 1 if this takes too long.
3940
# Exit with status 2 on any other error.
40-
( set -eE -o pipefail; trap '{ sleep 3; exit 2; }' ERR
41-
42-
local PACKAGE TIME_LIMIT TIME_HARD_LIMIT TIME_START
43-
PACKAGE="${1:?}" || exit 2
44-
TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || exit 2
45-
TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || exit 2
46-
TIME_START=${4:-$BREW_TIME_START} || exit 2
47-
48-
local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
49-
50-
if brew list --versions "$PACKAGE" >/dev/null && ! (brew outdated | grep -qxF "$PACKAGE"); then
51-
echo "Already installed and the latest version: $PACKAGE"
52-
return 0
53-
fi
54-
55-
56-
_brew_is_bottle_available "$PACKAGE" KEG_ONLY || BUILD_FROM_SOURCE=1
57-
[ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
58-
59-
# Whitespace is illegal in package names so converting all whitespace into single spaces due to no quotes is okay.
60-
DEPS=`brew deps "$PACKAGE" $INCLUDE_BUILD` || exit 2
61-
for dep in $DEPS; do
62-
#TIME_LIMIT only has to be met if we'll be actually building the main project this iteration, i.e. after the "root" module installation
63-
#While we don't know that yet, we can make better use of Travis-given time with a laxer limit
64-
#We still can't overrun TIME_HARD_LIMIT as that would't leave time to save the cache
65-
brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || exit $?
66-
done
67-
68-
_brew_check_slow_building_ahead "$PACKAGE" "$TIME_START" "$TIME_HARD_LIMIT" || exit $?
69-
_brew_install_and_cache "$PACKAGE" "$([[ -z "$BUILD_FROM_SOURCE" ]] && echo 1 || echo 0)" "$KEG_ONLY" || exit 2
70-
_brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || exit $?
71-
) \
72-
|| if test $? -eq 1; then brew_go_bootstrap_mode; return 1; else return 2; fi #must run this in current process
41+
_brew_install_and_cache_within_time_limit $@ \
42+
|| if test $? -eq 1; then brew_go_bootstrap_mode; return 1; else return 2; fi
7343
}
7444

7545
function brew_add_local_bottles {
@@ -106,8 +76,8 @@ function brew_add_local_bottles {
10676
local FORMULA_HAS_BOTTLE; [ -n "$FORMULA_BOTTLE_HASH" ] && FORMULA_HAS_BOTTLE=1 || true
10777

10878

109-
local BOTTLE_LINK BOTTLE; BOTTLE_LINK="${JSON}.bottle.lnk";
110-
local BOTTLE_EXISTS BOTTLE_MISMATCH VERSION_MISMATCH
79+
local BOTTLE_LINK BOTTLE=""; BOTTLE_LINK="${JSON}.bottle.lnk";
80+
local BOTTLE_EXISTS= BOTTLE_MISMATCH= VERSION_MISMATCH=
11181

11282

11383
# Check that the bottle file exists and is still appropriate for the formula
@@ -223,12 +193,19 @@ function brew_go_bootstrap_mode {
223193
#Can't just `exit` because that would terminate the build without saving the cache
224194
#Have to replace further actions with no-ops
225195

196+
local MESSAGE=""; if [ "$EXIT_CODE" -ne 0 ]; then
197+
MESSAGE='Building dependencies took too long. Restart the build in Travis UI to continue from cache.';
198+
fi
199+
226200
eval '
227201
function '"$cmd"' { return 0; }
228202
function repair_wheelhouse { return 0; }
229-
function install_run {
230-
echo -e "\nBuilding dependencies took too long. Restart the build in Travis UI to continue from cache.\n"
231-
203+
function install_run {'\
204+
"$(if [ -n "$MESSAGE" ]; then
205+
echo \
206+
' echo -e "\n'"$MESSAGE"'\n"'
207+
fi)"\
208+
'
232209
# Travis runs user scripts via `eval` i.e. in the same shell process.
233210
# So have to unset errexit in order to get to cache save stage
234211
set +e; return '"$EXIT_CODE"'
@@ -239,6 +216,46 @@ function brew_go_bootstrap_mode {
239216

240217
#Internal functions
241218

219+
function _brew_install_and_cache_within_time_limit {
220+
# This fn is run with || so errexit can't be enabled
221+
222+
local PACKAGE TIME_LIMIT TIME_HARD_LIMIT TIME_START MARKED_INSTALLED
223+
PACKAGE="${1:?}" || return 2
224+
TIME_LIMIT=${2:-$BREW_TIME_LIMIT} || return 2
225+
TIME_HARD_LIMIT=${3:-$BREW_TIME_HARD_LIMIT} || return 2
226+
TIME_START=${4:-$BREW_TIME_START} || return 2
227+
228+
if grep -qxFf <(cat <<<"$_BREW_ALREADY_INSTALLED") <<<"$PACKAGE"; then
229+
MARKED_INSTALLED=1
230+
fi
231+
232+
if [ -n "$MARKED_INSTALLED" ] || (brew list --versions "$PACKAGE" >/dev/null && ! (brew outdated | grep -qxF "$PACKAGE")); then
233+
echo "Already installed and the latest version: $PACKAGE"
234+
if [ -z "$MARKED_INSTALLED" ]; then _brew_mark_installed "$PACKAGE"; fi
235+
return 0
236+
fi
237+
238+
local BUILD_FROM_SOURCE INCLUDE_BUILD KEG_ONLY
239+
240+
_brew_is_bottle_available "$PACKAGE" KEG_ONLY || BUILD_FROM_SOURCE=1
241+
[ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
242+
243+
# Whitespace is illegal in package names so converting all whitespace into single spaces due to no quotes is okay.
244+
DEPS=`brew deps "$PACKAGE" $INCLUDE_BUILD` || return 2
245+
DEPS=`grep -vxF <(cat <<<"$_BREW_ALREADY_INSTALLED") <<<"$DEPS"` || test $? -eq 1 || return 2
246+
for dep in $DEPS; do
247+
#TIME_LIMIT only has to be met if we'll be actually building the main project this iteration, i.e. after the "root" module installation
248+
#While we don't know that yet, we can make better use of Travis-given time with a laxer limit
249+
#We still can't overrun TIME_HARD_LIMIT as that would't leave time to save the cache
250+
_brew_install_and_cache_within_time_limit "$dep" $(((TIME_LIMIT+TIME_HARD_LIMIT)/2)) "$TIME_HARD_LIMIT" "$TIME_START" || return $?
251+
done
252+
253+
_brew_check_slow_building_ahead "$PACKAGE" "$TIME_START" "$TIME_HARD_LIMIT" || return $?
254+
_brew_install_and_cache "$PACKAGE" "$([[ -z "$BUILD_FROM_SOURCE" ]] && echo 1 || echo 0)" "$KEG_ONLY" || return 2
255+
_brew_check_elapsed_build_time "$TIME_START" "$TIME_LIMIT" || return $?
256+
}
257+
258+
242259
function _brew_parse_bottle_json {
243260
# Parse JSON file resulting from `brew bottle --json`
244261
# and save data into specified variables
@@ -278,7 +295,7 @@ function _brew_parse_package_info {
278295
revision=data["revision"]
279296
# in bottle''s json, revision is included into version; here, they are separate
280297
print data["versions"]["stable"]+("_"+str(revision) if revision else "")
281-
bottle_data=data["bottle"]["stable"]
298+
bottle_data=data["bottle"].get("stable",{"rebuild":"","files":{}})
282299
print bottle_data["rebuild"]
283300
print bottle_data["files"].get(sys.argv[2],{"sha256":"!?"})["sha256"] #prevent losing trailing blank line to command substitution
284301
' \
@@ -300,7 +317,9 @@ function _brew_is_bottle_available {
300317
local PACKAGE;PACKAGE="${1:?}"
301318
local VAR_KEG_ONLY="$2"
302319

303-
local INFO;INFO="$(brew info "$PACKAGE" | head -n 1)"
320+
# `brew info` prints "Error: Broken pipe" if piped directly to `head` and the info is long
321+
# 141 = 128 + SIGPIPE
322+
local INFO;INFO="$((brew info "$PACKAGE" | cat || test $? -eq 141) | head -n 1)"
304323
if [ -n "$VAR_KEG_ONLY" ]; then
305324
if grep -qwF '[keg-only]' <<<"$INFO"; then
306325
eval "${VAR_KEG_ONLY}=1"
@@ -377,10 +396,13 @@ function _brew_install_and_cache {
377396
echo "$CACHED_BOTTLE" >"$BOTTLE_LINK"
378397
379398
fi
399+
400+
_brew_mark_installed "$PACKAGE"
380401
}
381402
382-
383-
403+
function _brew_mark_installed {
404+
_BREW_ALREADY_INSTALLED="$_BREW_ALREADY_INSTALLED"$'\n'"${1:?}"
405+
}
384406
385407
function _brew_check_elapsed_build_time {
386408
# If time limit has been reached,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.