summaryrefslogtreecommitdiff
path: root/scripts/travis_helper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/travis_helper.sh')
-rwxr-xr-xscripts/travis_helper.sh28
1 files changed, 18 insertions, 10 deletions
diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh
index c42ce215e3..5e7dd46f4f 100755
--- a/scripts/travis_helper.sh
+++ b/scripts/travis_helper.sh
@@ -1,13 +1,21 @@
#!/usr/bin/env bash
+case `uname -s` in
+ 'Darwin') JOBS=$((`sysctl -n hw.ncpu` + 2)) ;;
+ 'Linux') JOBS=$((`nproc` + 2)) ;;
+ *) JOBS=2 ;;
+esac
+
+ANSI_CLEAR="\e[0m"
+
function mapbox_time_start {
local name=$1
mapbox_timer_name=$name
- travis_fold start $name
+ mapbox_fold start $name
mapbox_timer_id=$(printf %08x $(( RANDOM * RANDOM )))
- eval "mapbox_start_time_$mapbox_timer_id=$(travis_nanoseconds)"
+ eval "mapbox_start_time_$mapbox_timer_id=$(mapbox_nanoseconds)"
echo -en "travis_time:start:$mapbox_timer_id\n"
}
@@ -16,11 +24,11 @@ function mapbox_time_finish {
local timer_id=${2:-$mapbox_timer_id}
local timer_start="mapbox_start_time_$timer_id"
eval local start_time=\${$timer_start}
- local end_time=$(travis_nanoseconds)
+ local end_time=$(mapbox_nanoseconds)
local duration=$(($end_time-$start_time))
echo -en "travis_time:end:$timer_id:start=$start_time,finish=$end_time,duration=$duration\n"
- travis_fold end $name
+ mapbox_fold end $name
}
function mapbox_time {
@@ -32,13 +40,13 @@ function mapbox_time {
mapbox_time_finish $name $timer_id
}
-if [[ "${TRAVIS_COMMIT:-false}" == false ]]; then
-function travis_fold {
+function mapbox_fold {
local action=$1
local name=$2
echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}"
}
-function travis_nanoseconds {
+
+function mapbox_nanoseconds {
local cmd="date"
local format="+%s%N"
local os=$(uname)
@@ -51,11 +59,11 @@ function travis_nanoseconds {
$cmd -u $format
}
-fi
+export JOBS
export ANSI_CLEAR
-export -f travis_fold
-export -f travis_nanoseconds
+export -f mapbox_fold
+export -f mapbox_nanoseconds
export -f mapbox_time
export -f mapbox_time_start
export -f mapbox_time_finish