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
|
#!/bin/bash
set -e
export LANG=C
export PATH=$PWD/tests:$PATH
# If PAGER is set, repo manifest will display its message using the pager,
# pausing the script until the pager is closed
unset PAGER
cpu_count=$(getconf _NPROCESSORS_ONLN)
jcpu_count=$(($cpu_count * 2))
build_config_dir=android-build-configs
if [[ ${JENKINS_HOME+y} ]]; then
# This script has been invoked by Jenkins, this is an automated run
JENKINS_MODE=y
echo -e "\e[32mJenkins run\e[0m"
git config --global user.email "android-build-bot@fake-email.invalid"
git config --global user.name "android-build-bot"
mkdir -p $HOME/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > $HOME/bin/repo
wget https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O $HOME/bin/linaro-cp.py
chmod a+x $HOME/bin/*
export PATH=$HOME/bin:$PATH
base_dir=$HOME/srv/$JOB_NAME
else
# Local run
unset JENKINS_MODE
echo -e "\e[32mLocal run\e[0m"
: ${base_dir:=$PWD/test_base_dir}
# We need to define variables that are normally defined by Jenkins
: ${WORKSPACE:=$PWD/workspace}
mkdir -p "$WORKSPACE"
: ${BUILD_CONFIG_REPO:=git://android.git.linaro.org/android-build-configs.git}
: ${BUILD_CONFIG_BRANCH:=master}
# Choose a default config filename depending on the script that sourced this file
case $(basename ${BASH_SOURCE[1]}) in
test-art-target-test.sh)
: ${BUILD_CONFIG_FILENAME:=linaro-art-tip-aosp_flounder} ;;
test-art-host-test.sh)
: ${BUILD_CONFIG_FILENAME:=linaro-art-tip-aosp_arm64} ;;
esac
fi
# Move to persistent drive
if [[ ! -d $base_dir ]]; then
mkdir -p "$base_dir"
[[ $JENKINS_MODE ]] && chmod 755 "$base_dir"
fi
cd "$base_dir"
if [[ ! ($BUILD_CONFIG_REPO && $BUILD_CONFIG_BRANCH && $BUILD_CONFIG_FILENAME) ]]; then
echo "ERROR: Please provide the config repository, branch and filename"
exit 1
else
if [[ -d $build_config_dir/.git && ! $JENKINS_MODE ]]; then
# Only update the repo to preserve local modifications
cd $build_config_dir
git pull
cd -
else
rm -rf $build_config_dir
git clone $BUILD_CONFIG_REPO -b $BUILD_CONFIG_BRANCH
fi
fi
# Should contain at least: {LOCAL_,}MANIFEST_{URL,BRANCH}
# Optionally: REPO_SEED_DIR, PATCHSETS, PINNED_MANIFEST
# And other configuration variables used in the scripts
. $build_config_dir/$BUILD_CONFIG_FILENAME
: ${MANIFEST_URL:=https://android.googlesource.com/platform/manifest}
: ${MANIFEST_BRANCH:=master}
if [[ ! $LOCAL_MANIFEST_URL ]]; then
echo "WARNING: local manifest not specified"
echo "build is using main manifest only"
else
if [[ ! $LOCAL_MANIFEST_BRANCH ]]; then
echo "WARNING: local manifest branch not specified, using master branch"
LOCAL_MANIFEST_BRANCH=master
fi
fi
: ${BOOT_TO_GUI_TEST:=0}
mkdir -p android
cd android/
: ${MAKE_TARGETS:=droidcore}
echo "SYNCING CODE"
REPO_GROUPS=${REPO_GROUPS-"all,-notdefault,-eclipse"}
REPO_START=$(date +%s.%N)
repo init -u $MANIFEST_URL -g $REPO_GROUPS -b $MANIFEST_BRANCH \
${REPO_SEED_DIR:+--reference="$REPO_SEED_DIR"}
cd .repo
rm -rf local_manifests
# If a pinned manifest is used, the local manifest must not be used as it would
# be conflicting (the pinned manifest already incorporates Linaro repos)
if [[ $LOCAL_MANIFEST_URL && ! $PINNED_MANIFEST ]]; then
export LOCAL_MANIFEST_BRANCH=$LOCAL_MANIFEST_BRANCH
git clone $LOCAL_MANIFEST_URL -b $LOCAL_MANIFEST_BRANCH local_manifests
fi
cd -
rm -rf art/ build/ external/vixl
set +e
# Download the code
sync_args=(--force-sync ${PINNED_MANIFEST:+-m "$PINNED_MANIFEST"})
repo sync "${sync_args[@]}" -j$cpu_count > "$WORKSPACE/sync-logs.txt" 2>&1
repo_sync_status=$?
if [[ $repo_sync_status -ne 0 ]]; then
for (( repo_sync_tries = 1; repo_sync_tries <= 3 && repo_sync_status != 0; \
++repo_sync_tries )); do
corrupt_repo=`grep -rni rev-list $WORKSPACE/sync-logs.txt | sed -e "s/.*error.GitError: //g" | sed -e "s/rev-list.*//g" | sed -e "s/platform\///g"`
rm -rf $corrupt_repo
echo "Retry #$repo_sync_tries" >> "$WORKSPACE/sync-logs.txt"
repo sync "${sync_args[@]}" -j$cpu_count >> "$WORKSPACE/sync-logs.txt" 2>&1
repo_sync_status=$?
done
if [[ $repo_sync_status -ne 0 ]]; then
echo "Starting over with repo sync" >> "$WORKSPACE/sync-logs.txt"
repo sync "${sync_args[@]}" -j2 >> "$WORKSPACE/sync-logs.txt" 2>&1
repo_sync_status=$?
if [[ $repo_sync_status -ne 0 ]]; then
echo "Error: *** Error repo sync failed"
cat "$WORKSPACE/sync-logs.txt"
exit 1
fi
fi
fi
# Clear old lava-job-info files
rm -rf out/lava-job-info*
if [[ $SOURCE_OVERLAY ]]; then
curl --fail --silent --show-error \
-b license_accepted_$SOURCE_OVERLAY_ACCEPT_LICENSE=yes \
http://snapshots.linaro.org/android/binaries/$SOURCE_OVERLAY > $(basename $SOURCE_OVERLAY)
tar -x -a -f $(basename $SOURCE_OVERLAY) -C .
fi
repo manifest -r -o "$WORKSPACE/pinned-manifest.xml"
# Configure ccache
export USE_CCACHE=1
export CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
# In local mode, if a configuration already exists, do not override the ccache
# path or its configuration
if [[ $JENKINS_MODE || ! $CCACHE_DIR || ! -f $CCACHE_DIR/ccache.conf ]]; then
export CCACHE_DIR=$base_dir/.ccache
ccache -M 50G
fi
if [[ $PATCHSETS ]]; then
for i in $PATCHSETS; do
sh ./android-patchsets/$i
done
fi
if [[ $GERRIT_PROJECT && $GERRIT_EVENT_TYPE == "patchset-created" ]]; then
cd $(grep -rni "$GERRIT_PROJECT"\" .repo/local_manifests | grep -Po 'path="\K[^"]*')
if git pull ssh://git@$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC | grep -q "Automatic merge failed"; then
git reset --hard
echo "Error: *** Error patch merge failed"
exit 1
fi
cd -
else
echo "Build Triggered by timer or after merging the patch"
fi
REPO_END=$(date +%s.%N)
REPO_TIME=$(echo "$REPO_END - $REPO_START" | bc)
MAKE_JOBS=$cpu_count
echo "BUILDING CODE"
#Clean previous build artifacts
[[ $JENKINS_MODE || ! $NO_CLEAN ]] && rm -rf out/host
if [[ $NO_TMPFS_TARGET_PRODUCT ]]; then
[[ $JENKINS_MODE || ! $NO_CLEAN ]] && rm -rf out/target
else
# setup tmpfs since we have enough free memory
# The default is half of the memory (size=50%)
mkdir -p out/target/product
sudo mount -t tmpfs tmpfs out/target/product
fi
|