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