-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild
executable file
·133 lines (113 loc) · 2.97 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
set -o errexit # set -e
set -o nounset # set -u
eval CONFIG_DIR="~/config"
# Prevent two classes of warnings, but fail on anything else
EXTRA_CFLAGS="-Wno-unused-result -Wformat-truncation=0"
FOLD=""
function get_config_location()
{
local TEST="/$1"
while [ -n "$TEST" ]; do
if [ -f "$CONFIG_DIR${TEST}.txt" ]; then
echo "$CONFIG_DIR${TEST}.txt"
return
fi
TEST="${TEST%/*}"
done
echo "$CONFIG_DIR/default.txt"
}
function start_fold()
{
echo -en "travis_fold:start:$2\\r"
# travis_fold start "$2"
# travis_time_start
echo "$1"
FOLD="$2"
}
function end_fold()
{
echo -en "travis_fold:end:$FOLD\\r"
# travis_time_finish
# travis_fold end "$FOLD"
FOLD=""
}
function run_build()
{
if [[ $# -ne 4 ]]; then
echo "Illegal arguments passed."
return
fi
BRANCH="$1"
LEN="$2"
FILE="$3"
CONFIG_DIR="$4"
echo "-------------------------------------------------------------------------------"
echo "BRANCH: https://github.com/neomutt/neomutt/tree/$BRANCH"
echo "COMMIT: https://github.com/neomutt/neomutt/commit/$(git rev-parse HEAD)"
echo "CONFIG FILE: https://github.com/neomutt/travis-build/blob/master/${FILE#$CONFIG_DIR/}"
echo "CONFIGURATIONS: $LEN"
echo "-------------------------------------------------------------------------------"
BUILD_COUNT=0
if grep -q "testing=0" auto.def; then
TESTING="--testing"
else
TESTING=""
fi
while read CONFIG; do
: $((BUILD_COUNT++))
echo "BUILD: $BUILD_COUNT/$LEN"
if [ -n "$CONFIG" ]; then
echo "$CONFIG" | fmt -w 75 | sed 's/^/ /'
else
echo " <no options>"
fi
echo
start_fold "Configure" "configure.$BUILD_COUNT"
git clean -xdfq
if ! ./configure --disable-doc $TESTING $CONFIG; then
if [ -f config.log ]; then
echo "-------------------------------------------------------------------------------"
start_fold "Config Log" config.log.$BUILD_COUNT
cat config.log
end_fold
exit 1
fi
fi
end_fold
start_fold "Build" "make.$BUILD_COUNT"
make -j2 EXTRA_CFLAGS="$EXTRA_CFLAGS" || exit 1
echo
end_fold
start_fold "Test" "test.$BUILD_COUNT"
[ -d test ] && make -s test
end_fold
start_fold "Version" "version.$BUILD_COUNT"
./neomutt -v
end_fold
echo
echo "-------------------------------------------------------------------------------"
done < "$FILE"
}
GIT_DIR="${0%/*}/.git"
if [ -d "$GIT_DIR" ]; then
VERSION=$(git --git-dir="$GIT_DIR" rev-parse --short HEAD)
echo "Travis build script: https://github.com/neomutt/travis-build/blob/$VERSION/build"
fi
if [ -n "${TRAVIS_BRANCH:-}" ]; then
BRANCH="$TRAVIS_BRANCH"
else
BRANCH=$(git rev-parse --abbrev-ref HEAD)
fi
if [[ "${TRAVIS_PULL_REQUEST:-}" =~ ^[0-9]+$ ]]; then
FILE="$CONFIG_DIR/pull-request.txt"
else
FILE=$(get_config_location "$BRANCH")
fi
LEN=$(wc -l "$FILE" | cut -d' ' -f1)
run_build "$BRANCH" "$LEN" "$FILE" "$CONFIG_DIR"
# if [[ $BRANCH = "master" && ! "${TRAVIS_PULL_REQUEST:-}" =~ ^[0-9]+$ ]]; then
# # Do a full build and test it
# fi
echo Success
exit 0