blob: ae0d33f58293c2fdbafbac5eddd5c0c0aff2c363 (
plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
#!/bin/bash
MAKEFLAGS="$1"
BGPROCESSFILE="$2"
cpuCount=1
if [[ $NUMBER_OF_PROCESSORS > 1 ]]; then
if [[ $NUMBER_OF_PROCESSORS > 4 ]]; then
cpuCount=$NUMBER_OF_PROCESSORS
else
cpuCount=`expr $NUMBER_OF_PROCESSORS + $NUMBER_OF_PROCESSORS / 2`
fi
fi
if [[ ! $cpuCount =~ ^[0-9]+$ ]]; then
cpuCount="$(($(nproc)/2))"
fi
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test "$ncolors" -ge 8; then
bold_color=$(tput bold)
blue_color=$(tput setaf 4)
orange_color=$(tput setaf 3)
green_color=$(tput setaf 2)
red_color=$(tput setaf 1)
reset_color=$(tput sgr0)
fi
ncols=72
fi
if [[ ! -d /build/src ]]; then
mkdir /build/src
fi
do_wget() {
local URL="$1"
local archive="$2"
if [[ -z $archive ]]; then
wget --tries=5 --retry-connrefused --waitretry=2 --no-check-certificate -c -P /downloads/ $URL
else
wget --tries=5 --retry-connrefused --waitretry=2 --no-check-certificate -c $URL -O /downloads/$archive
fi
}
do_makeinstall() {
make -j"$cpuCount" "$@"
make install
}
do_makelib() {
do_print_status "$LIBNAME-$VERSION (${TRIPLET})" "$blue_color" "Compiling"
do_makeinstall $1
if [ $? == 0 ]; then
do_print_status "$LIBNAME-$VERSION (${TRIPLET})" "$green_color" "Done"
else
do_print_status "$LIBNAME-$VERSION (${TRIPLET})" "$red_color" "Error"
fi
}
do_print_status() {
local pad=$(printf '%0.1s' "."{1..72})
local padlen=$((${#pad}-${#1}-${#3}))
printf '%s %*.*s%s%s%s\n' "${bold_color}$1${reset_color}" 0 "$padlen" "$pad" " [$2" "$3" "$reset_color]"
}
do_print_progress() {
echo -e "\e]0;$* in $(get_first_subdir)\007"
echo -e "${bold_color}$* in $(get_first_subdir)${reset_color}"
}
get_first_subdir() {
local subdir="${PWD#*build/}"
if [[ "$subdir" != "$PWD" ]]; then
subdir="${subdir%%/*}"
echo "$subdir"
else
echo "."
fi
}
do_pkgConfig() {
local pkg=${1%% *}
local version=$2
[[ -z "$version" ]] && version="${1##*= }"
[[ "$version" = "$1" ]] && version="" || version=" $version"
local prefix=$(pkg-config --variable=prefix --silence-errors "$1")
[[ ! -z "$prefix" ]] && prefix="$(cygpath -u "$prefix")"
if [[ "$prefix" = "$LOCALDESTDIR" || "$prefix" = "/trunk${LOCALDESTDIR}" ]]; then
do_print_status "${pkg} ${version}" "$green_color" "Up-to-date"
return 1
else
do_print_status "${pkg} ${version}" "$red_color" "Not installed"
fi
}
do_autoreconf() {
if [[ ! -f $LOCALSRCDIR/configure ]]; then
local CURDIR=$(pwd)
cd $LOCALSRCDIR
autoreconf -fiv
cd $CURDIR
fi
}
do_clean() {
if [[ "$1" == "clean" ]]; then
if [ -d "$LIBBUILDDIR" ]; then
do_print_status "$LIBNAME ($TRIPLET)" "$red_color" "Removing"
rm -rf "$LIBBUILDDIR"
fi
fi
}
do_download() {
if [ ! -d "$LOCALSRCDIR" ]; then
if [ ! -f /downloads/$ARCHIVE ]; then
do_print_status "$LIBNAME-$VERSION" "$orange_color" "Downloading"
do_wget $BASE_URL/$VERSION.tar.gz $ARCHIVE
fi
do_print_status "$LIBNAME-$VERSION" "$blue_color" "Extracting"
mkdir $LOCALSRCDIR && cd $LOCALSRCDIR
tar -xaf /downloads/$ARCHIVE --strip 1
fi
# applying patches
local patches=(/xbmc/tools/buildsteps/windows/patches/*-$LIBNAME-*.patch)
for patch in ${patches[@]}; do
echo "Applying patch ${patch}"
if [[ -f $patch ]]; then
patch -p1 -d $LOCALSRCDIR -i $patch -N -r -
fi
done
}
do_loaddeps() {
local file="$1"
LIBNAME=$(grep "LIBNAME=" $file | sed 's/LIBNAME=//g;s/#.*$//g;/^$/d')
BASE_URL=$(grep "BASE_URL=" $file | sed 's/BASE_URL=//g;s/#.*$//g;/^$/d')
VERSION=$(grep "VERSION=" $file | sed 's/VERSION=//g;s/#.*$//g;/^$/d')
GITREV=$(git ls-remote $BASE_URL $VERSION | awk '{print substr($1, 1, 10)}')
if [[ -z "$GITREV" ]]; then
ARCHIVE=$LIBNAME-$(echo "${VERSION}" | sed 's/\//-/g').tar.gz
else
ARCHIVE=$LIBNAME-$GITREV.tar.gz
fi
BASE_URL=$BASE_URL/archive
local libsrcdir=$LIBNAME-$VERSION
if [[ ! -z "$GITREV" ]]; then
libsrcdir=$LIBNAME-$GITREV
fi
LOCALSRCDIR=$LOCALBUILDDIR/src/$libsrcdir
LIBBUILDDIR=$LOCALBUILDDIR/$LIBNAME-$TRIPLET
}
do_clean_get() {
do_clean $1
do_download
if [[ ! -d "$LIBBUILDDIR" ]]; then
mkdir "$LIBBUILDDIR"
fi
cd "$LIBBUILDDIR"
}
PATH_CHANGE_REV_FILENAME=".last_success_revision"
#hash a dir based on the git revision and $TRIPLET
#param1 path to be hashed
function getBuildHash ()
{
local checkPath
checkPath="$1"
shift 1
local hashStr
hashStr="$(git rev-list HEAD --max-count=1 -- $checkPath $@)"
hashStr="$hashStr $@ $TRIPLET"
echo $hashStr
}
#param1 path to be checked for changes
function pathChanged ()
{
local ret
local checkPath
ret="0"
#no optims in release builds!
if [ "$Configuration" == "Release" ]
then
echo "1"
return
fi
checkPath="$1"
shift 1
if [ -e $checkPath/$PATH_CHANGE_REV_FILENAME ]
then
if [ "$(cat $checkPath/$PATH_CHANGE_REV_FILENAME)" != "$(getBuildHash $checkPath $@)" ]
then
ret="1"
fi
else
ret="1"
fi
echo $ret
}
#param1 path to be tagged with hash
function tagSuccessFulBuild ()
{
local pathToTag
pathToTag="$1"
shift 1
# tag last successful build with revisions of the given dir
# needs to match the checks in function getBuildHash
echo "$(getBuildHash $pathToTag $@)" > $pathToTag/$PATH_CHANGE_REV_FILENAME
}
|