1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright (c) 2018 Vojtech Horky
|
---|
5 | # All rights reserved.
|
---|
6 | #
|
---|
7 | # Redistribution and use in source and binary forms, with or without
|
---|
8 | # modification, are permitted provided that the following conditions
|
---|
9 | # are met:
|
---|
10 | #
|
---|
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.
|
---|
18 | #
|
---|
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.
|
---|
29 | #
|
---|
30 |
|
---|
31 | #
|
---|
32 | # This is wrapper script for testing build of HelenOS under Travis CI [1].
|
---|
33 | #
|
---|
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).
|
---|
38 | #
|
---|
39 | # [1] https://travis-ci.org/
|
---|
40 | # [2] http://www.helenos.org/wiki/CI
|
---|
41 | #
|
---|
42 |
|
---|
43 | H_ARCH_CONFIG_CROSS_TARGET=2
|
---|
44 | H_ARCH_CONFIG_OUTPUT_FILENAME=3
|
---|
45 |
|
---|
46 | h_get_arch_config_space() {
|
---|
47 | cat <<'EOF_CONFIG_SPACE'
|
---|
48 | amd64:amd64-unknown-elf:image.iso
|
---|
49 | arm32/beagleboardxm:arm-linux-gnueabi:uImage.bin
|
---|
50 | arm32/beaglebone:arm-linux-gnueabi:uImage.bin
|
---|
51 | arm32/gta02:arm-linux-gnueabi:uImage.bin
|
---|
52 | arm32/integratorcp:arm-linux-gnueabi:image.boot
|
---|
53 | arm32/raspberrypi:arm-linux-gnueabi:uImage.bin
|
---|
54 | ia32:i686-pc-linux-gnu:image.iso
|
---|
55 | ia64/i460GX:ia64-pc-linux-gnu:image.boot
|
---|
56 | ia64/ski:ia64-pc-linux-gnu:image.boot
|
---|
57 | mips32/malta-be:mips-linux-gnu:image.boot
|
---|
58 | mips32/malta-le:mipsel-linux-gnu:image.boot
|
---|
59 | mips32/msim:mipsel-linux-gnu:image.boot
|
---|
60 | ppc32:ppc-linux-gnu:image.iso
|
---|
61 | sparc64/niagara:sparc64-linux-gnu:image.iso
|
---|
62 | sparc64/ultra:sparc64-linux-gnu:image.iso
|
---|
63 | EOF_CONFIG_SPACE
|
---|
64 | }
|
---|
65 |
|
---|
66 | h_get_arch_config() {
|
---|
67 | h_get_arch_config_space | grep "^$H_ARCH:" | cut '-d:' -f "$1"
|
---|
68 | }
|
---|
69 |
|
---|
70 | H_DEFAULT_HARBOURS_LIST="binutils fdlibm jainja libgmp libiconv msim pcc zlib libisl libmpfr libpng python2 libmpc gcc"
|
---|
71 |
|
---|
72 |
|
---|
73 |
|
---|
74 | #
|
---|
75 | # main script starts here
|
---|
76 | #
|
---|
77 |
|
---|
78 | # Check we are actually running inside Travis
|
---|
79 | if [ -z "$TRAVIS" ]; then
|
---|
80 | echo "\$TRAVIS env not set. Are you running me inside Travis?" >&2
|
---|
81 | exit 5
|
---|
82 | fi
|
---|
83 |
|
---|
84 | # C style check
|
---|
85 | if [ -n "$H_CCHECK" ]; then
|
---|
86 | echo "Will try to run C style check."
|
---|
87 | echo
|
---|
88 | make ccheck || exit 1
|
---|
89 | echo "C style check passed."
|
---|
90 | exit 0
|
---|
91 | fi
|
---|
92 |
|
---|
93 | # Check HelenOS configuration was set-up
|
---|
94 | if [ -z "$H_ARCH" ]; then
|
---|
95 | echo "\$H_ARCH env not set. Are you running me inside Travis?" >&2
|
---|
96 | exit 5
|
---|
97 | fi
|
---|
98 |
|
---|
99 | # Check cross-compiler target
|
---|
100 | H_CROSS_TARGET=`h_get_arch_config $H_ARCH_CONFIG_CROSS_TARGET`
|
---|
101 | if [ -z "$H_CROSS_TARGET" ]; then
|
---|
102 | echo "No suitable cross-target found for '$H_ARCH.'" >&2
|
---|
103 | exit 1
|
---|
104 | fi
|
---|
105 |
|
---|
106 |
|
---|
107 | # Custom CROSS_PREFIX
|
---|
108 | if [ ."$CROSS_PREFIX" == . ]; then
|
---|
109 | export CROSS_PREFIX=/usr/local/cross-static/
|
---|
110 | fi
|
---|
111 |
|
---|
112 | # Default Harbours repository
|
---|
113 | if [ -z "$H_HARBOURS_REPOSITORY" ]; then
|
---|
114 | H_HARBOURS_REPOSITORY="https://github.com/HelenOS/harbours.git"
|
---|
115 | fi
|
---|
116 |
|
---|
117 | if [ "$1" = "help" ]; then
|
---|
118 | echo
|
---|
119 | echo "Following variables needs to be set prior running this script."
|
---|
120 | echo "Example settings follows:"
|
---|
121 | echo
|
---|
122 | echo "export H_ARCH=$H_ARCH"
|
---|
123 | echo "export TRAVIS_BUILD_ID=`date +%s`"
|
---|
124 | echo
|
---|
125 | echo "export H_HARBOURS=true"
|
---|
126 | echo "export H_HARBOUR_LIST=\"$H_DEFAULT_HARBOURS_LIST\""
|
---|
127 | echo
|
---|
128 | echo "or"
|
---|
129 | echo
|
---|
130 | echo "export H_CCHECK=true"
|
---|
131 | echo
|
---|
132 | exit 0
|
---|
133 |
|
---|
134 | elif [ "$1" = "install" ]; then
|
---|
135 | set -x
|
---|
136 |
|
---|
137 | # Install dependencies
|
---|
138 | sudo apt-get -qq update || exit 1
|
---|
139 | sudo apt-get install -y genisoimage || exit 1
|
---|
140 |
|
---|
141 | # Fetch and install cross-compiler
|
---|
142 | 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
|
---|
143 | sudo mkdir -p "$CROSS_PREFIX" || exit 1
|
---|
144 | sudo tar -xJ -C "$CROSS_PREFIX" -f "/tmp/cross-$H_CROSS_TARGET.static.tar.xz" || exit 1
|
---|
145 | exit 0
|
---|
146 |
|
---|
147 |
|
---|
148 | elif [ "$1" = "run" ]; then
|
---|
149 | set -x
|
---|
150 |
|
---|
151 | # Expected output filename (bootable image)
|
---|
152 | H_OUTPUT_FILENAME=`h_get_arch_config $H_ARCH_CONFIG_OUTPUT_FILENAME`
|
---|
153 | if [ -z "$H_OUTPUT_FILENAME" ]; then
|
---|
154 | echo "No suitable output image found for '$H_ARCH.'" >&2
|
---|
155 | exit 1
|
---|
156 | fi
|
---|
157 |
|
---|
158 | # Build HARBOURs too?
|
---|
159 | H_HARBOURS=`echo "$H_HARBOURS" | grep -e '^true$' -e '^false$'`
|
---|
160 | if [ -z "$H_HARBOURS" ]; then
|
---|
161 | H_HARBOURS=false
|
---|
162 | fi
|
---|
163 | if [ -z "$H_HARBOUR_LIST" ]; then
|
---|
164 | H_HARBOUR_LIST="$H_DEFAULT_HARBOURS_LIST"
|
---|
165 | fi
|
---|
166 |
|
---|
167 |
|
---|
168 | # Build it
|
---|
169 | make "PROFILE=$H_ARCH" HANDS_OFF=y || exit 1
|
---|
170 | test -s "$H_OUTPUT_FILENAME" || exit 1
|
---|
171 |
|
---|
172 | echo
|
---|
173 | echo "HelenOS for $H_ARCH built okay."
|
---|
174 | echo
|
---|
175 |
|
---|
176 | # Build harbours
|
---|
177 | if $H_HARBOURS; then
|
---|
178 | echo
|
---|
179 | echo "Will try to build ported software for $H_ARCH."
|
---|
180 | echo "Repository used is $H_HARBOURS_REPOSITORY."
|
---|
181 | echo
|
---|
182 |
|
---|
183 | H_HELENOS_HOME=`pwd`
|
---|
184 | cd "$HOME" || exit 1
|
---|
185 | git clone --depth 10 "$H_HARBOURS_REPOSITORY" helenos-harbours || exit 1
|
---|
186 | mkdir "build-harbours-$TRAVIS_BUILD_ID" || exit 1
|
---|
187 | (
|
---|
188 | cd "build-harbours-$TRAVIS_BUILD_ID" || exit 1
|
---|
189 | mkdir build || exit 1
|
---|
190 | cd build
|
---|
191 |
|
---|
192 | (
|
---|
193 | #[ "$H_ARCH" = "mips32/malta-be" ] && H_ARCH="mips32eb/malta-be"
|
---|
194 | echo "root = $H_HELENOS_HOME"
|
---|
195 | echo "arch =" `echo "$H_ARCH" | cut -d/ -f 1`
|
---|
196 | echo "machine =" `echo "$H_ARCH" | cut -d/ -f 2`
|
---|
197 | ) >hsct.conf || exit 1
|
---|
198 |
|
---|
199 | "$HOME/helenos-harbours/hsct.sh" init "$H_HELENOS_HOME" || exit 1
|
---|
200 |
|
---|
201 | # We cannot flood the output as Travis has limit of maximum output size
|
---|
202 | # (reason is to prevent endless stacktraces going forever). But also Travis
|
---|
203 | # kills a job that does not print anything for a while.
|
---|
204 | #
|
---|
205 | # So we store the full output into a file and print single dot for each line.
|
---|
206 | # As pipe tends to hide errors we check the success by checking that archive
|
---|
207 | # exists.
|
---|
208 | #
|
---|
209 | FAILED_HARBOURS=""
|
---|
210 | for HARBOUR in $H_HARBOUR_LIST; do
|
---|
211 | "$HOME/helenos-harbours/hsct.sh" archive --no-deps "$HARBOUR" 2>&1 | tee "run-$HARBOUR.log" | awk '// {printf "."}'
|
---|
212 |
|
---|
213 | test -s "archives/$HARBOUR.tar.xz"
|
---|
214 | if [ $? -eq 0 ]; then
|
---|
215 | tail -n 10 "run-$HARBOUR.log"
|
---|
216 | else
|
---|
217 | FAILED_HARBOURS="$FAILED_HARBOURS $HARBOUR"
|
---|
218 | cat build/$HARBOUR/*/config.log
|
---|
219 | tail -n 100 "run-$HARBOUR.log"
|
---|
220 | fi
|
---|
221 |
|
---|
222 | done
|
---|
223 |
|
---|
224 | if [ -n "$FAILED_HARBOURS" ]; then
|
---|
225 | echo
|
---|
226 | echo "ERROR: following packages were not built:$FAILED_HARBOURS."
|
---|
227 | echo
|
---|
228 | exit 1
|
---|
229 | fi
|
---|
230 | ) || exit 1
|
---|
231 | fi
|
---|
232 | else
|
---|
233 | echo "Invalid action specified." >&2
|
---|
234 | exit 5
|
---|
235 | fi
|
---|
236 |
|
---|