2016-02-18 15:40:13 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
# enabled VALUE
|
|
|
|
# - if VALUE is empty or falsy, returns 1 (false)
|
|
|
|
# - otherwise returns 0 (true)
|
|
|
|
# enabled VALUE COMMAND ...
|
|
|
|
# - if VALUE is empty or falsy, returns 0 (true)
|
|
|
|
# - otherwise runs COMMAND and returns its result
|
|
|
|
enabled () {
|
|
|
|
local value="$1"; shift
|
|
|
|
case $value in
|
|
|
|
''|'0'|[Ff]alse|[Nn]o) test $# -ne 0;;
|
|
|
|
*) test $# -eq 0 || "$@";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
# on NAME
|
|
|
|
# - if NAME == $TRAVIS_OS_NAME, returns 0 (true)
|
|
|
|
# - otherwise returns 1 (false)
|
|
|
|
# on NAME COMMAND ...
|
|
|
|
# - if NAME == $TRAVIS_OS_NAME, runs COMMAND and returns its result
|
|
|
|
# - otherwise returns 0 (true)
|
|
|
|
on () {
|
|
|
|
local name="$1"; shift
|
|
|
|
case $name in
|
|
|
|
$TRAVIS_OS_NAME) test $# -eq 0 || "$@";;
|
|
|
|
*) test $# -ne 0;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
git_submodule_update () {
|
|
|
|
git submodule update "$@" && return
|
2016-10-05 20:03:45 +02:00
|
|
|
# failed, search branch and pull request heads for matching commit
|
2016-02-18 15:40:13 +01:00
|
|
|
git submodule foreach \
|
|
|
|
'
|
|
|
|
test "$sha1" = "`git rev-parse HEAD`" ||
|
2016-10-05 20:03:45 +02:00
|
|
|
git ls-remote origin "refs/heads/*" "refs/pull/*/head" |
|
2016-02-18 15:40:13 +01:00
|
|
|
while read hash ref; do
|
|
|
|
if test "$hash" = "$sha1"; then
|
2016-10-05 20:03:45 +02:00
|
|
|
git config --add remote.origin.fetch "+$ref:$ref"
|
|
|
|
break
|
2016-02-18 15:40:13 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
'
|
|
|
|
# try again with added fetch refs
|
|
|
|
git submodule update "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# install and call pip
|
|
|
|
pip () {
|
|
|
|
if ! which pip >/dev/null; then
|
|
|
|
easy_install --user pip && \
|
|
|
|
export PATH="$HOME/Library/Python/2.7/bin:$PATH"
|
|
|
|
fi
|
|
|
|
command pip "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# commit_message_contains TEXT
|
|
|
|
# - returns 0 (true) if TEXT is found in commit message
|
|
|
|
# - case-insensitive, plain-text search, not regex
|
|
|
|
commit_message_contains () {
|
|
|
|
git log -1 --pretty='%B' "$TRAVIS_COMMIT" | grep -qiFe "$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_message_parse () {
|
2016-05-09 23:04:55 +02:00
|
|
|
if commit_message_contains '[skip tests]'; then
|
2016-02-18 15:40:13 +01:00
|
|
|
config_override "CPP_TESTS = False"
|
|
|
|
fi
|
|
|
|
if commit_message_contains '[skip utils]'; then
|
|
|
|
config_override "MAPNIK_INDEX = False"
|
|
|
|
config_override "MAPNIK_RENDER = False"
|
|
|
|
config_override "PGSQL2SQLITE = False"
|
|
|
|
config_override "SHAPEINDEX = False"
|
|
|
|
config_override "SVG2PNG = False"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
config_override () {
|
|
|
|
echo "Appending to config.py:" "$@"
|
|
|
|
echo "$@" >> ./config.py
|
|
|
|
}
|
|
|
|
|
|
|
|
configure () {
|
|
|
|
if enabled ${COVERAGE}; then
|
2016-03-16 23:51:40 +01:00
|
|
|
./configure "$@" PREFIX=${PREFIX} PGSQL2SQLITE=False SVG2PNG=False SVG_RENDERER=False \
|
2016-11-29 22:50:08 +01:00
|
|
|
COVERAGE=True DEBUG=True
|
2016-02-18 15:40:13 +01:00
|
|
|
else
|
2016-11-29 22:50:08 +01:00
|
|
|
./configure "$@" PREFIX=${PREFIX}
|
2016-02-18 15:40:13 +01:00
|
|
|
fi
|
|
|
|
# print final config values, sorted and indented
|
|
|
|
sort -sk1,1 ./config.py | sed -e 's/^/ /'
|
|
|
|
}
|
|
|
|
|
|
|
|
coverage () {
|
|
|
|
./mason_packages/.link/bin/cpp-coveralls \
|
2016-06-15 06:25:33 +02:00
|
|
|
--gcov ${LLVM_COV} \
|
2016-03-03 23:19:12 +01:00
|
|
|
--exclude mason_packages \
|
2016-02-18 15:40:13 +01:00
|
|
|
--exclude .sconf_temp --exclude benchmark --exclude deps \
|
|
|
|
--exclude scons --exclude test --exclude demo --exclude docs \
|
2016-03-03 23:19:12 +01:00
|
|
|
--exclude fonts \
|
2016-02-18 15:40:13 +01:00
|
|
|
> /dev/null
|
|
|
|
}
|
2016-03-17 01:01:28 +01:00
|
|
|
|
|
|
|
trigger_downstream() {
|
2016-03-17 01:08:32 +01:00
|
|
|
body="{
|
|
|
|
\"request\": {
|
|
|
|
\"message\": \"Triggered build: Mapnik core commit ${TRAVIS_COMMIT}\",
|
|
|
|
\"branch\":\"master\"
|
2016-03-17 01:01:28 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-17 01:08:32 +01:00
|
|
|
"
|
2016-03-17 01:01:28 +01:00
|
|
|
|
|
|
|
curl -s -X POST \
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
-H "Accept: application/json" \
|
|
|
|
-H "Travis-API-Version: 3" \
|
|
|
|
-H "Authorization: token ${TRAVIS_TRIGGER_TOKEN}" \
|
|
|
|
-d "$body" \
|
|
|
|
https://api.travis-ci.org/repo/mapnik%2Fpython-mapnik/requests
|
|
|
|
}
|