Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / native_client / buildbot / buildbot_linux-glibc-makefile.sh
1 #!/bin/bash
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # Script assumed to be run in native_client/
7 if [[ ${PWD} != */native_client ]]; then
8   echo "ERROR: must be run in native_client!"
9   exit 1
10 fi
11
12 set -x
13 set -e
14 set -u
15
16 # Transitionally, even though our new toolchain location is under
17 # toolchain/linux_x86_nacl_x86/nacl_x86_glibc we have to keep the old format
18 # inside of the tar (toolchain/linux_x86) so that the untar toolchain script
19 # is backwards compatible and can untar old tars. Eventually this will be
20 # unnecessary with the new package_version scheme since how to untar the
21 # tar file will be embedded inside of the package file so they can differ
22 # between revisions.
23 export TOOLCHAINLOC=toolchain
24 export TOOLCHAINNAME=linux_x86
25
26 # This is where we want the toolchain when moving to native_client/toolchain.
27 OUT_TOOLCHAINLOC=toolchain/linux_x86
28 OUT_TOOLCHAINNAME=nacl_x86_glibc
29
30 TOOL_TOOLCHAIN="${TOOLCHAINLOC}/${TOOLCHAINNAME}"
31 OUT_TOOLCHAIN="${OUT_TOOLCHAINLOC}/${OUT_TOOLCHAINNAME}"
32
33 echo @@@BUILD_STEP gclient_runhooks@@@
34 gclient runhooks --force
35
36 echo @@@BUILD_STEP clobber_toolchain@@@
37 rm -rf scons-out tools/SRC/*.patch* tools/BUILD/* tools/out tools/toolchain \
38   tools/glibc tools/glibc.tar tools/toolchain.t* "${OUT_TOOLCHAIN}" .tmp ||
39   echo already_clean
40
41 echo @@@BUILD_STEP clean_sources@@@
42 tools/update_all_repos_to_latest.sh
43
44 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" == "Trybot" ]]; then
45 echo @@@BUILD_STEP setup source@@@
46 (cd tools; ./buildbot_patch-toolchain-tries.sh)
47 fi
48
49 echo @@@BUILD_STEP compile_toolchain@@@
50 (
51   cd tools
52   make -j8 buildbot-build-with-glibc
53   if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
54     make install-glibc INST_GLIBC_PREFIX="$PWD"
55   fi
56   mkdir -p SRC/newlib/newlib/libc/sys/nacl/include
57   cp -aiv ../src/untrusted/pthread/{pthread.h,semaphore.h} \
58     SRC/newlib/newlib/libc/sys/nacl/include
59   find SRC/newlib/newlib/libc/sys/nacl -name .svn -print0 | xargs -0 rm -rf --
60   ( cd SRC/newlib/newlib/libc/sys ; git add nacl )
61   for file in SRC/gcc/gcc/configure.ac SRC/gcc/gcc/configure ; do
62     cp -aiv $file $file.orig
63     sed -e s"|\(CROSS_SYSTEM_HEADER_DIR='\)\(\\\$(gcc_tooldir)/sys-include'\)|\1\$(DESTDIR)\2|" \
64       < $file.orig > $file
65     touch -r $file.orig $file
66     rm $file.orig
67     ( cd SRC/gcc/gcc ; git add $(basename $file) )
68   done
69   make patches
70   for patchname in SRC/*.patch ; do
71     xz -k -9 "$patchname"
72     bzip2 -k -9 "$patchname"
73     gzip -9 "$patchname"
74     zcat "$patchname".gz > "$patchname"
75   done
76   mkdir linux
77   cp -aiv {SRC/linux-headers-for-nacl/include/,}linux/getcpu.h
78   cp -aiv {../src/untrusted/include/machine/,}_default_types.h
79   cp -aiv ../LICENSE LICENSE
80   mv Makefile Makefile.orig
81   . REVISIONS
82   sed -e s"|^\\(CANNED_REVISION = \\)no$|\\1$BUILDBOT_GOT_REVISION|" \
83       -e s'|^\(SRCDIR =\).*$|\1|' \
84       -e s'|\(GCC_CC = \)gcc -m$(HOST_TOOLCHAIN_BITS)|\1gcc|' \
85       -e s'|\(GLIBC_CC =.*\)|\1 -I$(abspath $(dir $(THISMAKEFILE)))|' \
86       -e s'|\(LINUX_HEADERS = \).*|\1/usr/include|' \
87       -e s"|\\(export NACL_FAKE_SONAME\\).*|\\1 = ${NACL_GLIBC_COMMIT:0:8}|" \
88          < Makefile.orig > Makefile
89   tar czSvpf nacltoolchain-buildscripts-r${BUILDBOT_GOT_REVISION}.tar.gz \
90     LICENSE Makefile download_SRC.sh \
91     _default_types.h linux newlib-libc-script \
92     create_redirector{,s,s_cygwin}.sh redirector.exe redirect_table.txt \
93     redirector/redirector{.c,.h} redirector/redirector_table.txt
94   rm Makefile
95   mv Makefile.orig Makefile
96   rm linux/getcpu.h _default_types.h LICENSE
97   rmdir linux
98 )
99
100 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
101   echo @@@BUILD_STEP tar_glibc@@@
102   (
103     cd tools
104     cp --archive --sparse=always glibc glibc_sparse
105     rm -rf glibc
106     mv glibc_sparse glibc
107     cd glibc
108     tar zScf ../glibc.tgz ./*
109     chmod a+r ../glibc.tgz
110   )
111
112   echo @@@BUILD_STEP archive_glibc@@@
113   rev="$(tools/glibc_revision.sh)"
114   wget https://gsdview.appspot.com/nativeclient-archive2/between_builders/x86_glibc/r"$rev"/glibc_x86.tar.gz -O /dev/null ||
115   $GSUTIL cp -a public-read \
116     tools/glibc.tgz \
117     gs://nativeclient-archive2/between_builders/x86_glibc/r"$rev"/glibc_x86.tar.gz
118   echo @@@STEP_LINK@download@http://gsdview.appspot.com/nativeclient-archive2/between_builders/x86_glibc/r"$rev"/@@@
119 fi
120
121 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
122   GSD_BUCKET=nativeclient-archive2
123   UPLOAD_REV=${BUILDBOT_GOT_REVISION}
124   UPLOAD_LOC=x86_toolchain/r${UPLOAD_REV}
125 else
126   GSD_BUCKET=nativeclient-trybot/packages
127   UPLOAD_REV=${BUILDBOT_BUILDERNAME}/${BUILDBOT_BUILDNUMBER}
128   UPLOAD_LOC=x86_toolchain/${UPLOAD_REV}
129 fi
130
131 (
132   cd tools
133   echo @@@BUILD_STEP sparsify_toolchain@@@
134   cp --archive --sparse=always "${TOOL_TOOLCHAIN}" "${TOOL_TOOLCHAIN}_sparse"
135   rm -rf "${TOOL_TOOLCHAIN}"
136   mv "${TOOL_TOOLCHAIN}_sparse" "${TOOL_TOOLCHAIN}"
137   echo @@@BUILD_STEP canonicalize timestamps@@@
138   ./canonicalize_timestamps.sh "${TOOL_TOOLCHAIN}"
139   echo @@@BUILD_STEP tar_toolchain@@@
140   tar Scf toolchain.tar "${TOOL_TOOLCHAIN}"
141   xz -k -9 toolchain.tar
142   bzip2 -k -9 toolchain.tar
143   gzip -n -9 toolchain.tar
144   for i in gz bz2 xz ; do
145     chmod a+r toolchain.tar.$i
146     echo "$(SHA1=$(sha1sum -b toolchain.tar.$i) ; echo ${SHA1:0:40})" \
147       > toolchain.tar.$i.sha1hash
148   done
149 )
150
151 echo @@@BUILD_STEP archive_build@@@
152 for suffix in gz gz.sha1hash bz2 bz2.sha1hash xz xz.sha1hash ; do
153   $GSUTIL cp -a public-read \
154     tools/toolchain.tar.$suffix \
155     gs://${GSD_BUCKET}/${UPLOAD_LOC}/toolchain_linux_x86.tar.$suffix
156 done
157 for patch in \
158     tools/nacltoolchain-buildscripts-r${BUILDBOT_GOT_REVISION}.tar.gz \
159     tools/SRC/*.patch* ; do
160   filename="${patch#tools/}"
161   filename="${filename#SRC/}"
162   $GSUTIL cp -a public-read \
163     $patch \
164     gs://${GSD_BUCKET}/${UPLOAD_LOC}/$filename
165 done
166 echo @@@STEP_LINK@download@http://gsdview.appspot.com/${GSD_BUCKET}/${UPLOAD_LOC}/@@@
167
168 echo @@@BUILD_STEP archive_extract_package@@@
169 python build/package_version/package_version.py \
170   archive --archive-package=nacl_x86_glibc --extract \
171   --extra-archive gdb_i686_linux.tgz \
172   tools/toolchain.tar.bz2,toolchain/linux_x86@https://storage.googleapis.com/${GSD_BUCKET}/${UPLOAD_LOC}/toolchain_linux_x86.tar.bz2 \
173
174 echo @@@BUILD_STEP upload_package_info@@@
175 python build/package_version/package_version.py \
176   --cloud-bucket=${GSD_BUCKET} --annotate \
177   upload --skip-missing \
178   --upload-package=nacl_x86_glibc --revision=${UPLOAD_REV}
179
180 echo @@@BUILD_STEP glibc_tests64@@@
181 (
182   cd tools
183   make glibc-check
184 )
185
186 # The script should exit nonzero if any test run fails.
187 # But that should not short-circuit the script due to the 'set -e' behavior.
188 exit_status=0
189 fail() {
190   exit_status=1
191   return 0
192 }
193
194 # Before we start testing, put in dummy mock archives so gyp can still untar
195 # the entire package.
196 python build/package_version/package_version.py fillemptytars \
197   --fill-package nacl_x86_glibc
198
199 # First run 32bit tests, then 64bit tests.  Both should succeed.
200 export INSIDE_TOOLCHAIN=1
201 python buildbot/buildbot_standard.py --scons-args='no_gdb_tests=1' \
202   --step-suffix=' (32)' opt 32 glibc || fail
203
204 python buildbot/buildbot_standard.py --scons-args='no_gdb_tests=1' \
205   --step-suffix=' (64)' opt 64 glibc || fail
206
207 # sync_backports is obsolete and should probably be removed.
208 # if [[ "${BUILD_COMPATIBLE_TOOLCHAINS:-yes}" != "no" ]]; then
209 #   echo @@@BUILD_STEP sync backports@@@
210 #   rm -rf tools/BACKPORTS/ppapi*
211 #   tools/BACKPORTS/build_backports.sh VERSIONS linux glibc
212 # fi
213
214 exit $exit_status