For CI - wake up the main thread as soon as worker thread completes.
This commit is contained in:
parent
076eaca13e
commit
faf50b0d99
30
.travis.yml
30
.travis.yml
@ -361,18 +361,32 @@ before_script:
|
||||
- export TRAVIS_COMMIT=$TRAVIS_COMMIT~
|
||||
- export COMMIT_MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT)
|
||||
- export TAG=$(git describe --exact-match $TRAVIS_COMMIT 2>/dev/null); if [[ $TAG =~ [[:digit:]]+\.[[:digit:]]+ ]]; then export RELEASE_TAG=$TAG; fi
|
||||
- if [ $XCODE ] && ([ $RELEASE_TAG ] || (! [[ $TRAVIS_BRANCH =~ [^-]+-[^-]+-CI ]] && echo $COMMIT_MESSAGE |grep -cq '\[ci package\]')); then export PACKAGE_UPLOAD=1; fi
|
||||
- if [ $XCODE ] && ([ $RELEASE_TAG ] || (! [[ $TRAVIS_BRANCH =~ [^-]+-[^-]+-CI ]] && echo $COMMIT_MESSAGE |grep -cq '\[ci package\]')); then export PACKAGE_UPLOAD=1; doxygen='doxygen graphviz'; fi
|
||||
- if [ $XCODE ] && echo $COMMIT_MESSAGE |egrep -cq '\[(ccache clear|xcode 64bit only)\]'; then export XCODE_64BIT_ONLY=1; fi
|
||||
- travis_retry brew update >/dev/null
|
||||
- which cmake >/dev/null 2>&1 || cmake=cmake
|
||||
- if [ $PACKAGE_UPLOAD ]; then doxygen='doxygen graphviz'; fi
|
||||
- travis_retry brew update >/dev/null
|
||||
- travis_retry brew install ccache $cmake $doxygen
|
||||
- whitelist='brew-cask ccache cmake doxygen graphviz libpng libyaml openssl pkg-config readline'
|
||||
- for f in $(brew list); do [[ $whitelist =~ $f ]] || travis_retry brew uninstall --force $f; done
|
||||
- for f in $(brew cask list); do [[ $whitelist =~ $f ]] || travis_retry brew cask uninstall --force $f; done
|
||||
- travis_retry brew cleanup
|
||||
- if [ $PACKAGE_UPLOAD ]; then
|
||||
whitelist='brew-cask ccache cmake doxygen graphviz libpng libyaml openssl pkg-config readline' &&
|
||||
for f in $(brew list); do [[ $whitelist =~ $f ]] || travis_retry brew uninstall --force $f; done &&
|
||||
for f in $(brew cask list); do [[ $whitelist =~ $f ]] || travis_retry brew cask uninstall --force $f; done &&
|
||||
travis_retry brew cleanup;
|
||||
fi
|
||||
- export PATH=$(brew info ccache |grep -o '\S*lib\S*'):$PATH
|
||||
- if [ $XCODE ]; then sudo cp -p $(which ccache) $(dirname $(xcodebuild -find-executable clang)) && for compiler in clang clang++; do path=$(xcodebuild -find-executable $compiler); sudo mv $path{,.orig} && sudo ln -sf $(dirname $path)/clang.orig /usr/bin/$compiler && sudo ln -sf ccache $path; done && if [ $IOS ]; then redundant=AppleTV,Watch; elif [ $TVOS ]; then redundant=iPhone,Watch; else redundant=iPhone,AppleTV,Watch; fi && eval sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/{$redundant}{OS,Simulator}.platform; fi
|
||||
- if [ $XCODE ]; then
|
||||
sudo cp -p $(which ccache) $(dirname $(xcodebuild -find-executable clang)) &&
|
||||
for compiler in clang clang++; do
|
||||
path=$(xcodebuild -find-executable $compiler); sudo mv $path{,.orig} &&
|
||||
sudo ln -sf $(dirname $path)/clang.orig /usr/bin/$compiler &&
|
||||
sudo ln -sf ccache $path;
|
||||
done &&
|
||||
if [ $PACKAGE_UPLOAD ]; then
|
||||
if [ $IOS ]; then redundant=AppleTV,Watch;
|
||||
elif [ $TVOS ]; then redundant=iPhone,Watch;
|
||||
else redundant=iPhone,AppleTV,Watch; fi &&
|
||||
eval sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/{$redundant}{OS,Simulator}.platform;
|
||||
fi;
|
||||
fi
|
||||
- rake ci_setup_cache
|
||||
script: rake ci && if [ $PACKAGE_UPLOAD ]; then rake ci_package_upload; fi && rake ci_timer
|
||||
after_script: rake ci_teardown_cache
|
||||
|
6
Rakefile
6
Rakefile
@ -822,7 +822,7 @@ end
|
||||
|
||||
# Usage: wait_for_block('This is a long function call...') { call_a_func } or abort
|
||||
# wait_for_block('This is a long system call...') { system 'do_something' } or abort
|
||||
def wait_for_block comment = '', retries = -1, retry_interval = 60, &block
|
||||
def wait_for_block comment = '', retries = -1, retry_interval = 60
|
||||
# When not using Xcode, execute the code block in full speed
|
||||
unless ENV['XCODE']
|
||||
puts comment; $stdout.flush
|
||||
@ -830,7 +830,7 @@ def wait_for_block comment = '', retries = -1, retry_interval = 60, &block
|
||||
end
|
||||
|
||||
# Wait until the code block is completed or it is killed externally by user via Ctrl+C or when it exceeds the number of retries (if the retries parameter is provided)
|
||||
thread = Thread.new &block
|
||||
thread = Thread.new { rc = yield; Thread.main.wakeup; rc }
|
||||
thread.priority = 1 # Make the worker thread has higher priority than the main thread
|
||||
str = comment
|
||||
retries = retries * 60 / retry_interval unless retries == -1
|
||||
@ -840,8 +840,8 @@ def wait_for_block comment = '', retries = -1, retry_interval = 60, &block
|
||||
break
|
||||
end
|
||||
print str; str = '.'; $stdout.flush # Flush the standard output stream in case it is buffered to prevent Travis-CI into thinking that the build/test has stalled
|
||||
sleep retry_interval
|
||||
retries -= 1 if retries > 0
|
||||
sleep retry_interval
|
||||
end
|
||||
puts "\n" if str == '.'; $stdout.flush
|
||||
thread.join
|
||||
|
Loading…
Reference in New Issue
Block a user