Add harbour for GZX
[harbours.git] / travis.sh
blob00c4c96b8de7dc08b27c2a9c6bf30daa3c83fe5a
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
43 H_ARCH_CONFIG_CROSS_TARGET=2
45 h_get_arch_config_space() {
46 cat <<'EOF_CONFIG_SPACE'
47 amd64:amd64-helenos
48 arm32/beagleboardxm:arm-helenos
49 arm32/beaglebone:arm-helenos
50 arm32/gta02:arm-helenos
51 arm32/integratorcp:arm-helenos
52 arm32/raspberrypi:arm-helenos
53 ia32:i686-helenos
54 ia64/i460GX:ia64-helenos
55 ia64/ski:ia64-helenos
56 mips32/malta-be:mips-helenos
57 mips32/malta-le:mipsel-helenos
58 mips32/msim:mipsel-helenos
59 ppc32:ppc-helenos
60 sparc64/niagara:sparc64-helenos
61 sparc64/ultra:sparc64-helenos
62 EOF_CONFIG_SPACE
65 h_get_arch_config() {
66 h_get_arch_config_space | grep "^$H_ARCH:" | cut '-d:' -f "$1"
72 # main script starts here
75 # Check we are actually running inside Travis
76 if [ -z "$TRAVIS" ]; then
77 echo "\$TRAVIS env not set. Are you running me inside Travis?" >&2
78 exit 5
81 # Check HelenOS configuration was set-up
82 if [ -z "$H_ARCH" ]; then
83 echo "\$H_ARCH env not set. Are you running me inside Travis?" >&2
84 exit 5
87 # Check HARBOUR was definied
88 if [ -z "$H_HARBOUR" ]; then
89 echo "\$H_HARBOUR env not set. Are you running me inside Travis?" >&2
90 exit 5
93 # Check cross-compiler target
94 H_CROSS_TARGET=`h_get_arch_config $H_ARCH_CONFIG_CROSS_TARGET`
95 if [ -z "$H_CROSS_TARGET" ]; then
96 echo "No suitable cross-target found for '$H_ARCH.'" >&2
97 exit 1
100 # Default HelenOS repository
101 if [ -z "$H_HELENOS_REPOSITORY" ]; then
102 H_HELENOS_REPOSITORY="https://github.com/HelenOS/helenos.git"
105 if [ "$1" = "help" ]; then
106 echo
107 echo "Following variables needs to be set prior running this script."
108 echo "Example settings follows:"
109 echo
110 echo "export H_ARCH=$H_ARCH"
111 echo "export H_ARCH=$H_HARBOUR"
112 echo "export TRAVIS_BUILD_ID=`date +%s`"
113 echo
114 exit 0
116 elif [ "$1" = "install" ]; then
117 set -x
119 # Fetch and install cross-compiler
120 wget "https://helenos.s3.amazonaws.com/toolchain/$H_CROSS_TARGET.tar.xz" -O "/tmp/$H_CROSS_TARGET.tar.xz" || exit 1
121 sudo tar -xJ -C "/" -f "/tmp/$H_CROSS_TARGET.tar.xz" || exit 1
122 exit 0
124 elif [ "$1" = "run" ]; then
125 set -x
127 H_HARBOURS_HOME=`pwd`
129 cd "$HOME" || exit 1
131 git clone --depth 10 "$H_HELENOS_REPOSITORY" helenos || exit 1
133 mkdir "build-$TRAVIS_BUILD_ID" || exit 1
134 cd "build-$TRAVIS_BUILD_ID" || exit 1
135 git clone "$HOME/helenos" helenos || exit 1
136 mkdir build || exit 1
137 cd build || exit 1
138 "$H_HARBOURS_HOME/hsct.sh" init "$HOME/build-$TRAVIS_BUILD_ID/helenos" $H_ARCH || exit 1
140 # We cannot flood the output as Travis has limit of maximum output size
141 # (reason is to prevent endless stacktraces going forever). But also Travis
142 # kills a job that does not print anything for a while.
144 # So we store the full output into a file and print single dot for each line.
145 # As pipe tends to hide errors we check the success by checking that archive
146 # exists.
148 "$H_HARBOURS_HOME/hsct.sh" archive "$H_HARBOUR" 2>&1 | tee build.log | awk '// {printf "."}'
150 tail -n 1000 build.log
152 test -s "archives/$H_HARBOUR.tar.xz"
154 RET="$?"
155 if [ $RET -ne 0 ]; then
156 exit $RET
159 ls -lh archives
161 set +x
163 echo "Looks good, $H_HARBOUR built on $H_ARCH."
164 echo
165 else
166 echo "Invalid action specified." >&2
167 exit 5