tools/ew.py: Add support for gnome-terminal
[helenos.git] / tools / travis.sh
blob99c9d3abe154bb3549a074d967980bd26924da9a
1 #!/bin/sh
4 # Copyright (c) 2018 Vojtech Horky
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
11 # - Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # - Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # - The name of the author may not be used to endorse or promote products
17 # derived from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 # This is wrapper script for testing build of HelenOS under Travis CI [1].
34 # You probably do not want to run this script directly. If you wish to test
35 # that HelenOS builds for all architectures, consider using either check.sh
36 # script or running our CI solution [2] (if you want to test ported software
37 # too).
39 # [1] https://travis-ci.org/
40 # [2] http://www.helenos.org/wiki/CI
43 H_ARCH_CONFIG_CROSS_TARGET=2
44 H_ARCH_CONFIG_OUTPUT_FILENAME=3
46 h_get_arch_config_space() {
47 cat <<'EOF_CONFIG_SPACE'
48 amd64:amd64-helenos:image.iso
49 arm32/beagleboardxm:arm-helenos:uImage.bin
50 arm32/beaglebone:arm-helenos:uImage.bin
51 arm32/gta02:arm-helenos:uImage.bin
52 arm32/integratorcp:arm-helenos:image.boot
53 arm32/raspberrypi:arm-helenos:uImage.bin
54 arm64/virt:aarch64-helenos:image.iso
55 ia32:i686-helenos:image.iso
56 ia64/i460GX:ia64-helenos:image.boot
57 ia64/ski:ia64-helenos:image.boot
58 mips32/malta-be:mips-helenos:image.boot
59 mips32/malta-le:mipsel-helenos:image.boot
60 mips32/msim:mipsel-helenos:image.boot
61 ppc32:ppc-helenos:image.iso
62 sparc64/niagara:sparc64-helenos:image.iso
63 sparc64/ultra:sparc64-helenos:image.iso
64 EOF_CONFIG_SPACE
67 h_get_arch_config() {
68 h_get_arch_config_space | grep "^$H_ARCH:" | cut '-d:' -f "$1"
71 H_DEFAULT_HARBOURS_LIST="binutils fdlibm jainja libgmp libiconv msim pcc zlib libisl libmpfr libpng python2 libmpc gcc"
76 # main script starts here
79 # Check we are actually running inside Travis
80 if [ -z "$TRAVIS" ]; then
81 echo "\$TRAVIS env not set. Are you running me inside Travis?" >&2
82 exit 5
85 # C style check
86 if [ -n "$H_CCHECK" ]; then
87 echo "Will try to run C style check."
88 echo
89 make ccheck || exit 1
90 echo "C style check passed."
91 exit 0
94 # Check HelenOS configuration was set-up
95 if [ -z "$H_ARCH" ]; then
96 echo "\$H_ARCH env not set. Are you running me inside Travis?" >&2
97 exit 5
100 # Check cross-compiler target
101 H_CROSS_TARGET=`h_get_arch_config $H_ARCH_CONFIG_CROSS_TARGET`
102 if [ -z "$H_CROSS_TARGET" ]; then
103 echo "No suitable cross-target found for '$H_ARCH.'" >&2
104 exit 1
107 # Default Harbours repository
108 if [ -z "$H_HARBOURS_REPOSITORY" ]; then
109 H_HARBOURS_REPOSITORY="https://github.com/HelenOS/harbours.git"
112 if [ "$1" = "help" ]; then
113 echo
114 echo "Following variables needs to be set prior running this script."
115 echo "Example settings follows:"
116 echo
117 echo "export H_ARCH=$H_ARCH"
118 echo "export TRAVIS_BUILD_ID=`date +%s`"
119 echo
120 echo "export H_HARBOURS=true"
121 echo "export H_HARBOUR_LIST=\"$H_DEFAULT_HARBOURS_LIST\""
122 echo
123 echo "or"
124 echo
125 echo "export H_CCHECK=true"
126 echo
127 exit 0
129 elif [ "$1" = "install" ]; then
130 set -x
132 # Fetch and install cross-compiler
133 wget "https://helenos.s3.amazonaws.com/toolchain/$H_CROSS_TARGET.tar.xz" -O "/tmp/$H_CROSS_TARGET.tar.xz" || exit 1
134 sudo tar -xJ -C "/" -f "/tmp/$H_CROSS_TARGET.tar.xz" || exit 1
135 exit 0
137 elif [ "$1" = "run" ]; then
138 set -x
140 # Expected output filename (bootable image)
141 H_OUTPUT_FILENAME=`h_get_arch_config $H_ARCH_CONFIG_OUTPUT_FILENAME`
142 if [ -z "$H_OUTPUT_FILENAME" ]; then
143 echo "No suitable output image found for '$H_ARCH.'" >&2
144 exit 1
147 # Build HARBOURs too?
148 H_HARBOURS=`echo "$H_HARBOURS" | grep -e '^true$' -e '^false$'`
149 if [ -z "$H_HARBOURS" ]; then
150 H_HARBOURS=false
152 if [ -z "$H_HARBOUR_LIST" ]; then
153 H_HARBOUR_LIST="$H_DEFAULT_HARBOURS_LIST"
157 # Build it
158 make "PROFILE=$H_ARCH" HANDS_OFF=y || exit 1
159 test -s "$H_OUTPUT_FILENAME" || exit 1
161 echo
162 echo "HelenOS for $H_ARCH built okay."
163 echo
165 # Build harbours
166 if $H_HARBOURS; then
167 echo
168 echo "Will try to build ported software for $H_ARCH."
169 echo "Repository used is $H_HARBOURS_REPOSITORY."
170 echo
172 H_HELENOS_HOME=`pwd`
173 cd "$HOME" || exit 1
174 git clone --depth 10 "$H_HARBOURS_REPOSITORY" helenos-harbours || exit 1
175 mkdir "build-harbours-$TRAVIS_BUILD_ID" || exit 1
177 cd "build-harbours-$TRAVIS_BUILD_ID" || exit 1
178 mkdir build || exit 1
179 cd build
182 #[ "$H_ARCH" = "mips32/malta-be" ] && H_ARCH="mips32eb/malta-be"
183 echo "root = $H_HELENOS_HOME"
184 echo "arch =" `echo "$H_ARCH" | cut -d/ -f 1`
185 echo "machine =" `echo "$H_ARCH" | cut -d/ -f 2`
186 ) >hsct.conf || exit 1
188 "$HOME/helenos-harbours/hsct.sh" init "$H_HELENOS_HOME" || exit 1
190 # We cannot flood the output as Travis has limit of maximum output size
191 # (reason is to prevent endless stacktraces going forever). But also Travis
192 # kills a job that does not print anything for a while.
194 # So we store the full output into a file and print single dot for each line.
195 # As pipe tends to hide errors we check the success by checking that archive
196 # exists.
198 FAILED_HARBOURS=""
199 for HARBOUR in $H_HARBOUR_LIST; do
200 "$HOME/helenos-harbours/hsct.sh" archive --no-deps "$HARBOUR" 2>&1 | tee "run-$HARBOUR.log" | awk '// {printf "."}'
202 test -s "archives/$HARBOUR.tar.xz"
203 if [ $? -eq 0 ]; then
204 tail -n 10 "run-$HARBOUR.log"
205 else
206 FAILED_HARBOURS="$FAILED_HARBOURS $HARBOUR"
207 cat build/$HARBOUR/*/config.log
208 tail -n 100 "run-$HARBOUR.log"
211 done
213 if [ -n "$FAILED_HARBOURS" ]; then
214 echo
215 echo "ERROR: following packages were not built:$FAILED_HARBOURS."
216 echo
217 exit 1
219 ) || exit 1
221 else
222 echo "Invalid action specified." >&2
223 exit 5