Adapt for mainline changes in https://github.com/HelenOS/helenos/pull/15,
[harbours.git] / travis.sh
blob9deaf41883fe12ed2bd6ff4e621063b5302d2351
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 harbours under
33 # Travis CI [1].
35 # You probably do not want to run this script directly. If you wish to test
36 # that HelenOS harbours builds for all architectures, consider using either
37 # our CI solution [2].
39 # [1] https://travis-ci.org/
40 # [2] http://www.helenos.org/wiki/CI
44 H_ARCH_CONFIG_CROSS_TARGET=2
46 h_get_arch_config_space() {
47 cat <<'EOF_CONFIG_SPACE'
48 amd64:amd64-unknown-elf
49 arm32/beagleboardxm:arm-linux-gnueabi
50 arm32/beaglebone:arm-linux-gnueabi
51 arm32/gta02:arm-linux-gnueabi
52 arm32/integratorcp:arm-linux-gnueabi
53 arm32/raspberrypi:arm-linux-gnueabi
54 ia32:i686-pc-linux-gnu
55 ia64/i460GX:ia64-pc-linux-gnu
56 ia64/ski:ia64-pc-linux-gnu
57 mips32/malta-be:mips-linux-gnu
58 mips32/malta-le:mipsel-linux-gnu
59 mips32/msim:mipsel-linux-gnu
60 ppc32:ppc-linux-gnu
61 sparc64/niagara:sparc64-linux-gnu
62 sparc64/ultra:sparc64-linux-gnu
63 EOF_CONFIG_SPACE
66 h_get_arch_config() {
67 h_get_arch_config_space | grep "^$H_ARCH:" | cut '-d:' -f "$1"
73 # main script starts here
76 # Check we are actually running inside Travis
77 if [ -z "$TRAVIS" ]; then
78 echo "\$TRAVIS env not set. Are you running me inside Travis?" >&2
79 exit 5
82 # Check HelenOS configuration was set-up
83 if [ -z "$H_ARCH" ]; then
84 echo "\$H_ARCH env not set. Are you running me inside Travis?" >&2
85 exit 5
88 # Check HARBOUR was definied
89 if [ -z "$H_HARBOUR" ]; then
90 echo "\$H_HARBOUR env not set. Are you running me inside Travis?" >&2
91 exit 5
94 # Check cross-compiler target
95 H_CROSS_TARGET=`h_get_arch_config $H_ARCH_CONFIG_CROSS_TARGET`
96 if [ -z "$H_CROSS_TARGET" ]; then
97 echo "No suitable cross-target found for '$H_ARCH.'" >&2
98 exit 1
102 # Custom CROSS_PREFIX
103 export CROSS_PREFIX=/usr/local/cross-static/
106 # Default HelenOS repository
107 if [ -z "$H_HELENOS_REPOSITORY" ]; then
108 H_HELENOS_REPOSITORY="https://github.com/HelenOS/helenos.git"
111 if [ "$1" = "help" ]; then
112 echo
113 echo "Following variables needs to be set prior running this script."
114 echo "Example settings follows:"
115 echo
116 echo "export H_ARCH=$H_ARCH"
117 echo "export H_ARCH=$H_HARBOUR"
118 echo "export TRAVIS_BUILD_ID=`date +%s`"
119 echo
120 exit 0
122 elif [ "$1" = "install" ]; then
123 set -x
125 # Install dependencies
126 sudo apt-get -qq update || exit 1
127 sudo apt-get install -y genisoimage || exit 1
129 # Fetch and install cross-compiler
130 wget "http://ci.helenos.org/download/helenos-cross-$H_CROSS_TARGET.static.tar.xz" -O "/tmp/cross-$H_CROSS_TARGET.static.tar.xz" || exit 1
131 sudo mkdir -p "$CROSS_PREFIX" || exit 1
132 sudo tar -xJ -C "$CROSS_PREFIX" -f "/tmp/cross-$H_CROSS_TARGET.static.tar.xz" || exit 1
133 exit 0
136 elif [ "$1" = "run" ]; then
137 set -x
139 H_HARBOURS_HOME=`pwd`
141 cd "$HOME" || exit 1
143 git clone --depth 10 "$H_HELENOS_REPOSITORY" helenos || exit 1
145 mkdir "build-$TRAVIS_BUILD_ID" || exit 1
147 cd "build-$TRAVIS_BUILD_ID" || exit 1
149 git clone "$HOME/helenos" helenos || exit 1
152 cd helenos
153 make "PROFILE=$H_ARCH" HANDS_OFF=y >build.log 2>&1
154 RET="$?"
155 tail -n 20 "build.log"
156 exit $RET
157 ) || exit 1
160 mkdir build || exit 1
161 cd build || exit 1
164 echo "root = $HOME/build-$TRAVIS_BUILD_ID/helenos"
165 echo "arch =" `echo "$H_ARCH" | sed 's#mips32/malta-be#mips32eb/malta-be#' | cut -d/ -f 1`
166 echo "machine =" `echo "$H_ARCH" | cut -d/ -f 2`
167 ) >hsct.conf || exit 1
169 "$H_HARBOURS_HOME/hsct.sh" update || exit 1
171 # We cannot flood the output as Travis has limit of maximum output size
172 # (reason is to prevent endless stacktraces going forever). But also Travis
173 # kills a job that does not print anything for a while.
175 # So we store the full output into a file but print every 10th line.
176 # As pipe tends to hide errors we check the success by checking that archive
177 # exists.
179 "$H_HARBOURS_HOME/hsct.sh" archive "$H_HARBOUR" 2>&1 | tee build.log | awk '!(NR%10)'
181 tail -n 1000 build.log
183 test -s "archives/$H_HARBOUR.tar.xz"
185 RET="$?"
186 if [ $RET -ne 0 ]; then
187 exit $RET
190 ls -lh archives
192 set +x
194 echo "Looks good, $H_HARBOUR built on $H_ARCH."
195 echo
196 else
197 echo "Invalid action specified." >&2
198 exit 5